此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。3 B2 |% q4 h- k3 D6 y* F
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 }# k* M) y. `' U, ~+ J 方式一:8 \0 a) ?( v1 }4 v I, z8 I) t8 W
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
/ B8 z; j1 U2 b0 I d; l 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和( @- G5 \ s1 Y p" e# g7 \. W* j
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
1 x# D. g6 J8 W5 H- c 方式二:
* q- e" c) ]3 ~/ S: J1 I/ i 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 Z T$ E9 N' P SetTitleMatchMode RegEx
0 c: J8 v( W7 O! X$ M return
G9 X( U8 b2 Z' O4 b" o+ W$ X: C ; Stuff to do when Windows Explorer is open
1 j" r6 U0 B9 o4 A; E% X/ r ;" c' F. B$ M, @( ]5 F
#IfWinActive ahk_class ExploreWClass|CabinetWClass/ ]6 J/ c% {+ N% _7 p& J/ s% A+ W
; open ‘cmd’ in the current directory
R+ e' G; w. C q ;' t0 C( ^ }2 k( G( t
#c::
5 ~# S3 E4 w3 [4 R _, T OpenCmdInCurrent()
9 s/ R# x1 m2 k* a1 E0 G7 J return
# h7 J* F, @( I4 Q% Y2 D* l #IfWinActive- y' o. J# |, T" T
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
8 \# c+ k$ }& [ ; Note: expecting to be run when the active window is Explorer.+ H+ `5 J' S$ E
;
$ A8 y; E3 J ]- l& z8 {# [4 K OpenCmdInCurrent(); J4 x4 E8 b7 [+ V
{
3 k! a; `; ~% G( V% U" s ; This is required to get the full path of the file from the address bar
8 V) V* C) }# R8 U WinGetText, full_path, A: n G ~7 t, s3 @2 ^* k1 l
; Split on newline (`n) G O- d+ e$ v5 G5 u1 k7 t% K
StringSplit, word_array, full_path, `n6 v; \( D/ l; B ~# B
; Take the first element from the array2 ?9 r5 O5 D7 ^3 S$ ?
full_path = %word_array1%
( e+ \" p0 C* h5 ^ ; strip to bare address( ^& z* T! B. ~* H8 D9 k% n
full_path := RegExReplace(full_path, “地址: “, “”)
; N( a, o$ M& ~4 U$ G ; Just in case – remove all carriage returns (`r)
, P' z' g0 k! W2 \7 b6 @ StringReplace, full_path, full_path, `r, , all
2 ~0 e1 [2 C, q0 M IfInString full_path, \$ A o& f% E" |' D. T1 i7 U
{& M# S w3 X$ N' C
Run, cmd /K cd /D “%full_path%”
5 O9 L: P/ X* H G q: ?9 b }
' ?4 U$ M! K' d% e: I else; D' x/ \2 d+ L( t
{
K5 U, w* h$ Q" \4 n3 M: u Run, cmd /K cd /D “C:\ ”4 X7 w+ a1 u8 o: J, W4 Y5 a. A y& O2 e
}
& `9 c- C; e! z5 X4 A8 I3 Q- i4 K }! D. K* f5 ?+ k2 c2 u2 o2 [# q" Y5 d
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 k; C# h/ f# @ 这段小代码肯能有两个你需要修改的地方+ b/ D' T# M k7 { y+ f
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
: h3 r7 k5 p9 @. p9 t4 b/ x" Z 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; ~, i% ^6 h0 |" E" V+ ]6 P$ E) J
|