此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ P2 c4 [! }* |4 U 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 ^4 j% Y9 Y1 C
方式一:- m$ R6 a( E/ o0 B
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
/ a" h6 H4 [( S+ y 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" ~9 ~) ^" F$ W# f. M# F0 s HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 C, R) F% ~& ^1 Z' M
方式二:
P# c3 i2 U: A( o/ V/ t) f% N 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:% m) U1 ]2 j5 ?- D
SetTitleMatchMode RegEx: i! R6 f! H F" H8 f4 t* u9 W9 ^
return1 U- d, z6 i2 f
; Stuff to do when Windows Explorer is open
& L9 x/ [( m* X ; K8 v8 R& H, O9 f
#IfWinActive ahk_class ExploreWClass|CabinetWClass
0 K9 T/ H8 h& d! L+ G* l ; open ‘cmd’ in the current directory
7 H& r/ }) _9 F ;1 `; g, F+ D1 I& C( V
#c::% ~4 _$ G8 U0 i' S+ ^
OpenCmdInCurrent()- ]0 _( W4 i, ~+ @ a8 e! m
return) ^% N0 U% A) }# v/ a" l- x
#IfWinActive
h6 P. I E8 Y' }" Z ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
; G. o C3 C0 N ; Note: expecting to be run when the active window is Explorer.) C6 A' T* |/ d( W d' v0 I( z
;
% W1 t2 c: V0 W! X( L/ v: ? OpenCmdInCurrent(); U7 G$ j0 v: B. B! t- s
{ j" }/ p, k$ D$ I) i
; This is required to get the full path of the file from the address bar
4 l9 h# m ?! Z/ w; |) H' _$ a/ v: Q- E WinGetText, full_path, A6 q0 H5 y7 f' \
; Split on newline (`n)
- t% G, u g/ a) i, S0 N" P0 a StringSplit, word_array, full_path, `n
: ~' B( L3 N0 R: Q# w5 i | ; Take the first element from the array( o3 ~' N) V; Z! U2 c$ L* G
full_path = %word_array1%
6 x' N0 g3 g+ r ; strip to bare address% E& ~/ a9 W" y" E
full_path := RegExReplace(full_path, “地址: “, “”)
; d2 o$ X. v) Y& t ; Just in case – remove all carriage returns (`r): G9 K" @" s. E& U7 t0 ]
StringReplace, full_path, full_path, `r, , all
7 q* p! c6 n% K0 E5 M, @ IfInString full_path, \
' W/ ^0 K9 m" A- b! ]) E# U- p; u) { {
. B" L! g" {. v3 O Run, cmd /K cd /D “%full_path%”" o9 w4 Z. r( g
}2 m# ^, j6 x! F
else# k2 n. T1 r7 b& F5 _9 x- ]1 i1 ^
{0 t5 ]& m1 t" L0 g& w( X
Run, cmd /K cd /D “C:\ ”: w( ]" @% V* ?; J$ B t }
}
: j2 A; R2 x5 r+ _- @ }
7 @9 n, ~/ ^- C. d a" W* H0 |$ K 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
4 x) l; [0 _; `. u) K 这段小代码肯能有两个你需要修改的地方
5 U2 j% U1 X+ k2 @ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
! Y$ w7 B) b% W7 r- Y, n: r 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 P$ b2 k6 O% d j* R |