此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
$ N3 z+ a" \% q/ z+ [ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 t1 \6 k5 n* i/ T
方式一:
U; c. t9 y: f 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,# t3 s% N; ~- X* ~
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" K( _( L& L6 k
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
7 e1 |* F, ~$ I0 [ g6 R' X6 F 方式二:- \; P2 P, x* M7 g5 |
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:1 W$ }' P6 h0 N z& o5 F. l/ R q1 Z
SetTitleMatchMode RegEx
0 n% D K! e' | return
& w3 r) g8 @. C1 Y# y# u, @0 s ; Stuff to do when Windows Explorer is open+ L0 I# y( m* f* ~, B' T E
;+ |& R5 _3 D' B% S
#IfWinActive ahk_class ExploreWClass|CabinetWClass
, Q7 q: ~) [9 } ; open ‘cmd’ in the current directory
+ @; t' D1 U* r" {& F% Q; h6 p ; s( v7 S' V: P4 n
#c::' q1 v8 @. p- J& H G7 O; f
OpenCmdInCurrent()
$ y) l$ C* ~, T return4 R* j+ E0 A t- ?$ P( u
#IfWinActive
. t* ?, ?8 P" Q$ ?3 c3 C! z# u8 U' p ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
6 ]1 Q3 K! q& _, O ; Note: expecting to be run when the active window is Explorer.
; V# T1 v _$ c* w8 ] ;
+ I3 p2 I3 r4 g4 w0 P: g OpenCmdInCurrent()
% n6 {6 S% _4 p0 @3 [ {( @( M! s Y* S9 U
; This is required to get the full path of the file from the address bar- S2 n7 n% _) Y5 V% _: S
WinGetText, full_path, A. \1 c9 K9 t( N2 N9 r
; Split on newline (`n)$ ]) Z7 Q; E' t2 B7 w
StringSplit, word_array, full_path, `n) K4 I0 f5 ^/ ?% H5 b
; Take the first element from the array% ]6 G- H b. L9 Z
full_path = %word_array1%: v p0 A' i5 [% Y
; strip to bare address9 t( z7 w1 t: m6 N) j, y( O
full_path := RegExReplace(full_path, “地址: “, “”)
9 _2 }" ^ v1 a' `' W6 y# f- | ; Just in case – remove all carriage returns (`r)7 R/ u/ a( [; y( K1 q3 c
StringReplace, full_path, full_path, `r, , all0 y2 F0 l) [) N
IfInString full_path, \
; i; b4 s8 D# O3 p4 L& H4 A* ? {
# Y+ K# v2 O7 `' F Run, cmd /K cd /D “%full_path%”
6 M7 o/ `2 x% D1 j+ W }& e9 D" O/ {. ^5 |1 |6 d; p4 j
else
" U3 y: Y& b2 G, ] {
7 b( A& `$ _7 ` Run, cmd /K cd /D “C:\ ”
" R2 O8 D! K& r" g }+ n6 E; s" ?& o( }; C+ _
}% |/ R% v: {! }9 K! b
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。$ {# s: o! R, D; `) y
这段小代码肯能有两个你需要修改的地方
3 ~( k* c+ I2 |+ l2 T 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 Z+ p5 O/ }- n0 l& A+ I
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “4 Z3 s( {6 e) `- M+ S1 q1 s, y% f
|