此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
# @7 P- ~6 N, `! h* |: h0 g 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ o1 a$ @9 d( j! ^ P" F' ^ 方式一:
7 Q7 q* I; @" _5 u6 c/ y 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
8 O+ {2 [% T5 O. ~& D+ S& }1 k+ i 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和% A \3 N2 i3 r: c. V3 O( K
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。) _* I9 M4 s7 t
方式二:
6 Q5 e& ]6 c2 A- n3 O- \ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# v6 ]; C5 M) Z8 [0 `& H SetTitleMatchMode RegEx1 {! X4 ?5 V8 {7 J" Y3 N
return! M9 x/ }. g% ~% g( W' l+ L. k+ b
; Stuff to do when Windows Explorer is open" H7 ?- N* w4 l; k7 q0 L# H0 f
;' n: w7 a/ G# D
#IfWinActive ahk_class ExploreWClass|CabinetWClass5 J6 W8 N) L$ b( r: c1 v: A
; open ‘cmd’ in the current directory
8 v- a1 M7 u% ~+ [% z) m( V ;
4 x3 D5 ]1 {, `4 n #c::
& v# i: a1 p* L& _: d4 Y OpenCmdInCurrent()/ m4 E4 O$ A) ^* u
return: f) x( e2 _- l
#IfWinActive q2 ~5 g: w! A
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 c# [6 K6 g2 Q- b
; Note: expecting to be run when the active window is Explorer.: g, O3 \# G% ?; C
;" M, H4 v W; R3 K9 W
OpenCmdInCurrent()
: A- L( I1 i5 [ {! t8 J+ y/ W l6 j {
; This is required to get the full path of the file from the address bar
- e) f' i0 C" m! L WinGetText, full_path, A
: `2 K& {0 R/ L' X8 _ ; Split on newline (`n)
7 z0 @! Y3 I* |" Y0 E! p StringSplit, word_array, full_path, `n) K! g, L; `) x) l j- A0 _
; Take the first element from the array
: L; i2 S0 P! F! [2 l full_path = %word_array1%. t3 W- r h n/ k5 r
; strip to bare address
% V& X" `" h4 s. A" ]5 N* R" ?3 O full_path := RegExReplace(full_path, “地址: “, “”)1 f5 Q) }) l9 h3 f2 q1 J' F
; Just in case – remove all carriage returns (`r). a6 n# P1 w9 O
StringReplace, full_path, full_path, `r, , all' ~- ^; F9 d& d
IfInString full_path, \
- L+ a0 P# M& I, h. A; ]! F {& b/ I$ s) `) o- y, {4 m
Run, cmd /K cd /D “%full_path%”# e$ X% W7 M" s8 X: d; @
}
' E( F/ f. `, n7 O1 t else) i8 F+ g7 J' A
{! }& ]( V6 M6 c5 u9 }1 k# p! `4 Z
Run, cmd /K cd /D “C:\ ”1 H6 q# V h, h/ l
}7 b7 a* d. A K6 M" K% f& h& g4 N
}. j$ w2 {. C2 W7 p3 ^
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
1 }/ {8 V1 y7 ~ 这段小代码肯能有两个你需要修改的地方
: H# Z$ s! b# p% F5 b4 h: A 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
4 W: J+ d+ q. k9 f: ^ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “4 B% n" [% Q$ ?6 w4 Q9 {, f
|