此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ U. k* [) g, ?; T+ N, Q4 n
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
( |: l6 w4 J8 { ]$ V) a' O5 J 方式一:
% P) g5 l* |. {6 E 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,% M' \: q0 I3 I4 V
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
& G% u1 g7 C6 o) q8 z HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 T7 T4 z8 x% U4 U 方式二:
1 @$ @! ^6 n$ o* c l# t0 V 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:- `) c4 \! \: D1 A( f7 Z2 ?! e e
SetTitleMatchMode RegEx z4 t0 q3 Q7 i- H1 F
return7 @+ `9 z1 [$ _; B- \
; Stuff to do when Windows Explorer is open$ o2 B0 S3 q% g
;
) ?$ {! M4 \+ O2 d #IfWinActive ahk_class ExploreWClass|CabinetWClass) W1 i- c- }# _. {7 ?' N
; open ‘cmd’ in the current directory
( F3 |/ N9 L' n, ] p5 c! e4 a ;( X$ A7 g% `. K5 W' }9 z4 G4 h
#c::3 p5 z2 F J Y$ o) K4 Z
OpenCmdInCurrent()
/ ]0 h1 d+ q9 p return8 @9 I% ]' k5 c# v8 R6 s
#IfWinActive8 B0 S) z4 E# n2 e
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.$ f" A' Q7 M4 A/ x( ]/ E$ I
; Note: expecting to be run when the active window is Explorer.
) b9 {6 l. a8 F5 u4 A7 a8 Z8 G# p6 O ;
" k- d& }2 H; C) g/ y: \* c0 M OpenCmdInCurrent()
/ I0 X [- g1 Z( J) m% ~4 x% y% _7 c {/ S5 ]" m# l+ g y: ]: C
; This is required to get the full path of the file from the address bar& d( K K( Y: S/ X
WinGetText, full_path, A
$ U* v$ i2 D& D% C4 N ; Split on newline (`n)% f2 Q# S( c7 ]: ~$ P
StringSplit, word_array, full_path, `n2 }- M6 }6 r n# O5 N
; Take the first element from the array
) `2 }* ~+ H; o q/ K- M+ n full_path = %word_array1%
2 P# }5 r' B4 K0 b: E5 ] ; strip to bare address: u* r9 t" P9 P; @/ Z9 s: K
full_path := RegExReplace(full_path, “地址: “, “”)" `# V6 v: J$ {- I
; Just in case – remove all carriage returns (`r)7 B- ^0 w* t' W" d: T0 }8 `
StringReplace, full_path, full_path, `r, , all7 T& h7 {. m" F* R* E8 x: ^
IfInString full_path, \
5 f& K& [- y. M2 S, m$ u: } {" F4 t. L! ~. `/ E' E+ s
Run, cmd /K cd /D “%full_path%”
5 I: R* n# W1 Z4 }; n/ Y }$ I+ j- u* g, G) y
else7 j @) N3 Z% @+ I
{
2 [: H5 t+ Q4 O0 E) n4 A t Run, cmd /K cd /D “C:\ ”( J* P' o/ r/ A! ?7 Z9 O
}
/ k& V5 Y9 F5 z5 e1 c* T& W }
# u0 o) x2 S- D/ H! H2 h0 g7 }0 X 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
/ |% L1 g! K" C( {8 y4 I, d8 z 这段小代码肯能有两个你需要修改的地方
9 ?& R# u6 I! @- N% g 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 B7 v" t. ]; r" y' Q. X& F 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ T1 y" E3 m# S, Y* o _2 d- T
|