此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) n/ B& g$ K. |' w0 C' A+ a0 W1 t
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 G0 ]& t8 g* t& Y 方式一:4 J* v. x8 x- m4 V) Z& e
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- Z* G- |; E- Q: K& V 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和, V; |/ H% V2 A
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。' w/ h, B3 u0 D' L' E, u3 S
方式二:3 ]" }$ k! r0 i! F1 ?* P
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# v2 n7 Y, T6 p# y% c2 U* a SetTitleMatchMode RegEx, A0 g1 k: \: R+ B. }
return
2 M* Q8 t) O6 u0 z7 V0 ` ; Stuff to do when Windows Explorer is open
v+ b$ E4 [# Y$ ] ;2 k2 Q7 ^2 o: X4 z; t4 C' D* u: d, K. a, h
#IfWinActive ahk_class ExploreWClass|CabinetWClass$ ^/ ]8 b0 _- ?3 v4 K3 v- J+ }* K
; open ‘cmd’ in the current directory" b, M% w+ v0 ^: P
;, {* i# J7 m g) u- z' ?( U4 {4 C( B
#c::
: _! |, k( g, U; y- e4 @0 G4 @* \ OpenCmdInCurrent()
6 f1 r9 c( o9 T6 W+ v return1 r# l5 I+ C- A: n, y
#IfWinActive
- q& ?0 D& b; m- J ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# Y& d" @% W% I% }+ _+ K
; Note: expecting to be run when the active window is Explorer.! t3 k: O1 M- k- r
;- [+ l. Q* l2 w& m8 N& T+ q
OpenCmdInCurrent()
) B. u6 {2 `6 ?& e" K {5 }) k- Z( W) M% V0 f7 i
; This is required to get the full path of the file from the address bar
1 _; U& Q1 F- W- q) E WinGetText, full_path, A$ G8 m9 A9 j+ Q0 F j1 w
; Split on newline (`n)
8 M, i2 c8 k/ R StringSplit, word_array, full_path, `n, ~2 j' r) Z) U/ f+ w
; Take the first element from the array' A% t" ?' K! G, p3 ?% T* H; y
full_path = %word_array1%% X( {1 Z1 e; U2 ]& F* c
; strip to bare address1 c- b, Z/ c3 r$ R K& T# g
full_path := RegExReplace(full_path, “地址: “, “”)3 t0 L [: c4 `. {; Z
; Just in case – remove all carriage returns (`r)% Q- ^: ~6 ^0 _
StringReplace, full_path, full_path, `r, , all
7 l% C0 p ?: ]9 P( {+ Z0 Q IfInString full_path, \
0 y; L9 O! t, \9 h. e' O {3 W/ a2 b2 f3 M/ e" _0 z8 s
Run, cmd /K cd /D “%full_path%”
1 j' V4 S8 p% E9 e% j, \( ^1 l }; `5 |9 F4 G5 |6 n
else& P N1 T& f4 v
{
7 ?& L/ E. F; @ Run, cmd /K cd /D “C:\ ”9 O3 \' k, c. N
}! l8 d( O8 Z; i6 U6 m% r5 h: _
}
* S5 Q8 Q$ `" e Z j4 ] 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
( U- U' A0 E' g 这段小代码肯能有两个你需要修改的地方
: I- V$ T" x1 `8 I5 n( E 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; {: }: t# q2 E& z5 }
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, [! G& Q0 l/ i# b6 R
|