此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
# o: y* n2 ~3 h' _: y1 r, b 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。0 N2 m$ W* P7 G$ R0 @+ W
方式一:
[" O! I& u; K) {0 B' b 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 E5 U: B2 K: I l+ I) b+ b 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: Y; d. o/ y/ l
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
, P# A. {* F! T; {/ H 方式二:
% S+ C: s1 u0 m" k. Q 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 U; m7 `. k1 o! q& H \1 R! @3 |' c
SetTitleMatchMode RegEx# B+ }2 n V, n+ ?! N
return
" _: a8 @0 W/ ~ ; Stuff to do when Windows Explorer is open
, ]4 i- w& B* K4 r( ~5 i* { ;# U) U: C B7 o. A7 B
#IfWinActive ahk_class ExploreWClass|CabinetWClass# b! U5 o' ^2 k, A/ c0 I5 a
; open ‘cmd’ in the current directory4 Y( t! b$ s! s; B( c* ^: W$ H/ q
;
$ R! O- p {3 I X" E3 O #c::) r+ s1 H4 G3 i
OpenCmdInCurrent()
' m4 R4 w5 S, C# @ return" `5 X1 k% C! [: L* m# g
#IfWinActive
9 Z1 g7 B& a0 F* ?- X" r ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' G8 r9 j2 E* I4 l% W ; Note: expecting to be run when the active window is Explorer.# Z: o6 |* w: a% o9 l
;
* N, H) k, U7 t {$ D OpenCmdInCurrent()% I( b2 n& b9 W) W `8 R. q
{; p1 g* ?+ O" w0 _5 W7 ]
; This is required to get the full path of the file from the address bar
4 Q) e4 w: U2 C: \3 t WinGetText, full_path, A! c4 t9 W6 \+ ^) _. o
; Split on newline (`n): D. c: U6 d; X3 U7 U
StringSplit, word_array, full_path, `n0 M3 H3 g1 V8 \
; Take the first element from the array
% X% _& e1 x4 R- Y% ?. G full_path = %word_array1%
( l- T7 H7 w/ i* Y ; strip to bare address" ?5 t2 i9 ?6 c1 x( ^2 ~
full_path := RegExReplace(full_path, “地址: “, “”)
. R: r, R1 c% u; Y6 }9 ~! X% Y ; Just in case – remove all carriage returns (`r)8 K" T. F% @2 k
StringReplace, full_path, full_path, `r, , all$ Z8 j) t, k5 X1 l* r
IfInString full_path, \
' w6 v. ~0 O) X/ S1 Z; M {
. h2 `' f* A4 o2 ]" ~" n' ^ Run, cmd /K cd /D “%full_path%”) u6 @2 j3 o5 H. ~2 x9 b* n( U$ J8 @
}. @0 L; G# T c* s
else% L/ o" B2 {' s% D
{
1 o% U; [ C3 ~! p1 ? Run, cmd /K cd /D “C:\ ”
& g8 u* A: Q/ D" d }" c% {1 I. B2 I$ X( K8 }% s2 F$ N
}% f! R5 n. }) g8 \5 ]9 O3 o9 ?
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。5 @, @) F. `1 R ~/ m8 t
这段小代码肯能有两个你需要修改的地方% P) { I) Q2 g
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
" G* e! s8 x, t- w 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 |* E- i8 f1 j |