此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 N' L. k4 x0 w. m \+ h9 n- p( [% m
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。; w0 s! O [, k( G
方式一:
+ x; b! w; ^$ u4 G 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,5 A) y# U. i5 p" T
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和+ W7 O- c- P( `: O3 Q
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
% v+ s: z7 i! I, ^/ N 方式二:
* ~5 C* T5 ` q2 R# j& [2 m 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( U0 l+ m2 o/ u5 I2 X S SetTitleMatchMode RegEx
" d/ f3 K! _* F8 P return7 f% n) Z* b' I+ k& F$ m8 A
; Stuff to do when Windows Explorer is open' t& _! j( i/ S5 S" F; x
;5 F9 b1 E A% W p) }
#IfWinActive ahk_class ExploreWClass|CabinetWClass. Z: W) W0 z. n" I
; open ‘cmd’ in the current directory; K; |- N* O9 b) x9 ^7 l9 I* F% v
;
" a# _* ~3 V0 J #c::7 ^2 t; t, j3 F" s6 y1 }
OpenCmdInCurrent()$ P m' u- E; F- P8 C
return% V3 S/ k' y2 {7 r9 F* `, L$ y
#IfWinActive6 n# { @1 b4 r$ _) w2 E5 z/ T
; Opens the command shell ‘cmd’ in the directory browsed in Explorer." D8 Z; G' v. F9 f
; Note: expecting to be run when the active window is Explorer.) P2 H/ X) M. T
;1 M. t+ M# q9 J9 F! E6 V' ~
OpenCmdInCurrent() {$ ^- y. o. M8 U4 Y
{5 T6 ]3 J- o' M' k" k
; This is required to get the full path of the file from the address bar6 Y: @4 t/ t, o* U+ }
WinGetText, full_path, A
. g2 ]: C2 V' d6 t9 R, B ; Split on newline (`n)
5 C, [1 v% y3 N& T StringSplit, word_array, full_path, `n
/ z, o, R( T% m6 R ; Take the first element from the array0 ~! d& k8 R5 h
full_path = %word_array1%; H( ]- ^9 i: u
; strip to bare address
+ l* l& H+ `* Q' E- v' }7 U( F full_path := RegExReplace(full_path, “地址: “, “”). w3 A4 f ?' x& l6 s0 H7 y) l
; Just in case – remove all carriage returns (`r)
- B% N A+ B o2 y' h4 u& X StringReplace, full_path, full_path, `r, , all( h# \& A, |4 A* ~* Z4 Y& ~7 _# q
IfInString full_path, \' S3 s& S! i% ?. l$ ~ H
{: L$ f- p7 v, J& s' U' @2 ?
Run, cmd /K cd /D “%full_path%”
/ J; J W; g& N: q }
/ L5 ?; s5 h' w4 ^' \ else$ ]( u! r4 v5 S! j: F# O. ^0 x
{
- Z& a5 s- ]1 c, y* g' L& R Run, cmd /K cd /D “C:\ ”" q) \! p, Y/ J0 E! a5 S7 t0 Q
}% O0 `- d/ t$ V+ y1 I
}
; {0 \) o9 S& |0 O) F 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 f+ O: t+ G* |8 y9 C0 ^ 这段小代码肯能有两个你需要修改的地方$ ?- Q! S7 H$ \5 K
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
5 ]: ?( r* m; l! Y& \/ @+ [# s. O2 ]( Y! M 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; z8 _4 j( T6 d# ], b
|