此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。" b1 o% h3 H/ S, x; z. ]
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
& Q9 Z5 c6 ?+ E 方式一:3 [& h D0 w8 b% _
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
* j9 ~3 K. X2 u8 m 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: w, X! `6 a& `8 M1 r0 k: V7 Z
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。 |9 l9 g! x& o; Q' p2 P2 e
方式二:9 S! S; y) n- ]( q6 U. @
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:1 s4 c/ R! _5 e+ `
SetTitleMatchMode RegEx
4 b/ K6 [; H: {) ]* s) m return
/ g& [& H, W3 T/ p- R8 F: b& ~ y+ } ; Stuff to do when Windows Explorer is open
! O' `+ `9 G1 X8 S- o ;
. g2 C9 b- l5 C #IfWinActive ahk_class ExploreWClass|CabinetWClass, \1 P( r' D$ k) y8 U* G) H8 }
; open ‘cmd’ in the current directory! e P& X& ]( S% r6 t4 o6 |
;
* [ A" Y+ v2 h, a5 Z" T #c::" }% }) X# b5 c F+ c
OpenCmdInCurrent()
3 a. q# a5 l4 f. ]; {0 G9 o" [1 e return
- Q2 |; R! O8 p& H7 a$ T6 B8 O #IfWinActive
+ {, L. m6 s, f! }5 C ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.( W) n9 n/ A: @- {9 A
; Note: expecting to be run when the active window is Explorer.+ v+ |) Q/ p7 F! J- X
;; p4 u/ W; n* o) Z" r& L
OpenCmdInCurrent(). E$ L0 Z# z& }$ L2 G; F! l
{! w$ ?- V9 ?& V% R' [, Z# T. e
; This is required to get the full path of the file from the address bar
/ A7 j6 Q6 B( f6 [' J WinGetText, full_path, A9 t# A7 z' n# `+ o
; Split on newline (`n)
8 @# g7 w* ^1 ^$ A2 R1 E2 l StringSplit, word_array, full_path, `n
) n% S+ R9 ]# G" e# ?% i ; Take the first element from the array
0 c# M U7 G3 p3 u9 I) P: n full_path = %word_array1%
4 ]6 t% O% K7 k6 s ; strip to bare address
2 e9 T8 x. ~) r full_path := RegExReplace(full_path, “地址: “, “”)% e4 o2 f! u R
; Just in case – remove all carriage returns (`r)
3 o% D7 Y" s( z" ?- C( R StringReplace, full_path, full_path, `r, , all( {" `: g- ~4 ~
IfInString full_path, \1 @9 O( [% }0 N0 Y1 W3 f
{& G0 E8 b' Z; @% _8 w; o
Run, cmd /K cd /D “%full_path%”
5 A$ {8 k- ^9 i }- n" z& V1 o9 L. W: G/ i9 S+ d
else4 u% Q6 R8 Q4 l' O2 Z+ {( _) Y4 o
{ v7 w' ]3 Y# C
Run, cmd /K cd /D “C:\ ”8 \; q4 b: [0 C7 u1 _
}. N9 i# s, A6 }2 N
}
) o$ X$ H5 ~6 v& g! I7 R# ~ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
1 b8 G [3 J$ C9 V- Y" D) | 这段小代码肯能有两个你需要修改的地方# l! W; K6 c" a: o, g
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
/ t7 o( M$ b- Z5 |: d! y7 D) y 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ X, W1 d/ P, q; `1 v/ G' Q |