此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 b0 d$ R# y* H6 U 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 P2 F% k) r2 o
方式一:6 u' q3 H1 @3 t! s4 P) Q9 e; c4 f* n N
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,2 u; \* O/ m e7 G5 c
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, F& K5 h& k5 I HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 T5 q7 r: I$ D* ]. m
方式二:
. u6 O+ b! `' W7 D0 { 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:' O& N$ V8 r, H f/ z
SetTitleMatchMode RegEx/ M9 |6 Y7 t+ T7 P. Z
return
# @. J" w8 x# A6 _( s ; Stuff to do when Windows Explorer is open/ p7 {' b" K- F& d- f; b
;
% o5 `. p# r% o$ l #IfWinActive ahk_class ExploreWClass|CabinetWClass
( Y" y1 O+ @( o, t. d ; open ‘cmd’ in the current directory& M" o1 I3 J& M4 ~0 [
;
2 a8 Y# e) T+ s+ A0 E5 z #c::
7 ~8 S8 T$ @0 [9 A OpenCmdInCurrent()8 R) b% v& G4 ]8 A7 G
return
( @7 ~* Y9 }* a7 k: B4 D #IfWinActive- K2 |8 Z! E8 a) ?
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.6 K9 x# L0 x- H1 q$ a$ F( D
; Note: expecting to be run when the active window is Explorer.
- h6 a- m$ X& u0 ^; ?) Q+ R ;5 J$ {# o' W i8 P% t
OpenCmdInCurrent()
+ c. D+ y1 a1 B* W {: `, d* x- [- ^% r8 |
; This is required to get the full path of the file from the address bar8 ? P1 @5 ^* @1 p
WinGetText, full_path, A
7 d7 d* l% o/ R- ?3 W6 D ; Split on newline (`n)
/ a j0 i) Q/ x: Z, B! Q" n$ a StringSplit, word_array, full_path, `n( m- x/ ]6 Y# x) x. g( T
; Take the first element from the array" P* h, D$ W) V6 q: Q! W
full_path = %word_array1%
2 L- H4 p8 [" U ; strip to bare address
, i0 N* Z0 q1 F9 G full_path := RegExReplace(full_path, “地址: “, “”)
9 d; d, l+ `6 S" ^8 l: S, e ; Just in case – remove all carriage returns (`r)' k! ]0 P) q1 Z# V: e
StringReplace, full_path, full_path, `r, , all
3 f2 R, y( F* |# C9 |5 u$ x IfInString full_path, \ I1 E8 ^/ M) N1 Y* H* O m
{
8 Y6 c% u" H) i( O, ?& t P Run, cmd /K cd /D “%full_path%”/ r- y8 @4 K2 o1 E6 _& ^8 {, h
}" d/ o7 P! _4 f8 d, @" Z: w7 J3 O3 K
else4 Y5 B" G. @" o3 `! A. W, }% c
{! ^/ H. P% W5 W) x1 n
Run, cmd /K cd /D “C:\ ”3 ~& n+ c6 A K5 ~5 M
}
7 R# D4 L- p& J }
3 N& h" x4 a/ u! k/ A% t 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% L( e3 z F) k! h; |
这段小代码肯能有两个你需要修改的地方
& |" \2 Y: z$ k+ ^6 Z' R 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 Y6 k* P8 p# R1 w% v e
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: t0 O& X V- v! a3 ?
|