此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
! M$ G) T. X/ P$ K8 W, Z 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 h% s6 Y; q/ j" j( T6 E/ H4 C) g( ` 方式一:
% e7 m4 f" _5 Y 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,2 w2 c8 m2 ~) s! p0 H- G
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和4 o# r& D8 m: K, C% D3 |
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
0 x# k: o" W7 G% Q# G 方式二:- ?9 q' _, a) U+ l$ T0 n& l
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
, Y" y# v5 W7 b) p8 O SetTitleMatchMode RegEx* v+ w' b9 ~( y d: H
return
/ |! T2 V2 O; }) J: s9 _ H ; Stuff to do when Windows Explorer is open7 K2 |: s/ ~0 x7 d: V E
; R- r" |8 ~) V
#IfWinActive ahk_class ExploreWClass|CabinetWClass
O/ c, _! b, {* U j ; open ‘cmd’ in the current directory
- o) |2 h8 L" a* P ;
+ o M0 I# r" d9 z5 b #c::/ i( C6 W- Z" V8 E4 {1 q" X* D
OpenCmdInCurrent()
9 g/ X7 g, |4 N% p, I, v return0 v/ E `: T' S+ S* A( ?3 K9 i9 ~' p# W
#IfWinActive6 {% |$ g4 _6 o2 c0 r: z' h
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 F! t; @$ }+ F% O- G ; Note: expecting to be run when the active window is Explorer.$ m7 t) n# \7 x0 D2 Q E- I! X
;& \1 D. R; e( ? I+ S$ S
OpenCmdInCurrent(). E, U Z& K1 w# k% ]* G }
{
$ f, f0 D5 k& ]/ a, v6 Q4 G ; This is required to get the full path of the file from the address bar0 ]3 B' g7 F0 ~6 F
WinGetText, full_path, A
4 K0 p- H0 w! N4 o0 a7 I ; Split on newline (`n) Z0 y1 u3 O M8 `' Y" G! X
StringSplit, word_array, full_path, `n/ u2 {: k( ^/ F) I. d3 K/ h
; Take the first element from the array
4 V1 I2 h# V' a6 \6 a/ n full_path = %word_array1%
. ?) n: l, m/ u0 t ; strip to bare address5 Z5 {1 F2 z* }
full_path := RegExReplace(full_path, “地址: “, “”)8 _; b8 ]$ j M% }3 L. }
; Just in case – remove all carriage returns (`r)# g1 o* Z+ l3 W5 [
StringReplace, full_path, full_path, `r, , all- }2 h* o+ f( W1 c; @/ ]! ^
IfInString full_path, \
. ?& T* \( Q6 V. F {
0 p/ b, A" V/ q Run, cmd /K cd /D “%full_path%”4 n( E5 k, p1 N% n( W
}
; Z/ y4 F3 {/ J else
9 G% j: f- N9 c$ C {
# Y& c# ~3 ]6 P1 | Run, cmd /K cd /D “C:\ ”
: `/ g' Z6 b% L# B4 g, _3 | }
9 d; `# C6 Y& K( G }% u) Y8 T* O/ M" Q- A3 [# H
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
w0 O2 v* x0 d$ h8 m 这段小代码肯能有两个你需要修改的地方+ C4 o! U2 t- ]" M
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
& H+ u) U7 b+ F$ C4 Z m9 s 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, E. o9 W9 o6 `/ b3 A: h
|