此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) \& z' j' ?/ V% g3 M# b
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
k0 ^2 _& s3 |/ Z r3 N0 n8 Z" M 方式一:- W! y' S! w2 P7 p
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
9 L9 X# U( ~* i4 ^ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和0 j4 g2 I- y6 v( p* w( C: \
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 S& M7 R* G- q' v1 [/ u* u+ Y
方式二:
1 \. j5 O8 M) D 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:0 A7 H" u p# z3 x, S, L
SetTitleMatchMode RegEx: Y5 S1 V) u" o' I! x$ L& p* z! i
return
. |2 D7 |: _7 y: F# O g$ V ; Stuff to do when Windows Explorer is open: e6 @; P, }6 h r& D5 [
;
3 f0 Q7 y l- M- [ H #IfWinActive ahk_class ExploreWClass|CabinetWClass
; M" S }8 b0 O# I' V ; open ‘cmd’ in the current directory
* V( Y/ I8 x) E U1 i @. t4 d ;
+ `5 x* q! o2 H4 | #c::
! k3 A' o' h. T+ e/ a/ O7 l OpenCmdInCurrent()3 S; \$ [. q9 _. ~+ ~; U
return
( D3 [! ]% \2 d; o #IfWinActive
' G# W( o. }! ^- k ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.* ?6 Z1 T& q" Y- Y# t# F/ s3 @
; Note: expecting to be run when the active window is Explorer.! q4 `; B/ D7 B0 l# q& a
;8 ]) e& \1 N0 C6 T
OpenCmdInCurrent(). _1 M5 k' ~, s; W/ R1 c& T
{' \9 ~1 D4 K9 X" |+ \5 h1 N, T
; This is required to get the full path of the file from the address bar
' n# W4 G, b/ J. D0 L7 u WinGetText, full_path, A
$ M5 D. ^9 P! y* x! h) T ; Split on newline (`n)% O, w/ S9 ~. [
StringSplit, word_array, full_path, `n
& G; k+ O3 U0 n0 B/ k7 l9 r ; Take the first element from the array
$ ~( n& f1 ^9 y6 K( g2 Y% N full_path = %word_array1%
/ f0 [( U2 _) G) Q/ s ; strip to bare address1 X6 `& y% I( s0 \
full_path := RegExReplace(full_path, “地址: “, “”)2 k5 D# \7 j5 O+ ] |9 \. a
; Just in case – remove all carriage returns (`r)
+ M( w7 g( [2 s9 J H( }* F" ` K% n! S StringReplace, full_path, full_path, `r, , all
% {! c# l( O( q+ M IfInString full_path, \/ F% d2 ?' k% `& ?; L/ O# C* z. p
{9 {" v9 W3 n8 f3 I
Run, cmd /K cd /D “%full_path%”; z) s% d, S' b" E, Q
}
6 Q9 G, r/ X5 a else
/ I/ [1 ^. o% C% s. L. v" E) \ {
( k, }6 e- X% e* l$ K; ~# P4 H Run, cmd /K cd /D “C:\ ”0 ^& G: m$ Z3 {# P1 `0 _
}2 N8 S( m5 i) k7 n
}
# i9 e0 }9 r+ ?' ^4 s9 p6 h 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ ?+ ^5 S! N3 s6 J6 T+ ]+ u* k 这段小代码肯能有两个你需要修改的地方
7 e, h( V( y4 ^! C) R8 P1 e 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键1 p1 l5 x$ d# r% J
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
0 s3 P4 X# J: M2 C- v. N |