此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
# B2 o, g( ?% E: f* a6 H* Y 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
' X' T% ~; x- w! [5 C; V 方式一:1 a9 Y5 w5 A9 H* ?
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 ~* b1 \8 x6 Q9 p* H! A$ Y$ J- e' s
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和* N, r2 j- T- [
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
% ~ c4 B9 g$ A7 n/ s 方式二:" V6 `, o( b" J8 U
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" D7 j5 g; M8 X" z( j SetTitleMatchMode RegEx, x/ i$ C; G: n4 y
return
" E2 A3 h/ ]' O5 q ; Stuff to do when Windows Explorer is open
. O' U; E3 N# Z ;
+ B8 d3 }$ D. U8 U4 I #IfWinActive ahk_class ExploreWClass|CabinetWClass7 U, j5 ~5 o3 Y J) X |5 m
; open ‘cmd’ in the current directory8 P& x5 h. n/ E! t6 Z+ s3 X
;7 @" X4 V; ~3 g# m5 `' c
#c::5 E p4 ?1 \+ M2 C" {
OpenCmdInCurrent()! j+ S; t" g0 n- b' p
return
. R2 w+ U; O1 H; s9 c8 B$ J #IfWinActive
2 V" f% @# ^, s& C$ Y ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.1 j# K- a, s7 D+ S
; Note: expecting to be run when the active window is Explorer.+ s% R4 r5 [6 X# F$ l" R
;
3 A# Z4 w1 Z0 t+ Q2 x" \' v OpenCmdInCurrent()# J& @8 C7 H1 g4 z7 z0 M
{
) e8 {. V: @2 B! @( t7 m& E ; This is required to get the full path of the file from the address bar
4 g7 D# f) J& z9 p WinGetText, full_path, A
* V3 J& Q% \) D% M2 w \. y ; Split on newline (`n)7 a6 X5 x& v& [- Y8 |
StringSplit, word_array, full_path, `n/ o: ?' t5 q# B) _# H7 {6 k
; Take the first element from the array
4 D) J ~) w3 r6 W; S# o full_path = %word_array1%
) d, y* ^ c' u- U1 h; r ; strip to bare address
; [+ {/ E; ~7 d. I/ Q+ q full_path := RegExReplace(full_path, “地址: “, “”)
9 C" }9 W& B* y" W3 d- X6 A ; Just in case – remove all carriage returns (`r)5 a" m( B7 v: b% n5 \ j9 Q
StringReplace, full_path, full_path, `r, , all! l% ~2 o' m R
IfInString full_path, \
8 f9 n7 X& v& t! o {: l- X% |& p/ \
Run, cmd /K cd /D “%full_path%”
; n. W+ g; t# E4 Z- r7 H6 F9 L1 B5 w4 C }
4 e& O" Y# E! A$ r3 x else
$ h- c; G$ Y" f% S5 Y# V {
! ~" w/ |: F1 s& L% B4 \" R# g Run, cmd /K cd /D “C:\ ”
4 \$ L0 I7 W8 ^' c. ~; Z% u7 [. M }
7 r" J) v1 ?! M }
) k& ^! Y f4 R9 T( ]' N$ m 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。; m8 B# c- ?" y8 u# b! Z8 p( |! T
这段小代码肯能有两个你需要修改的地方) r1 _' V. O$ A6 r
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
4 J; P/ ^3 b" |- {" O; ]9 s 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “ X4 V. |2 K2 B* j' `! S& K; |
|