此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。& |+ m, \; ?, t. C& {8 x. n
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
7 }5 y" u5 ]2 e( S) K 方式一:
4 e( Z8 H3 n% I5 x( e5 J Z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
$ {+ V5 c0 Q8 c6 r9 q 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
/ o! b: m9 m$ `4 A HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 X& F% Z2 p- k- L" S9 h' X: b 方式二:6 V# v5 g8 k8 S! O' y
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 P6 O* d- w/ J4 T8 x
SetTitleMatchMode RegEx3 ?! F1 @& g. N t2 e! _
return5 b! C N2 A6 E5 a) @/ j7 S, h( a
; Stuff to do when Windows Explorer is open5 [. U. I O# V6 `; Y! M6 O
;
, A+ S& Y+ e" E1 b$ B* D+ g #IfWinActive ahk_class ExploreWClass|CabinetWClass3 z; p3 r5 r% p$ x# C
; open ‘cmd’ in the current directory
( Z: G- S4 t& A: Z. s# i8 D$ k; ?! y ;* b K4 r" \3 N
#c::2 S% p! `* j7 ?/ v
OpenCmdInCurrent()" E/ P: i2 e3 S! t$ G
return" ~/ ]" [, M0 n3 S5 W) ~$ V( f
#IfWinActive* ]8 M+ T0 G1 [$ N m
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
$ T& _: b3 w* i# D) B ; Note: expecting to be run when the active window is Explorer.- _2 S' T( g" G& e8 Q
;
6 u4 c9 _5 t" \' O- e& k! O" M OpenCmdInCurrent()
# v/ N: j: f j, A0 a; U. M {) H9 [! m/ f J, ~9 R
; This is required to get the full path of the file from the address bar) o+ P% u% F. m) [- T
WinGetText, full_path, A5 k7 t5 S3 n7 ^5 P; e. u
; Split on newline (`n)
; ^+ I( S. L1 g; a" T+ _& E StringSplit, word_array, full_path, `n) b& ]; I% V' |: x$ a- e/ N
; Take the first element from the array
# Q$ f+ ~7 n3 i" ^2 y- [7 M5 E full_path = %word_array1%
5 h6 R4 P9 K( A: ` ; strip to bare address
% g) l: z* R4 U/ z0 m full_path := RegExReplace(full_path, “地址: “, “”)
( o: F' _/ m* K ; Just in case – remove all carriage returns (`r)% @" }0 {7 u2 X
StringReplace, full_path, full_path, `r, , all7 _( Q. {+ T$ B7 L
IfInString full_path, \ Y( _8 i, f$ U; z6 M$ S
{
% b$ S$ e5 V$ Q9 M3 w% M Run, cmd /K cd /D “%full_path%”) g# {# g$ j- X0 d b
}2 R' T+ U1 E8 q9 q4 U1 [; R0 H
else5 X7 L7 M% R& {# x* F7 S7 M
{
J& f, N+ D7 P2 r Run, cmd /K cd /D “C:\ ”) f* z& G' l& m
}: o9 d! }& f2 N8 C
}
: A! B- Z% o1 n/ l7 D& u, d( x 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。; N5 ]3 |& @, ]) @
这段小代码肯能有两个你需要修改的地方
% I- t' Y/ h1 F$ ]" u& t0 R' l 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
6 [) [0 u. K1 A; }# _ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “* a3 J1 b- R% B. X+ U+ k1 x
|