此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
6 L4 k) k3 E5 P" ?, j3 y. E8 k 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。' l" m. P: U; ~7 h5 f( ^
方式一:
" w1 l* d! y8 N! |# D) E) o7 n 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,3 ^* s! {: E+ ?* u/ D( ~0 ^2 ~
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 _- b6 R# t+ F3 s7 i HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 u! n9 |3 t# {! d8 G( V1 y; P
方式二:
" |1 h7 d3 _9 @! F1 ^- w$ N* |9 W! z6 @6 h 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:' N& X. g7 a( d
SetTitleMatchMode RegEx
$ @& p" F" c* V! ? return( \. K3 ]" P* {; S. z
; Stuff to do when Windows Explorer is open
0 f3 F$ ~; E# a( h ;: M' N5 h8 F- x' K# L
#IfWinActive ahk_class ExploreWClass|CabinetWClass
3 @$ {, R5 u2 g+ z/ H ; open ‘cmd’ in the current directory' R7 h; N* s; `+ o' _2 G
;
7 }( m J% i2 H. v. I #c::8 t/ O) F* D6 l' e& |- |. Z/ E
OpenCmdInCurrent()/ [3 L/ l/ I) a+ W# X( j6 i
return
: U+ l+ ]6 c: x- p4 ~" t4 @ #IfWinActive# t2 u! m" \# E3 @
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 C( b# g9 v+ a3 |9 b: S ; Note: expecting to be run when the active window is Explorer.+ t1 L! p2 c4 Q
;) U& ]3 B, K; I& d
OpenCmdInCurrent()9 G; r r2 [6 b* Q4 l( t w
{
$ f3 o) R% ?5 l0 S$ M4 } ; This is required to get the full path of the file from the address bar- x$ F8 z$ b1 d! X
WinGetText, full_path, A' v! i% }& C2 L9 h$ t5 v% G
; Split on newline (`n)
- A" P8 |6 k1 F StringSplit, word_array, full_path, `n- [2 i: h% B+ c
; Take the first element from the array2 z5 F8 }+ D, i* K" s4 x3 }
full_path = %word_array1%, d3 a. M/ d) D$ A9 g2 D: U
; strip to bare address; U5 E% r7 ?8 R. L: k1 D
full_path := RegExReplace(full_path, “地址: “, “”)% [$ x8 o' ]6 _
; Just in case – remove all carriage returns (`r)
' L& Z9 v, ?! z* n: K. f StringReplace, full_path, full_path, `r, , all
$ s. M7 n \( G* D* p* t3 k3 \ IfInString full_path, \
+ A$ R3 O6 q7 _) h {1 T3 j: q) ~' z
Run, cmd /K cd /D “%full_path%”
) C$ k7 d; |/ N+ M3 M }
4 J, i: \7 s. I) F( X! J else; T) W* f) N' w2 n8 y
{- L U% K- f R6 B& d" B, v
Run, cmd /K cd /D “C:\ ”6 Q8 @. {" K* o! U6 j7 o! S
}
/ z3 i0 d1 b+ T9 I$ r( {1 Y }
+ `5 p- P3 z6 z- X, j1 I4 E 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
7 l5 V V) s1 i3 n3 ~4 S" Z, c. J ? 这段小代码肯能有两个你需要修改的地方7 Z2 X6 F% w+ Y
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 D" Z6 d- a& j5 ]; u* ^ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “4 H- ~- k' s6 c' H/ f* ? D
|