此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; U6 d" i) r, T" [! s2 }5 @0 X
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
/ l% ?& F! _. Y( e% o) ]' ^ 方式一:
- z) D) D% o" f2 {# T% V 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,# S1 {5 W4 z! C) U& P7 ~& p; N
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和0 _! }2 s! s7 `, m" ~+ U
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 v9 M6 s7 b. H& W( D% D0 r; U 方式二:
8 U8 U$ A- J. P9 a 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# z9 |7 x% r% O; B! x SetTitleMatchMode RegEx
4 q+ m$ ?1 d6 L) J) _0 { return5 i* i0 ^1 d1 q, w4 p! t/ c
; Stuff to do when Windows Explorer is open; n3 |9 C4 e: F1 r5 }. a
;2 Q* M$ e' r/ i e9 W
#IfWinActive ahk_class ExploreWClass|CabinetWClass, b: t7 N0 R$ x4 K+ e9 x5 G
; open ‘cmd’ in the current directory; M+ D; K7 r0 z9 s4 J7 Z) }( C
;% B/ J( D* w, {1 o/ q# G. g
#c::4 x$ L. m% Q. w
OpenCmdInCurrent()
! I4 ^% C! S1 b# U0 G& C; g return
7 M7 N. P) O7 P& c1 B9 \ #IfWinActive
" u8 e# }% ^' F; ?& _3 Z8 X ; Opens the command shell ‘cmd’ in the directory browsed in Explorer. h9 P4 a# r2 x
; Note: expecting to be run when the active window is Explorer.
, V/ L% `. }; W ;
, T) c9 O; p: e6 @$ y* w OpenCmdInCurrent()
' l$ M4 l5 D+ @ m: X {( D: M, V5 o9 c6 K
; This is required to get the full path of the file from the address bar
& X* n' `' U3 |9 m& P9 ]$ E! E WinGetText, full_path, A7 A; k- N8 A: Y7 _, @
; Split on newline (`n): u M) K) s1 E. A' Z
StringSplit, word_array, full_path, `n
4 o8 d9 @- E L8 R ; Take the first element from the array3 E; @, \7 h# E$ v; n, O+ T9 N
full_path = %word_array1%
5 r: f. l+ D& v* H* m7 T ; strip to bare address) H, W- A% j. z( S
full_path := RegExReplace(full_path, “地址: “, “”)
. a2 t9 m9 q( q ; Just in case – remove all carriage returns (`r), {/ u( s4 l" ~0 K
StringReplace, full_path, full_path, `r, , all/ J2 S& w! Y X8 a, K
IfInString full_path, \
+ y5 S' Q+ \+ C' h2 {, F {
& O# n# d: y1 F5 n/ i6 p Run, cmd /K cd /D “%full_path%”
' r5 P; D) x) R2 O/ C }
+ f$ K) D9 a6 K: i; M$ R: ?' G# ?4 z# ? else
1 X# y' Q8 N& a2 ^1 t# Y4 y {
4 v7 D& G( c( u, x9 w9 C" S- r; T Run, cmd /K cd /D “C:\ ”
/ O9 g( ] s" Z7 s3 i }) h8 ~ n6 q7 L1 {5 x: j
}
M2 r3 k9 H3 |" `% v6 i 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
6 O1 G6 j% |2 W5 |) E2 H 这段小代码肯能有两个你需要修改的地方2 U7 P9 O7 M' b
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 R& U9 d: i7 Y) Q- a9 S5 A
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ J: e+ X4 R0 q# g0 m
|