此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
9 m8 l% V( G2 Y" E0 Z 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。; ~0 _1 m$ G* d2 O
方式一:& @* K, E; Q* I& x5 c! a
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,6 G3 p8 K! H i* h4 `' c
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
: H9 v% s( [& t* K+ }/ I; Q2 @ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。 H) z! D& d$ N8 E% z2 ]0 j5 x
方式二:) U P6 a, ^# j: j- |$ A
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
% e# b6 m$ X) a* L# s/ z/ D1 Q; d SetTitleMatchMode RegEx
: j- g; w: b" M! g2 k return" N p# V, N& ], s- n: W! ?9 B
; Stuff to do when Windows Explorer is open
3 `& B5 d! S4 P9 g# F ;
& v/ h' c. E$ y3 J" K #IfWinActive ahk_class ExploreWClass|CabinetWClass3 }, F Q) v6 C ?- x6 L
; open ‘cmd’ in the current directory
+ }: x% d: R8 ?+ \) k# ~ ;: m" H/ _/ y- Y
#c::
; n1 N1 R/ E, `6 R OpenCmdInCurrent()
, N+ \* |" V. ]$ K3 t z2 F% S8 o return
& D6 V- n3 ?& i #IfWinActive
# C; y+ F8 ?# V ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 I3 v% X0 V$ L ; Note: expecting to be run when the active window is Explorer.
: o6 \6 F. P2 s A3 c7 r4 d ;$ |% m2 e) u5 \7 \, ?! D/ H, l
OpenCmdInCurrent()! w) V! L( n9 C# R7 h2 I( S# `3 }
{$ v3 Q2 t9 A( w; V2 J
; This is required to get the full path of the file from the address bar
- n* w* A& E# S7 x# J) k WinGetText, full_path, A
/ d% {1 g* F) ]2 L8 V# g ; Split on newline (`n)$ f* Q# k. [4 k3 L
StringSplit, word_array, full_path, `n& e: g; f$ y& ~4 Y/ z
; Take the first element from the array
- v" U1 ~/ `; z* n! Y% x+ X* p full_path = %word_array1%
! b: R2 s* K$ A8 \" S/ { ; strip to bare address
& H# x9 _5 |. s ^ J full_path := RegExReplace(full_path, “地址: “, “”)7 E2 y, W6 V o* B5 g0 b t
; Just in case – remove all carriage returns (`r)
8 h" w$ Y I: L/ w% A StringReplace, full_path, full_path, `r, , all
+ O6 E i" ?( ` [ IfInString full_path, \
; V5 {" p9 C# G$ v) J: m8 t1 F, C v v/ D {
' g/ l2 v+ l$ { r5 h2 F+ \ Run, cmd /K cd /D “%full_path%”( D1 q: Z5 F& |, x
}
4 E' d6 Q6 d& j/ S else
4 ? i0 B C0 {/ D2 n {
4 ^4 i( g2 v6 v- T Run, cmd /K cd /D “C:\ ”
- I Z7 N7 r& L2 c v3 N2 s* p }% S4 J4 C* x; h- f" [, y
}
" G0 x2 G. a0 P! c. t 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" v8 q6 r9 s# ]1 N' `
这段小代码肯能有两个你需要修改的地方
' }( Y( b7 B6 P& h 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键6 A, M0 v2 E5 ?$ U% ]
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; n# {+ p7 p [
|