此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; p2 m% c P b 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
5 n9 d5 l. x3 j# d& @- O# F- n1 q 方式一:
" h' F& H9 d( |# O+ Z" i" p2 } 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
/ a# Y# \: j8 T% x; @ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和& [% @$ m& `: z5 @! F
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。! S* b2 @4 @6 O5 ^5 `- }- F' n
方式二:4 ~, x! M3 V, t# v8 Q' H* K
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:- p: E8 E6 A; w& F2 l7 J, ^
SetTitleMatchMode RegEx
% T0 Z9 p; H7 B O return0 U- }1 p3 e% N: P0 E4 \! T7 |0 U
; Stuff to do when Windows Explorer is open
0 K! I- N d8 c! [ ;
T/ z/ R% o5 C% b #IfWinActive ahk_class ExploreWClass|CabinetWClass
0 D. J. ^ ^6 Q3 F, j9 [ ; open ‘cmd’ in the current directory
( Q6 v- n f) W5 V ;
( E$ p% |9 N' P- a #c::' i |4 M' H4 r$ G$ \
OpenCmdInCurrent()
( b2 w- ?" s9 R# R7 y: Y* q) B return
6 G9 W) H1 m J: f #IfWinActive- L: U" j/ l6 h& p
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) ]* \" T1 g. Y8 q+ K/ [
; Note: expecting to be run when the active window is Explorer.( z0 F. H* w5 H+ `" Z
;
; T$ e L, M& n$ T$ C4 E OpenCmdInCurrent()& I4 W: l* }/ Q; T" |4 l1 C3 q/ z. B
{$ T$ V( E; t# p5 x0 |$ a9 {0 @
; This is required to get the full path of the file from the address bar$ S9 N- }; h2 I4 T
WinGetText, full_path, A8 _5 @& C# c* Z' X
; Split on newline (`n)
, x7 E; e0 l9 p4 O+ f: ?5 G3 V StringSplit, word_array, full_path, `n1 S c! k) X' t* T+ B
; Take the first element from the array" m% |6 E* i% P
full_path = %word_array1%
- {: Q4 T# w' M. Y8 z ; strip to bare address
: O- ?' Z8 G0 {% ] full_path := RegExReplace(full_path, “地址: “, “”)
* w: P- V, L" R, X" l' l( g ; Just in case – remove all carriage returns (`r)
& J# ~& u2 M2 k StringReplace, full_path, full_path, `r, , all
7 h; w3 T- f* q+ h# t$ @ IfInString full_path, \
1 O; k; H0 n& x; a/ h {1 ^1 K s1 S8 ~1 g
Run, cmd /K cd /D “%full_path%”1 |8 P$ a3 X7 g: o* ^
}
( z2 p5 D" D$ k8 E. T9 m else
9 r a) \, r x: f {
0 w% T2 s% v* u2 a Run, cmd /K cd /D “C:\ ”
9 F, R5 J, |& B6 } }- W6 `$ ~1 d V
}
4 C) I! P6 b" d& w! C# c 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
& @* s6 t+ I4 l+ g6 M! ^% h; a! r 这段小代码肯能有两个你需要修改的地方- x# w+ \# d+ K' {- L) ?2 ^
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
k9 [) `& O& Q+ ]7 p' Y$ M% @ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* \8 F6 [8 H6 h/ C4 w& G2 M |