此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。$ w x+ E4 ]( W, Z4 ]2 I
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 Q4 Q- C* I8 f4 t
方式一:
) \) Y3 _% A1 m, ^3 C# O 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# _, Y# }4 @% D: O- c3 Y 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, Y; m$ F+ u% \3 g- | u. ~ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。% T, X: h+ N! S! f% A- R
方式二:
0 j5 r" J Y0 I$ B. C 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
0 i! y; ?$ _8 v SetTitleMatchMode RegEx
" g' \- K8 s+ \2 x+ h% Z+ [ return
) ~- t! F( k3 E; \' s) F ; Stuff to do when Windows Explorer is open
! Y. t5 P4 o8 `+ q% y ;
9 K- r+ I2 ]. c0 J2 Y/ S) s #IfWinActive ahk_class ExploreWClass|CabinetWClass
L+ s4 e4 f% }& j5 G# b8 e ; open ‘cmd’ in the current directory
( S7 x4 J2 U! a/ i9 n' \4 h$ t ;! w: u4 F/ N7 d, ?6 s
#c::
( P9 l( b) b7 p) L4 V OpenCmdInCurrent()
+ k5 K/ e, q, e- c% `. h6 `. A return* w8 ]( I, H0 O+ v% i
#IfWinActive' d) v- e" J& x& J+ w1 K
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# k- c- S C9 j# Q5 q
; Note: expecting to be run when the active window is Explorer.
. c: n J: e) u' Q8 _2 g ;
$ r- }5 L! h& J k7 U! z OpenCmdInCurrent()
' A# i! [4 n- L; {, |. i. f {6 f1 Z2 ~2 \6 _* Q
; This is required to get the full path of the file from the address bar: l3 s9 ~; {+ L! y; ~) Q0 ^
WinGetText, full_path, A
4 ~3 @: ~9 A8 t3 V0 Z3 Z* f ; Split on newline (`n)
: P% l( I$ K, m2 A) s5 z6 K9 k, [ StringSplit, word_array, full_path, `n; V2 v1 s% ^2 i Z+ m: n
; Take the first element from the array
0 J, C/ |5 {! [5 p* E2 v full_path = %word_array1%
8 A* _& v2 o- m& F ; strip to bare address" H7 G) U; P! M6 T8 E
full_path := RegExReplace(full_path, “地址: “, “”)
$ P7 A) h- C! d/ r* ?3 Z ; Just in case – remove all carriage returns (`r)8 e, \# r! Z0 B0 {! [+ N: `
StringReplace, full_path, full_path, `r, , all
" Q: E8 z' P% u# { IfInString full_path, \
8 U- L& y8 g3 ~. P F' h4 Z. O {! D! m7 C2 F9 B9 X" Q
Run, cmd /K cd /D “%full_path%”0 X7 A% _' Q2 w9 h. t8 \
}5 M- X. a$ j' D# ^6 V
else
8 T( r2 G+ N1 L# }$ Q {
/ g7 S9 z* {% z H9 P Run, cmd /K cd /D “C:\ ”
6 e' D! \- T$ P, J; a' N; _ }/ U! x5 o% v5 u1 J+ E: `
}1 a5 M5 I1 ~- }& \
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 Y* G; a. h" y
这段小代码肯能有两个你需要修改的地方* U' G2 o0 W9 V' D# ?! C
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 O k2 z8 @7 j& D! d
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! p# `: p7 ^+ D$ H. T. M: n% [4 E
|