此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
) L2 e$ S( [, B" q 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
/ j+ H' h0 X" q+ L1 a 方式一:. P" G8 h, T) y8 q1 F1 ?2 O+ n
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
H6 e3 H! @. d5 G# e 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和9 N9 b& f# M0 s9 z9 x. p, M+ E
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ f+ e4 j9 a: ^7 I P- I( m 方式二:
; u9 @7 i" u- q, F0 K7 K' B 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: b3 @, n3 w( o+ ?3 E8 h3 }- R
SetTitleMatchMode RegEx2 }1 ?4 ^; p& R
return0 }& k6 t0 ?0 T
; Stuff to do when Windows Explorer is open
/ C5 |' m2 d, l# ^& J" i3 A6 F ;% D) V) M. L5 h& h
#IfWinActive ahk_class ExploreWClass|CabinetWClass
P) r( Y8 Q$ ^5 c) ?6 X0 w7 _ ; open ‘cmd’ in the current directory& q( q. y5 Q5 R6 q$ E
;: @) Y9 ~' ?$ @
#c::, C# e; G) N9 W0 k" M
OpenCmdInCurrent()% d$ F& N& V! [' h2 y4 Q
return4 I/ y6 S) P* u4 ^5 z
#IfWinActive {" @' ~& L* \; K6 J- s# d
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
* ~( {9 p4 O$ K; D& p& K ; Note: expecting to be run when the active window is Explorer.1 s8 r7 n8 H" G
;
" C% Y4 N! g; v4 v# u$ k. S OpenCmdInCurrent()# ?2 d' J' t# k3 C- {8 I/ g
{* C& x% u( F9 a9 c
; This is required to get the full path of the file from the address bar
+ X/ |: g( J" L WinGetText, full_path, A
7 V7 ~1 c% v2 L8 Y7 k& k ; Split on newline (`n)& q) t* ~* U0 A" S" C" B
StringSplit, word_array, full_path, `n9 Z, g9 | e+ D+ c( c
; Take the first element from the array2 O6 P5 O4 s( M
full_path = %word_array1%3 G# {- }6 c- k3 o" U/ p% {% n
; strip to bare address0 Z) z; E; o; p$ ~" v
full_path := RegExReplace(full_path, “地址: “, “”)4 I- ^7 Y& ?- {# F# O% m
; Just in case – remove all carriage returns (`r)
; p; {/ k* v6 h* _+ z: ]) o StringReplace, full_path, full_path, `r, , all
) z6 D" X) `) r9 y) Z- _ IfInString full_path, \
6 n' O5 _2 C8 U0 y {3 c) O9 ]7 A; y' c
Run, cmd /K cd /D “%full_path%”6 U4 h1 y( O( t, {
}
4 Q A: R$ r% S& x else/ }& Y1 y6 e7 `$ \
{* [! Z1 `+ p0 s. Q: G/ ^
Run, cmd /K cd /D “C:\ ”% I: Y+ u9 ^5 \7 ~( N& Q
}
4 C |* |6 O& C9 i: V }# b& @! t U5 K. T: `3 b: S
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。4 @& B) \0 L/ ?' I
这段小代码肯能有两个你需要修改的地方
2 _: n% y' k8 D 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键# d m3 w7 E& ~& V* ?8 k
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 F/ N- `+ ?% [, Y) V! v( |- ` |