此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。! t- J' d' g- O5 z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
2 z" h- W! t# p( L; G- t 方式一:- D2 r6 w" j7 z* v& i
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,: t0 u0 W6 L7 e: G
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 K0 N0 e5 y5 r$ B9 P, n HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。# w9 o8 w; p) Q) P
方式二:
/ }, ?$ ]' _" c2 ? 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ O6 M+ l) c/ _ SetTitleMatchMode RegEx, W! Z: w: J4 n+ i) _
return& {2 T/ K7 u& i$ f
; Stuff to do when Windows Explorer is open: M0 x- S1 e: w4 U
;) K4 A1 D* `/ N' J! E" L4 o& }
#IfWinActive ahk_class ExploreWClass|CabinetWClass
7 m1 h) g3 E2 S ; open ‘cmd’ in the current directory1 J8 T3 v+ z( N4 L0 v9 G
;9 N6 W8 b; o. G* w8 X2 }& o* E
#c::* Y9 }2 g: {- r0 r
OpenCmdInCurrent()8 e. Q% i h) f% s; l
return
' w; o9 y, j' Z7 i) O- y; m) `+ v #IfWinActive( a2 I/ f/ g) z1 h& m a! n
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.1 s0 c9 x0 t/ }3 Z
; Note: expecting to be run when the active window is Explorer.) R$ D# J0 d* G7 C6 C5 G
;
6 e" k' P' n5 y8 Z0 Y2 t6 m OpenCmdInCurrent(): z! S+ y' ~* W" _5 g$ m( \) O
{
9 Q A% I+ `! \/ B* C2 J ; This is required to get the full path of the file from the address bar
& O b. W3 s; ?7 h3 Y! x: ]) h) v WinGetText, full_path, A
9 w; I- C! Z* ^/ T5 F8 t ; Split on newline (`n)
6 X2 y* w0 K& z' k StringSplit, word_array, full_path, `n
" g" F; w2 O5 V; ^7 ?6 P ; Take the first element from the array' z) O$ v" H/ w8 ~$ R J
full_path = %word_array1%$ p) x5 B! E; p+ p& D/ G5 J$ v K# Q
; strip to bare address- F7 ^1 u( k& D! T0 {
full_path := RegExReplace(full_path, “地址: “, “”)
8 }' N8 X+ B# u: Y! } ; Just in case – remove all carriage returns (`r)
4 R7 P- J; y5 _9 J# c1 r" X StringReplace, full_path, full_path, `r, , all
, r R7 ]/ O, N+ F" F IfInString full_path, \
6 Y5 d* a8 a) v' x+ b/ Q/ A' u, L: y {* w( k: _: X4 w" Y
Run, cmd /K cd /D “%full_path%”0 u; k# ]1 M2 V# T9 |- n
}
h# d( W5 g, C% C, t/ X else( B, ~) S# X) s/ W$ O; v
{+ N8 t" M4 C7 I. Y8 r; R+ A
Run, cmd /K cd /D “C:\ ”
. O8 z; `2 _; r8 @/ _5 ` }
2 M6 l: l! \! p1 j/ B( f' } }
) O q. K: R9 N8 T* ^8 F 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
6 q( h5 ~$ o' G6 P, F 这段小代码肯能有两个你需要修改的地方
8 |6 t1 q a: Q7 Y& d" m- I 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
9 {5 `4 L+ Z9 m7 {% ~ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 T" k( ?7 A T |