此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。0 H) k$ B8 i, i/ V) F! Y* H" \
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ O! z) W- o+ S% M5 Q: r$ H2 k 方式一:0 e* e+ X3 V6 a, a1 Z
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,3 J* y/ J' R, e
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 ^$ t9 U" f5 h0 t+ A3 p6 _ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。( y/ _- x+ H( E
方式二:7 z: f' {/ G# ~& t
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
0 t7 }0 B' W! Y3 y% w0 H SetTitleMatchMode RegEx
3 v3 V! ?7 n5 k, R1 { return
9 O: Q/ x- j4 T( W ; Stuff to do when Windows Explorer is open0 i0 ~. d3 j; `) T$ w
; C& R; @* `7 @6 p/ V
#IfWinActive ahk_class ExploreWClass|CabinetWClass
( t+ J# {5 R, s: T1 o m ; open ‘cmd’ in the current directory A4 n- x: ?. a, h4 T: F
;. P* I; d# g! J, v N* t4 U
#c::
]( H' O& @. D0 y OpenCmdInCurrent()# w; V5 J; t- g! a/ P% o+ D ^
return" j+ z2 J' D0 Q% C* y
#IfWinActive
) a4 I7 V! @3 M3 u ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( ~) z4 `' |$ |* k: p ; Note: expecting to be run when the active window is Explorer.+ o) r6 s( H, R' L5 f: {: z
;% p9 L2 ?/ M' M" n
OpenCmdInCurrent()" Q2 X' Q0 m* v& _
{% [# D' t+ _- j1 ]
; This is required to get the full path of the file from the address bar s! j: ] \/ x& j2 q' A% W
WinGetText, full_path, A6 {0 D b+ H' @6 `7 C+ d
; Split on newline (`n)
' Q' v- W: _3 H StringSplit, word_array, full_path, `n4 ?) l$ B) ?/ W% |( M! o- {6 I
; Take the first element from the array% W ]# T2 ^0 m
full_path = %word_array1%
+ v5 c( I6 j: J2 L9 s1 U5 X ; strip to bare address
6 t2 U# o7 \& y& t full_path := RegExReplace(full_path, “地址: “, “”), ^. X& W; e0 e1 s4 |
; Just in case – remove all carriage returns (`r)% [7 o4 I) _# A; [. l: T6 B
StringReplace, full_path, full_path, `r, , all
\+ `( V& g6 ]6 |7 B6 K" u IfInString full_path, \# F4 u f& R/ z0 z2 \
{0 C/ h& K+ ]( f6 z
Run, cmd /K cd /D “%full_path%”4 z0 R3 O. V5 u' m3 x6 O
}
1 T2 b+ p1 x! s else
! {! r& g7 r8 ?" s5 s' f {
5 {. m6 Q; @0 a2 s8 V/ S3 D Run, cmd /K cd /D “C:\ ”" Q0 a* C! `& L" u; a( j8 u
}
% G& T' A" K; S) ? }( V+ ~5 j/ N% H6 P$ b1 s/ d* ~
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
8 q4 z X- h( G; J' F+ @ k8 f9 L 这段小代码肯能有两个你需要修改的地方3 A! S0 s, s4 }* {
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ G) s! s, p9 e4 N$ \) l ]
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “0 f: n! z: Q1 g
|