此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。& W9 S5 [: A# V
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。# B* L' O8 m( Q/ S1 x0 n
方式一:
' J% W2 ^9 R/ g* g ]% w 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% p. u& @6 @2 K 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和( V: W* `! A1 Z8 Z+ B4 O& R5 J
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
R9 J" ?! E$ F6 U! U Y 方式二:4 ~* X' W# ~4 m3 A3 p; w7 ]
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
1 A$ g. Z) V! J3 e- J SetTitleMatchMode RegEx
! h$ K5 A1 J% s. ?, H) } return
4 H/ c8 m3 y1 I8 V2 O ; Stuff to do when Windows Explorer is open4 r! ~3 l- W& Z4 g0 }; v
;3 V- o4 x' d1 m5 a8 U% e% d& a
#IfWinActive ahk_class ExploreWClass|CabinetWClass! i3 F" h3 j0 ~5 t8 o
; open ‘cmd’ in the current directory
/ V* _4 x5 \4 d; E ;! r* b! X0 y8 x4 H
#c::
, }$ G3 p) k4 v7 T OpenCmdInCurrent()# Q3 w- R+ x( F- h& P1 |
return4 t; [3 {# V0 m$ L; o( U
#IfWinActive
$ f+ }" p1 ^: ~- h$ r$ H; C8 o, \ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 k# ^8 O, Q" X7 q# H1 z
; Note: expecting to be run when the active window is Explorer.
0 ^, n5 w+ p s) A$ I ;
# x/ ~4 S7 e. n0 A4 B& M1 A7 B OpenCmdInCurrent()
2 P% j, ~) p$ o/ X {
q& o, I3 \$ ]9 |8 Y- o1 A' C ; This is required to get the full path of the file from the address bar
* q2 Q# ^: N6 }0 C3 G; r& o WinGetText, full_path, A
3 f1 E0 \# S, P2 v ; Split on newline (`n)
- o4 k4 k4 t- D/ K% l7 W0 j- H StringSplit, word_array, full_path, `n6 Q2 d/ b4 T5 D% p/ }, S/ s
; Take the first element from the array% p: R9 A/ H5 [# ^0 }6 r+ ?( M6 c
full_path = %word_array1%. c& q+ n- {# J2 D2 m3 g/ l
; strip to bare address: R6 z0 ^/ S( B5 M
full_path := RegExReplace(full_path, “地址: “, “”). S9 w4 a) R& ^2 B: ]3 c( c3 z
; Just in case – remove all carriage returns (`r)
8 P% d% _1 w2 B7 H StringReplace, full_path, full_path, `r, , all
; V/ E% \8 P! o; H, _: p1 C IfInString full_path, \3 h: x$ j- f0 X4 s5 C$ l
{! O! L1 T! l K; B
Run, cmd /K cd /D “%full_path%”
+ o3 {) k ]* v }" p9 C7 T: u5 X( ?+ M3 P. [
else
; M1 c0 K* m- i7 w$ Y7 j {
2 h: N) b0 S, G7 j Run, cmd /K cd /D “C:\ ”8 [" H9 g, P" K) Y+ e2 u
}
. R0 q" E5 k2 V* y& H n }
M# l" X1 q- K' p 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。3 ?& @& F: I: o+ e9 i
这段小代码肯能有两个你需要修改的地方+ q/ I" \* h* h4 H: \+ w+ T7 A/ u
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键8 u7 y9 e- w5 f6 l
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “" r3 H& D! [" ^; @# r) }9 j+ a
|