此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( ~1 k( P: @, i; j; l
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
k7 ~, I2 D3 z3 x v6 [3 m* J 方式一:& I- a% ?; |# e6 I( I
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ Q" H' U: s( O+ o
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 R7 }9 q/ X2 G* [) ?3 z; C' }
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 W0 t/ w1 }2 l: d" q$ j
方式二:! N4 s) w! [" t" Q
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
9 c1 s$ b' i9 P8 A4 | SetTitleMatchMode RegEx
( k$ T" j7 Y% t7 O return3 x! x1 @/ A9 t$ m
; Stuff to do when Windows Explorer is open" E& d; f$ p$ V. t
;
4 G& K* b: ]: q4 r, a #IfWinActive ahk_class ExploreWClass|CabinetWClass
2 ^' u* i% Z. l4 [4 _' H: b. u4 j ; open ‘cmd’ in the current directory' ]% Q8 ~$ f" S) g' Q& L' z
;; j* f d) J8 |: e6 v" H3 R2 ^
#c::
1 B |' ]( e+ E. J1 R0 O9 v OpenCmdInCurrent(); X- l/ m& B! b3 m) k6 X0 _9 G( {
return7 w( `/ `# v! o" P
#IfWinActive: H4 N1 D ]+ `: h* S
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
/ E+ L6 ?& [9 x' l1 z. [6 R; [ ; Note: expecting to be run when the active window is Explorer.9 K9 P7 Z/ @& H6 Y( v8 B
;
( x j7 O D' Y* t( G0 }* a* O$ o5 a OpenCmdInCurrent() o' r% s. Z* [: V- O
{
( I- M9 M$ e: N ; This is required to get the full path of the file from the address bar; r; A8 K9 U/ Y, c( ^5 B0 v5 j
WinGetText, full_path, A' }' t0 v1 B* A) L
; Split on newline (`n)) j# W" x, K' m0 Q0 R0 e
StringSplit, word_array, full_path, `n/ R% L/ Q T8 t% R& ?
; Take the first element from the array
( \$ v4 f* U; q$ o, M4 S full_path = %word_array1%
/ A/ Q2 h% |/ p5 t6 o) P' W" G ; strip to bare address
5 R. B% N8 ]& p. T, [( ? full_path := RegExReplace(full_path, “地址: “, “”)' L+ x! r5 ?& f: e
; Just in case – remove all carriage returns (`r)( I" I& F# x2 h8 Y8 P. ~
StringReplace, full_path, full_path, `r, , all: X8 d& k2 J5 X
IfInString full_path, \& _8 n; g$ M, @
{
% q' ~1 V' C2 C e! O; i$ i7 A Run, cmd /K cd /D “%full_path%”
! b1 m- O- y; M0 a: m( K }5 F6 H# q8 b& U0 B M
else: M p! T7 e H+ w% @- ^; B. }
{6 e+ |" z/ u- E, r. J/ r5 u* a5 ]
Run, cmd /K cd /D “C:\ ”
?+ U; W3 I) p8 k+ ~ }, ^) W7 a3 B8 Q( C
}" J# k) c% M& ?3 u
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 V5 D, [. l5 y4 V& ~
这段小代码肯能有两个你需要修改的地方) r4 z- A% v( G7 g( S
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键+ A" k# a6 N$ H" K2 l) n
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
+ n7 }. [$ ?3 y2 a( r$ c |