此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
$ ?1 ~1 {, W/ r$ q: L0 n# ^' Q 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 I( ?- ^4 `( S3 p" D2 m, m+ A7 m 方式一:
1 T/ G" j+ j/ {+ M" p 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
0 B/ n/ e" v5 P! o* i9 e( k 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和 z' K" p3 h U& M9 C
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) J9 g( F& L/ i e, L/ b, M D 方式二:
! z% ^: d. i% A" P5 y3 x8 m 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:. ]- @5 y/ f: I
SetTitleMatchMode RegEx6 @. u% p# v6 c$ X) F
return
3 h( g# @' x3 @# U. q ; Stuff to do when Windows Explorer is open3 r- A7 Z+ u/ _9 v7 h
;
0 @- N. B% d+ A2 f0 j9 N: [: O #IfWinActive ahk_class ExploreWClass|CabinetWClass
) `7 f; [' b$ i ; open ‘cmd’ in the current directory4 [' s! i5 O. ?7 n9 V
;
7 U& i! _/ q2 U% _+ m #c::1 s1 N) z2 T* J2 v2 n( N
OpenCmdInCurrent()2 ?. }+ h. o1 `" {
return
- O4 k* y4 U+ S# g" R) W K- ~5 O2 B #IfWinActive- \% V$ u( `$ R5 b- n8 m/ t. l
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 O& q) A: \, X: d1 a2 h ; Note: expecting to be run when the active window is Explorer.( A1 R) c: c. ?6 l! q
;2 G2 [# g8 g& L. J1 K1 |( S( y6 |
OpenCmdInCurrent()1 V& {) S7 }0 N' I' S
{3 |# E( z$ G9 s. { i' M9 \4 `( s
; This is required to get the full path of the file from the address bar
" k2 [. P' _# X2 \ w* e/ t( X WinGetText, full_path, A
' q2 ^8 ` K$ d ~( b: t ; Split on newline (`n)# R1 R) A. b9 S) L
StringSplit, word_array, full_path, `n e! F7 s6 N# \5 }8 n" B
; Take the first element from the array5 O- U, W/ K* l
full_path = %word_array1%$ y7 N" `" u2 C
; strip to bare address9 c; C$ z6 h. m d
full_path := RegExReplace(full_path, “地址: “, “”)
7 p% e# N$ x! d. a/ ?& w ; Just in case – remove all carriage returns (`r)9 w; u9 R0 R6 V; I& {/ m* ~
StringReplace, full_path, full_path, `r, , all1 Y$ d3 c% p# X1 `: x' T! D7 j
IfInString full_path, \3 O4 K: I+ V7 t* K# }( W! w
{
7 b$ v: D5 K; m8 k2 a" E6 ?$ l Run, cmd /K cd /D “%full_path%”. e# ^* ]9 V4 w: \- A
}1 [. z: q' p+ Y; ]
else
8 V# A( U' ]1 `$ H9 r; G {* |% H) y. j% s2 B/ ]& }# |# K
Run, cmd /K cd /D “C:\ ”& D! K( K8 w7 @
}
0 h& B& h' R9 }. i0 E }
5 G. i) | X5 p4 J( h, T/ F# C 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! l8 t8 n4 l) X" W
这段小代码肯能有两个你需要修改的地方. _$ c! B$ G( O4 G
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
, I/ t: l' E7 c% X+ O 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “" v9 H5 m* j8 M5 y4 X. A5 [
|