此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。5 _: E Z, ^$ N/ y( x% z1 B1 i* u
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! r) | r! J0 D8 ?9 l/ a, l' N
方式一:5 y# A/ [4 {& U
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
2 a! r0 @( D" Y; q% X9 V, a 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和; z$ R0 R& z- _1 K* `! i
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
9 R$ A ^: e# r, l0 k9 |/ w 方式二:4 y3 H7 r' L$ C; J
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( r* W3 B9 R6 q0 T" s SetTitleMatchMode RegEx
+ n; D7 a6 j6 d2 q; X& R h ? return5 @+ I1 E/ k$ {1 p5 M% q
; Stuff to do when Windows Explorer is open+ P8 Y6 P# M' E, T4 `
;
$ S. M& \( @& r #IfWinActive ahk_class ExploreWClass|CabinetWClass8 l9 C: l1 e* i: m7 K" G
; open ‘cmd’ in the current directory
: [7 }% v. x* o# k, P ;
; F* f! e& B* z' N( Z+ p #c::7 V$ T1 H/ n! ~4 l
OpenCmdInCurrent()
1 u1 h6 p2 k3 f* z0 _* e return0 t5 W8 @" j+ g/ N# c3 u
#IfWinActive) \/ }/ ^% B! F: G# c
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) u8 B1 N' B r- e. ~ ; Note: expecting to be run when the active window is Explorer.
, g; ], O/ a9 U7 r3 z1 f ;
# s+ o" z7 g* j3 Y OpenCmdInCurrent()8 W! P& Y6 \7 |- r& A7 P
{
/ |# e7 \& ~5 a, s. u8 p; } ; This is required to get the full path of the file from the address bar
6 x# J3 f6 p( i* m, s WinGetText, full_path, A& E% q) u! F3 k/ `( _: G
; Split on newline (`n)$ `- K7 V) M. g; |; y* P
StringSplit, word_array, full_path, `n
' ~$ ^/ z9 r" y: R/ J! p4 U2 Q ; Take the first element from the array
0 E$ A3 O% h r( ?# K0 C$ B' N full_path = %word_array1%, w. ?# A* K. N/ d# w1 {
; strip to bare address
+ r5 l- a* ?9 |! M% n* n3 u full_path := RegExReplace(full_path, “地址: “, “”)
& i7 d& L" j& h5 H! `" e ; Just in case – remove all carriage returns (`r)
7 S0 Y" k; z, i) x StringReplace, full_path, full_path, `r, , all9 s: b$ g! `4 T; m
IfInString full_path, \8 U: V9 d, @' q
{) L- V, a6 R3 `0 L
Run, cmd /K cd /D “%full_path%”
" U3 l! m/ H% f, x( K' B }- F/ t, q }. i) @$ q5 l$ F+ M
else3 l/ G' e7 X9 E. W6 K
{
" }, `8 p5 @. ^8 e8 Q' M Run, cmd /K cd /D “C:\ ”
! ~! W% p) l0 i+ e F. x1 g0 g } ^7 c7 y/ _7 ^0 g# `5 Z E
}- {; ~: ~& k- E! g+ l
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。4 f* y l" k9 T3 H7 {# u: Q
这段小代码肯能有两个你需要修改的地方
7 d/ ^5 J' a, E 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( r9 w q2 L- h
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
6 q0 ~" [# [ @. X |