此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
N! k2 j" i& `" O8 A4 x- N9 Y1 |0 D 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
( t z. A7 o, ~- x% ] 方式一:
( P: p: e6 d. r; u 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,2 z8 A" i7 p. k& p: [2 c
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和5 i, _/ e: q8 J7 J: ]3 |) z
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 t/ g/ h4 f: y4 c, A: V
方式二:, U9 N1 P- g" [
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- N) }% D+ i+ ?) J1 x4 k/ ~9 J SetTitleMatchMode RegEx
. g' L9 |6 w1 w- {0 W return( w% {7 c2 U/ w
; Stuff to do when Windows Explorer is open6 {9 f! v. a% o4 g; w1 C/ F
;
) {$ N( E% z' ]6 n5 H #IfWinActive ahk_class ExploreWClass|CabinetWClass/ H% {0 ~$ s& Z% t: E$ S
; open ‘cmd’ in the current directory) h2 V4 L- z; O {9 J" [
;
- H, I0 G+ J7 ^* |: ^, s4 m' o #c::
, O( G" P& _/ u8 m; I OpenCmdInCurrent()
- X4 l0 D8 k# P+ w8 Q% K" Y$ ~ return
0 b/ U9 M8 l) i, y% G7 w4 F #IfWinActive
( G2 D% e& u7 X" Q+ | ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) I9 _/ t" r) @, m q T: D5 F
; Note: expecting to be run when the active window is Explorer.2 R% ]* V h3 f: j4 t
;
% y( c7 W3 P; }. i OpenCmdInCurrent()
+ Z* w& \% X: H- N {' m& p) u# ~ }# H2 }; U3 Z
; This is required to get the full path of the file from the address bar
* `7 m, Y- }2 m WinGetText, full_path, A3 N5 x. o r" z+ u2 Q: r% N
; Split on newline (`n)
- ^% Z5 [% f% K6 t StringSplit, word_array, full_path, `n
7 u0 \# U( e! g ^5 J ; Take the first element from the array
2 V* a1 K |& N9 f" w, ? full_path = %word_array1%7 s3 \$ |8 R) i
; strip to bare address; K9 m- h) U9 [# O4 Z* D% B3 j
full_path := RegExReplace(full_path, “地址: “, “”)4 I& Q; a$ G- j+ H2 W
; Just in case – remove all carriage returns (`r)
- \ x; l4 i g StringReplace, full_path, full_path, `r, , all
2 Z0 k: }7 q$ Y( Q8 p# U& a8 F IfInString full_path, \
: s( X+ z m8 Z4 S! ^8 U7 k! w- @ {/ T3 l$ i! H, j$ H6 X0 j9 }
Run, cmd /K cd /D “%full_path%”' W0 @0 b% ^ x8 z9 y
}; j* _0 r& M' k$ K' Y; u9 T
else n6 I6 I" a7 j3 Z2 z( b1 ~6 w
{6 ?8 ^( G9 Z D) x8 f
Run, cmd /K cd /D “C:\ ”
' h- R: @% c9 W& Z% C9 U }- N$ c7 q# u$ l# I, p
}
& E3 Y N) |* y- s- G 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
/ v4 R$ N( k: Z( Q- O! y% v 这段小代码肯能有两个你需要修改的地方
) F3 d. U6 W: c+ L7 M 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
! H/ Z( W( Q- T6 H+ d 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “ F/ _0 m4 f6 W
|