此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ |. }- K1 F7 F! F, v+ X' a% I Y
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
^9 @1 e+ x0 M2 I/ M1 P9 B( T7 N 方式一:
2 z6 |2 }2 ?; J 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( G* B; ^" U' ^% L' D" \/ v9 ]9 K: j
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和. ?$ d$ B! v5 F3 W8 z, C
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。7 @, B1 m" S& N$ E3 c8 m2 ]
方式二:
- Z* C/ R& Z6 w/ ~# k5 Z) }* M- v3 U 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
; T# o8 Z7 W1 Q+ M SetTitleMatchMode RegEx- L# Z2 Y; g: m* Z" Q3 T5 F7 k
return. s f$ ? j. p& i; n
; Stuff to do when Windows Explorer is open. r9 D/ v" l+ [, M3 L
;" v1 B: ^; W y( T. T0 `3 C
#IfWinActive ahk_class ExploreWClass|CabinetWClass# M5 k) S7 S. |$ Z- R
; open ‘cmd’ in the current directory
* q q. ^2 L9 J( h' F O( e ;, M8 I5 n S3 s6 t7 ^8 Y
#c::
0 ^$ e6 x x& J, w' } OpenCmdInCurrent()6 d. V1 X. S5 J3 |7 d, P
return/ {% d: S8 g, }6 T
#IfWinActive5 v3 d3 k( T9 t; G
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) F) q8 o! c' i2 a
; Note: expecting to be run when the active window is Explorer.9 ^, l+ s* ]' ^# W: A6 T% ^
;
: ^: m( u1 w8 `7 H* X4 {- M3 f OpenCmdInCurrent()
! l- V. j2 f, U3 W {+ K n# n# A% n/ c
; This is required to get the full path of the file from the address bar
) d9 @7 i) P: u WinGetText, full_path, A+ N' Q9 T' M( M
; Split on newline (`n)) N. V( P* ?, {6 _: w( S
StringSplit, word_array, full_path, `n0 R( _1 G7 Q+ Y
; Take the first element from the array
9 [( l- m4 t- N- \" I" \4 {$ O9 R/ b full_path = %word_array1%* c! T8 \" @6 f% b1 k% N8 _! l
; strip to bare address
6 m7 P, G, K7 E; T9 c full_path := RegExReplace(full_path, “地址: “, “”)
; S; r* U3 X1 R* `4 V* X ; Just in case – remove all carriage returns (`r)
$ k1 J/ s( W4 U* H7 t4 a. ]8 { StringReplace, full_path, full_path, `r, , all
) y$ G0 J; x7 `1 I' @ IfInString full_path, \
2 [+ d6 b- H5 k* Y* o' q {, j9 [( {4 O" t4 }
Run, cmd /K cd /D “%full_path%”$ d$ I4 {7 z5 O
}
) h6 m1 k. m! V# w8 t; d else
7 B3 t/ _7 ~. \2 O2 b) W3 u- f. N {) d m7 R, X- H" z
Run, cmd /K cd /D “C:\ ”+ H% T6 U: g. k
}% L5 B+ [6 J; E& W; P: J( A2 f0 ?4 e( s
}% U6 P/ w0 K8 [" o$ X' `3 G
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
, V# k3 ?/ {% A 这段小代码肯能有两个你需要修改的地方; e+ j, c3 N" W' {1 z/ |; j- O
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
" d( k+ G, g( G" |' g7 s+ r 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “ G( D: k; D1 S" y: c
|