此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
) I, S3 U, r6 u 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
. H4 h2 T7 O" ^! I; f 方式一:4 E" {7 V% V8 C: {( M0 H
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,' N; j7 u5 A/ @1 C T+ h
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和# I; t$ w B1 C7 l( {
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! B" \4 {, ~% K2 ]4 m8 k* U2 i8 t 方式二:$ B( q( P }. e5 g0 q0 N
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
, K3 c* D* W5 c! L3 n+ r( \, I SetTitleMatchMode RegEx
- S$ l) r1 a/ {% J5 R return: A# T3 \, A' b) t" Y3 J" Y. J
; Stuff to do when Windows Explorer is open
4 }& ]6 @# ^4 S- m& { ;7 }0 \# \* v/ {7 a
#IfWinActive ahk_class ExploreWClass|CabinetWClass( s9 K. f" _ B3 v8 ~- b
; open ‘cmd’ in the current directory) W% Z O: B$ E/ ?7 m) ^
;
% ^; ~1 x6 m# i+ Y9 N' R& x #c::( M4 q) j a1 V* X; F, _( P) G
OpenCmdInCurrent()$ q( V$ D1 b# V6 h" u2 s# I; t0 B
return5 E; G2 J4 L3 T& s8 p
#IfWinActive! y0 p. R1 b. {# I: v4 W2 h
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
" S9 }8 w2 w3 ~4 R& R ; Note: expecting to be run when the active window is Explorer.
* V* F7 Y8 G% N t' b0 E- f ;
* f& ]# T( W1 @$ O OpenCmdInCurrent()
N, s s* O* D9 w& r; k {
" o' Y! c. h q, g5 E ; This is required to get the full path of the file from the address bar# O2 e6 \1 C+ s4 Q
WinGetText, full_path, A
. R# u0 w, t }$ E" I( S ; Split on newline (`n)
4 {- k9 a5 L0 h2 C3 S+ n StringSplit, word_array, full_path, `n
; O9 F5 B7 ], C$ J" p: b2 y; x- Z ; Take the first element from the array0 }& @% D+ G# I5 z; t
full_path = %word_array1%6 `' D7 l$ t4 ^
; strip to bare address
. L) n6 w0 k& P9 m! c: h o f" Z full_path := RegExReplace(full_path, “地址: “, “”)
$ ~' p1 u, c6 x4 G ; Just in case – remove all carriage returns (`r): y! W* p) @# ^: H9 U
StringReplace, full_path, full_path, `r, , all7 D, `0 R2 V+ l a# u$ s6 [
IfInString full_path, \' S0 T* t8 a' H2 x" w( H0 z
{8 D: j) w9 E. x; a. _
Run, cmd /K cd /D “%full_path%”5 H/ Z7 c3 t' j& G
}
4 z) i; }+ _! X+ X else
8 H$ P+ j8 F5 H( {1 }) [ {* o+ w* g5 g a$ H9 F6 S
Run, cmd /K cd /D “C:\ ”
4 q: m5 Z9 D( Z; T }& E! J9 Z& e9 ~3 W, j
}* m6 D; ]1 {# j* \% ]
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* O9 d( C( a1 x$ E- |0 E 这段小代码肯能有两个你需要修改的地方3 S1 i0 k8 K' x- t% r
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 @- L% ]& g+ x7 [" ^+ l
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, c- f7 Y. z( d, r$ K
|