此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# O# b& k4 K! n7 J+ @0 ]6 B ~. n- r
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
6 s5 L6 n0 X3 m3 C* {9 Y! f& o 方式一:
' X# m* p4 w: l, J3 A' ^/ w 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
4 T |. G3 { f$ y( f7 z1 }& s. s 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和, [9 H% ?5 }2 k6 ~' G" y) s; K
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
7 ~/ s% }$ z( ^0 q/ N 方式二:
& G- X. u: ?& Z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, Q- e0 C" v. @5 S. n4 o$ a
SetTitleMatchMode RegEx
5 j. t5 L. g& |+ q9 N$ g return0 m. x/ O# @* g5 g2 k* e
; Stuff to do when Windows Explorer is open0 Q! U0 ]' O& P( x" U$ _" A
;
% G3 `& E* r: _/ R3 W7 e3 u# I$ r #IfWinActive ahk_class ExploreWClass|CabinetWClass
. G6 f5 d% d( Q( n4 p$ L, K1 n) I ; open ‘cmd’ in the current directory
$ H7 p: Y4 ^: n( t! N& K/ k ;
1 M" L& Z! Q$ Z- y3 \! k& M( g #c::
: y! n% m. n& f1 ^# W OpenCmdInCurrent()
9 a& i* i0 n6 }% G return
; }# R* M, A8 {; }3 O #IfWinActive
: n I3 }7 c9 G ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.! x R, V% J- N5 C1 J
; Note: expecting to be run when the active window is Explorer.% c! Z6 E Q3 A/ B
;
: [8 B4 h! b# Q. T d6 c5 f OpenCmdInCurrent()" P* j1 Y6 ]+ O* Q& m; q6 {
{- S+ ]7 T! p6 L
; This is required to get the full path of the file from the address bar( Z0 F4 x& Q5 f C2 T8 e
WinGetText, full_path, A$ H% w! ?1 o4 W
; Split on newline (`n)
6 u ^) _. J7 S* [/ U StringSplit, word_array, full_path, `n1 J% }* e( p! O
; Take the first element from the array
, g2 R2 q6 J$ n' \+ q9 S full_path = %word_array1%- f: ]( ^; f7 h3 f6 A8 `7 c
; strip to bare address6 n$ D P5 M8 P$ J' U
full_path := RegExReplace(full_path, “地址: “, “”), B9 H9 D7 ~) v: F
; Just in case – remove all carriage returns (`r)
) q. D/ n8 x: p0 H! z StringReplace, full_path, full_path, `r, , all5 r% a, `0 x# Y$ q- A {6 \
IfInString full_path, \
, @% b) Q- a' K3 q$ t) w {# r, s5 ?2 C; d' Y
Run, cmd /K cd /D “%full_path%”
' U9 I( l: h: T7 v' Q1 N3 P* j5 a }
( @/ M+ b s4 h$ {+ U0 g. P7 u else! K8 ?& Z$ [2 T+ J
{ Y2 u# F- }5 L% J3 ?
Run, cmd /K cd /D “C:\ ”
1 B3 P" w* ?1 S; v }6 G4 z; J8 q) }7 j6 T2 w+ B5 S4 H( K
}
( X$ G& m% y7 U7 x 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
8 C2 U7 X9 ]. l 这段小代码肯能有两个你需要修改的地方
% a5 M; |, r+ ?- J 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
; \6 n6 p# r" N s. P+ u. B 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" F; ^' H, ?$ f! I! I7 d |