此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。3 t1 Z7 M* y! ]& w
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* }% F7 |/ U% W# C 方式一:
! A8 O- U9 F* |! ]+ G5 d 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
1 }$ {5 z$ t) |* I& P0 c; ? 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; K7 i1 }9 y% k4 z HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
1 J D ] E9 y5 w 方式二:6 F( Z. C f* x! r, s( l* |
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: `/ |7 o. W5 P1 w& n1 L
SetTitleMatchMode RegEx4 l1 H8 l4 o6 @
return
4 u P8 L) L9 Y2 U! [" A ; Stuff to do when Windows Explorer is open" e: u) ]: c8 E# F1 [: u5 ]+ c: S" t
;
; K7 Z) o- Z2 i! H #IfWinActive ahk_class ExploreWClass|CabinetWClass
2 E& J+ O3 A B4 I1 z: {5 y0 T, g7 t ; open ‘cmd’ in the current directory1 R" y. Z$ k: ~8 u
;
4 D* w6 Q' a5 B \8 V. R0 {* D# q #c::9 `1 m4 J U6 A. c: `3 A
OpenCmdInCurrent(); }# k4 T1 }6 K
return* U: ~- @1 F2 B% p- L
#IfWinActive$ v4 @+ b* c0 Q' V& i" r
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 u) C* U9 F9 K% j
; Note: expecting to be run when the active window is Explorer.
- c/ G/ P8 x4 q( k( ` ;* X* Y2 \, p3 l* L0 y3 x7 h
OpenCmdInCurrent()
0 N; C8 f2 U: J, X) |+ Z& L {9 s* l, [+ |' }. o6 _
; This is required to get the full path of the file from the address bar+ C: m0 ^; g6 D9 z7 h. s0 s
WinGetText, full_path, A5 l7 X1 c, g8 t
; Split on newline (`n)
* R" Y5 W8 E" d1 r0 `3 D; v. l StringSplit, word_array, full_path, `n
7 f' {% }# Q# x% \. d& m ; Take the first element from the array
$ X/ X$ u1 e; R- a4 Q7 n1 o full_path = %word_array1%+ x& ^/ \$ d2 V- @
; strip to bare address
9 L. Z& n: n* H1 G7 f {0 q" _( ^) ~0 y J full_path := RegExReplace(full_path, “地址: “, “”)+ y: o: m. f% L$ ?" g2 J
; Just in case – remove all carriage returns (`r)
8 U$ ~, p) Y4 p6 ~) ?' l. O5 ]: s StringReplace, full_path, full_path, `r, , all0 |. e2 h0 N0 D( a% G4 y" k' Y) y
IfInString full_path, \
; v/ C- c6 I! \3 h {8 ^9 N. f. W( \0 N8 H |
Run, cmd /K cd /D “%full_path%”! R& ^# y1 a9 W% l7 S m H
}
9 y! I1 M/ A2 E" j2 d else7 M1 w' g9 W( Z {& q& k+ V C( N+ G
{$ d! ?( I# S7 p: R5 V6 P
Run, cmd /K cd /D “C:\ ”4 S1 ]/ O8 j, ]" V' U
}
& j2 m! l; y! r }6 t0 ^' W& N1 }" L1 J3 x+ K
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。3 a2 Z9 ~/ `5 T9 g5 `# v
这段小代码肯能有两个你需要修改的地方
% ]! n- `1 l8 @# G0 l% q 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键" e& \: D6 Y- I# \7 s) f. g
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ P H' |$ l( Z+ N- z5 s; i |