此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; B! ]/ M9 ^1 p6 e
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 D5 O+ f3 e" w* W3 K 方式一:0 |4 M0 V3 ]$ N4 n# _& y/ s" S# _
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,; [- ]1 c4 r' |) c% h
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) c. B9 L& a: G$ C) @3 d! k z
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
% e$ V& F t. q1 s 方式二:* w1 ^, ]8 G4 x( {# {
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
% ^. {5 ^9 A4 Z5 e& P; }4 E* g SetTitleMatchMode RegEx
7 H, @. ]& H, _. i# Q, p V; ^ return
$ v% _3 e8 k2 Q8 v ; Stuff to do when Windows Explorer is open
% }8 q) ]# d; I( n2 l+ z ;, {1 T. }7 Y+ [/ m4 j
#IfWinActive ahk_class ExploreWClass|CabinetWClass
5 Q- R: _6 n" n/ | ; open ‘cmd’ in the current directory
; X9 A; ]* N. y3 t ;4 T# B/ B% [1 t7 F9 ~
#c::* i7 A$ p5 M6 }7 z) }: c& L b
OpenCmdInCurrent()
/ j0 w# ~ b# L! v6 d- v. a return
3 { [1 z- S3 v! h F4 t #IfWinActive2 @8 O* u; x; L) ^& v
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# K# f( W; h4 O! p" }3 o# ] R
; Note: expecting to be run when the active window is Explorer.
/ R4 P* ]. b9 v3 u6 d$ I, r" ]& `3 m ;8 V6 X; f+ R+ f$ N
OpenCmdInCurrent()4 S7 D; G. w& ^9 d
{6 Q) w+ r, _- M' g& h0 _
; This is required to get the full path of the file from the address bar9 V* a- z3 k" F! J9 l+ p
WinGetText, full_path, A
4 L6 ^2 u' g' @! ]( \ v6 v ; Split on newline (`n)
m: d& n, v( \. u1 L StringSplit, word_array, full_path, `n
8 Q5 X1 T( F! S, {2 e z ; Take the first element from the array
/ r4 R- M; f9 m3 _ full_path = %word_array1%1 h3 n( R# H+ k) M2 j
; strip to bare address. v! x4 h# `. c* u6 y: C8 l" F9 n0 z
full_path := RegExReplace(full_path, “地址: “, “”)) q9 K$ ?$ h! i; |; O: T: n
; Just in case – remove all carriage returns (`r)
1 n5 ^. V& L) R1 x' N StringReplace, full_path, full_path, `r, , all8 I _0 Y0 i' w
IfInString full_path, \2 F& u$ L+ r% ]
{
7 w8 c0 Z! w! X Run, cmd /K cd /D “%full_path%”
1 }" ^" _6 V! g7 } Z }$ r7 K2 e; @7 k/ L z
else
3 v/ P5 L% }. ~8 I$ J& L; i {# r/ F! h& |( n b
Run, cmd /K cd /D “C:\ ”
7 N3 x! V- p3 j+ X) b- {7 n$ T }
X/ q; }+ Z+ [" P+ [( V }: @! m7 \3 D' u- K" L1 ]
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! m, G$ z) j+ L
这段小代码肯能有两个你需要修改的地方 {' S# I5 h- W2 y
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) F3 J" J. w! v9 Y% ]. r( a 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ M$ z3 u( }: Q( r' O- t3 q' G
|