此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 S- h. N+ _, _0 U o8 {
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 D- @5 n1 l3 \+ }0 @, h. @
方式一:; N* x2 O% o7 J" X# P# M+ P; f
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 j2 L4 [$ I3 N3 }; \9 A7 W
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 g: ^$ K8 m! r- U# O3 L8 Z3 p* i
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" ]' H6 o! c" Z& a1 t 方式二:
+ Z+ E& |; b! }/ i( O( p t 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* A5 N s/ ^( w. G* E; w SetTitleMatchMode RegEx" E4 }+ }7 l. T/ U% p) U, r
return
6 O$ V4 ?5 V9 k7 p7 f5 d ; Stuff to do when Windows Explorer is open8 r! ~/ T& t3 S; a. y
;5 G( y% n( O5 t$ b
#IfWinActive ahk_class ExploreWClass|CabinetWClass
1 |7 U) b$ r& G5 o ; open ‘cmd’ in the current directory
5 h# V* b% u' O" G! c ;# K$ K% b8 F! M0 i& l; {
#c::2 c0 R+ [ s& [; \' ]
OpenCmdInCurrent()
' ^1 C# I8 R# d# b% ] l3 n5 b% w" l return
# V1 j7 g3 U: \ #IfWinActive
) z1 {3 g& u' u+ E* B ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' U0 b# n# g1 h; Y; S- b ; Note: expecting to be run when the active window is Explorer.
+ w* |, `" X0 K, F8 a6 j7 U ;
; B% `) q( ^! s1 o1 I OpenCmdInCurrent()
4 G W' x3 j7 V3 s' f2 y4 [( ?, { {
& H2 H+ D- h/ @/ k+ q ; This is required to get the full path of the file from the address bar
) Y$ Y! K. _' Z; z: `$ r; ]6 K WinGetText, full_path, A, Q& x! `5 u+ a& ~2 e+ H3 V- W- j) N
; Split on newline (`n)
: X6 d5 `" r4 h8 T5 J StringSplit, word_array, full_path, `n
- t$ j, W3 @* c- b t ; Take the first element from the array
$ i8 V* S# Y; Z: Z8 R full_path = %word_array1%. r* q9 [& N/ x/ R( _) }5 F3 d
; strip to bare address B! g3 V: n; y* N& K# L5 q
full_path := RegExReplace(full_path, “地址: “, “”)
' T' F, U; b6 l/ y }- P4 r ; Just in case – remove all carriage returns (`r)' y3 n7 N# [6 o8 ~
StringReplace, full_path, full_path, `r, , all( k X+ m/ O# B- \( S" B* v- c
IfInString full_path, \
% _; k2 T& E( e/ Z) m {9 J- L9 I* a0 `! ^
Run, cmd /K cd /D “%full_path%”0 l3 T/ L( x" b4 K" K) {7 y- m( I
}& D2 H! g0 d' }6 M M4 i
else
$ Z1 o, l! F4 M# O: W {
9 y: L/ S, b0 `9 z' @1 g Run, cmd /K cd /D “C:\ ”
7 z& Z/ Q+ o( x U }! ]9 S Q! j+ p C. F* Z
}
. W" A' x f! x) }3 n0 q. V 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 ^2 ?. L! t6 } d' } 这段小代码肯能有两个你需要修改的地方4 X {7 G; V d
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( Q+ y8 p8 k3 j e2 o8 Q. f- m) d1 Q$ U: I 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
5 e. Q1 f6 r% H$ \, n2 S |