此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; W; t. K- D$ b+ a; q 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: p# G/ B& Q0 H6 v3 e1 a6 k9 M- h
方式一:
6 P6 ~) g! G' d+ ~& _3 m 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,7 m' `" Q2 B; h& T( `
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和5 C% w6 \; x/ U# d8 t$ M, Z/ s0 t% p
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
0 `- B D9 J o 方式二: H7 j1 Q. y0 S# Q
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
. M q% J. r6 U& w" O# W1 P; @9 D SetTitleMatchMode RegEx
4 N, M4 j8 t! J# S9 @ return
0 h! V! u8 `7 Z ^ ; Stuff to do when Windows Explorer is open
; w# X% t$ B- c5 r2 ^) X ;( i: T! _" S, Z* d) ]8 m
#IfWinActive ahk_class ExploreWClass|CabinetWClass
) n# D; `, V" `8 s7 h( n ; open ‘cmd’ in the current directory
. ^; ~. O! v& v3 i: V! K ;
' G" j% B% _! | #c::. ]" {, _+ `+ ?5 S f
OpenCmdInCurrent()
% ^. S2 k: P( [/ ? k- J return
, E* ]) [7 f* X6 T- R #IfWinActive0 o: g- z; o- Z n
; Opens the command shell ‘cmd’ in the directory browsed in Explorer., M/ R# o8 a6 ?' i2 }( _
; Note: expecting to be run when the active window is Explorer.2 x) o0 U9 b, a
;
3 L" b7 n6 t0 o: w. v OpenCmdInCurrent()
7 h9 ]+ G* \& k% S: W0 _. a {% X5 @& i& j5 I4 e: T. P0 [
; This is required to get the full path of the file from the address bar: t( F; O- ], { v1 S; z
WinGetText, full_path, A8 W, h3 ?% w9 T6 B, {& t- {3 M
; Split on newline (`n)
! S7 A: z1 X6 O StringSplit, word_array, full_path, `n7 ?* b) u8 N) _- z3 |
; Take the first element from the array$ s& Y0 u( l& Q7 w* ^/ M
full_path = %word_array1%7 R* U" _2 Z4 \/ R5 R
; strip to bare address
' h* m! q/ z& R8 ^: d# z- O full_path := RegExReplace(full_path, “地址: “, “”)9 d9 ^% u- G% k- U" [
; Just in case – remove all carriage returns (`r)
, Y, X; E- N) D9 f StringReplace, full_path, full_path, `r, , all
( D6 ?( F6 V* K' M IfInString full_path, \; _; I& S0 O' q6 l7 G6 s
{* {3 w' q. b* A: d8 i7 U
Run, cmd /K cd /D “%full_path%”: k5 e' y' y& m% g- u
}4 a* ]8 j ?+ B& h, } @
else
$ L! d* T; B4 b# v* i; ?! Z {& @1 y. C5 c; i( G$ @
Run, cmd /K cd /D “C:\ ”- w# o. h! o9 c6 D7 s' D
}7 y7 e7 v/ J! ]- L: w3 P
}5 d5 c" L) C) @ w& M5 q
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
( J7 \: {2 L2 F, H1 | 这段小代码肯能有两个你需要修改的地方1 R4 o+ T- o! n7 X B
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键 r$ j0 w& ]6 d# O1 u
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! E0 K5 P2 n8 Y |