此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- P" K) p6 r8 y& p 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
. ]3 r+ ~. X3 m. j 方式一:
/ q" Q7 x9 Z; P+ M& W" I7 g6 k 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,! J! p! ?$ ?: @- ?# U; \+ O
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
- Q9 I3 X* a& o) m HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 Y0 [6 g: [$ n/ g- [$ W3 g* @ 方式二:
) c& f3 [- r' Z. f0 z0 W4 J7 a+ R# | 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
9 n$ a; \7 R5 ^2 M1 y1 z$ L SetTitleMatchMode RegEx
+ r; E- E8 F8 G$ N/ W7 v6 k6 c return' L* i1 E& E8 O$ ?/ F F
; Stuff to do when Windows Explorer is open
1 l" A0 Q. M% K w ;6 s' b+ w' b2 F; K0 M1 E* V
#IfWinActive ahk_class ExploreWClass|CabinetWClass9 {7 t5 y" q4 q8 q0 c3 ~ A
; open ‘cmd’ in the current directory
8 B- Y" E- b2 r% e' T. A! q ;
# Y. M# s$ ]7 j) y1 V #c::( k; m }7 E; t
OpenCmdInCurrent()7 t' H) ` p) F& u8 l7 b k
return8 U5 t F% ?) E2 R3 @5 i# d; b
#IfWinActive
" J- i) H1 m' q ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 l2 _9 w- M! l7 i: ]! w* J! Q& } ; Note: expecting to be run when the active window is Explorer.
+ J# L. q4 x( g* F ;5 e1 o8 }! d, E" S% ^8 r
OpenCmdInCurrent()
/ ?0 }3 a4 c, _9 F {
* `! {" j5 a0 Q# m( } ; This is required to get the full path of the file from the address bar8 {8 [* z5 A+ Q" k
WinGetText, full_path, A
0 e0 P; l7 w6 l3 ? ; Split on newline (`n)( R6 H' W/ l0 ^7 O) ~
StringSplit, word_array, full_path, `n
/ G0 v* ?' Y5 M* y6 Y7 m ; Take the first element from the array6 b# i/ a8 G8 n0 \5 \
full_path = %word_array1%! S, }* x& S; B( C; H5 n4 L
; strip to bare address
+ s3 i8 d7 v* M full_path := RegExReplace(full_path, “地址: “, “”)
1 B7 e: _' O" e9 E- i' M ; Just in case – remove all carriage returns (`r)
3 w9 J+ S; Y& J& w( y StringReplace, full_path, full_path, `r, , all$ U8 f9 g6 i! h. Y" ]4 y8 `8 C( P
IfInString full_path, \
& F: A$ j# M. U+ Y1 | {* M J9 N2 G( e" n- P ~3 f% j
Run, cmd /K cd /D “%full_path%”
/ M7 P7 ^$ F6 N }$ p% K2 e# X6 e
else; G. h/ ~! P& J
{( t( H& `1 z. e# Y* r7 H
Run, cmd /K cd /D “C:\ ”! z) U. T) ?% r7 q e& E
}
% R- G: J. \ Z% V# l9 }' g }
2 m: W6 D9 B4 v/ o3 T% x) u 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。3 G% U0 Q0 k: j/ a- M7 v; Q
这段小代码肯能有两个你需要修改的地方 D9 Z; \0 }, A7 w: b7 x9 @' J8 p
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键5 d2 ~* ^4 `- f$ e
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 L3 [9 @& n: o! V+ j; }8 A |