此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。5 o* R0 X) h: I- ]
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
& [8 ~- u+ P% i8 m! m 方式一:
) n: @/ z: o; j8 q5 I 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% U8 L7 I6 M* J 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和5 {) k2 |5 i+ W' h0 x b
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。3 U/ _& ~: m% e7 m, q
方式二:
; A' e$ ~( m) l9 b8 } 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
0 U$ d. J* O0 y, a8 @ SetTitleMatchMode RegEx
! D' b9 _; s/ `5 Q return
! T- _) X# o' K2 G# W0 L' f3 M) _ ; Stuff to do when Windows Explorer is open
6 }% k- p' [( \! z" F d& i1 S ;
% e3 }5 V; |: q3 X$ w2 J! t1 a #IfWinActive ahk_class ExploreWClass|CabinetWClass
* ]( ]0 g7 x& w" i: G: |3 C s ; open ‘cmd’ in the current directory; R8 F8 m& G) o( K0 M8 q
;( G4 p6 @4 E& ?& i
#c::( ^/ ~: ]/ @+ W8 N8 d% \
OpenCmdInCurrent()
/ G! W+ j% H, L5 }9 f" J. A return
" ~) X/ W% I$ d7 Q0 z5 T #IfWinActive
8 o9 P( ^$ i, `8 M* f ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.4 g3 @* }0 ?. j( r8 O+ ^
; Note: expecting to be run when the active window is Explorer.0 l/ Q( c! @) z
;
8 Q& h* `% Z' A OpenCmdInCurrent()
+ g2 a7 H0 O/ T9 j {
) R& n' ?9 e* i ; This is required to get the full path of the file from the address bar
% a. h7 \- a( I) k' } WinGetText, full_path, A
1 A- P7 K5 x& `* h# m8 X2 Q6 X ; Split on newline (`n)
# @& e1 A# F' Q/ b: O1 c& ?* w StringSplit, word_array, full_path, `n
1 @0 ^5 b5 m' B, z- _7 W ; Take the first element from the array
, T3 x9 Y) r* n/ y full_path = %word_array1%8 a& `- d; P! a7 s" O: @+ H# M
; strip to bare address1 U! u. _0 X2 ~% I: g! ]4 B
full_path := RegExReplace(full_path, “地址: “, “”)% W H: y( j0 A3 R4 V1 N
; Just in case – remove all carriage returns (`r)
) {' M6 k, ?- d1 ~ StringReplace, full_path, full_path, `r, , all
" O5 H: N1 Z% u' D' u. Y- I$ ? IfInString full_path, \
& \2 K G7 d8 f1 e4 p& O6 ^ {) n4 H3 @6 J2 j, t& Y( K0 ?( \
Run, cmd /K cd /D “%full_path%”
6 R1 F) N2 b8 p2 T# d }
! f) E4 O% N, k8 P n( l$ f; f. m else- z5 ? o# u% O9 y$ F
{
* N6 u2 h& B$ D1 F E" ]& S Run, cmd /K cd /D “C:\ ”
$ `0 w% i2 {: m, M0 \' ?; C; P }
- M; X6 q9 V* V6 B4 O2 \ }; O3 I6 \! n+ C1 I6 V' b
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
' o8 q& {" A' T6 u 这段小代码肯能有两个你需要修改的地方
3 D% T& j- ~, P: ]1 @+ G$ h" V8 Z: w 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键7 u0 X* S4 u! f3 D: ~$ y4 N( c
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
1 U5 Y4 J1 r5 _) m/ j. c3 z |