此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
: O b$ j: h- k% y. Q 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
! U4 b5 R$ a. Z 方式一:) z9 x2 O, S% }' M: o% E
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
( [7 s' U$ R3 D( m+ c% K 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
' H' t9 v l6 x/ h5 b: V: ] HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 O7 s" p m, p) [6 |
方式二:% G1 m3 `2 F( f, P1 I2 F
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:0 T% |6 H6 h' d: M
SetTitleMatchMode RegEx& G/ ^$ A6 C( p* Z( i# [9 F; ~
return
) \ j5 U- }% f( [; g5 k ; Stuff to do when Windows Explorer is open
( A' x/ ^. \$ h4 W" N( F9 E ;
/ e$ \4 ]: Y- A. ~ #IfWinActive ahk_class ExploreWClass|CabinetWClass& w$ W! M2 f$ i! R. w. t
; open ‘cmd’ in the current directory
5 A; i- O |: ~2 y+ j2 i ;
3 x& Z: r) M* C. q. U! g2 I #c::
* L3 w$ k. q* c" m, L OpenCmdInCurrent()
5 {! y* w4 M0 H, P: I return
$ L, s% m; v" ^$ u #IfWinActive
* p% b$ ]8 k* h. d ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
, S% X% u! ~) K1 ^2 e ; Note: expecting to be run when the active window is Explorer.$ n C5 m1 Y4 U3 A3 g5 K
;
7 l" w+ E4 o* {9 _ OpenCmdInCurrent(); E9 V, i% p/ {: j
{
8 o6 ]' G9 T& @1 K3 @ ; This is required to get the full path of the file from the address bar
* o* _6 @( d3 z; d WinGetText, full_path, A
# v& j' _, {5 t1 j ; Split on newline (`n)* {; [3 L* m; c* ^( T) k
StringSplit, word_array, full_path, `n
# r7 f7 r( O- }, l ; Take the first element from the array
. s$ H* G9 a+ g: f8 ^ full_path = %word_array1%
- t2 {* X$ e) B ; strip to bare address# V; N1 D, C7 x
full_path := RegExReplace(full_path, “地址: “, “”)& F5 w4 s( l" T. V
; Just in case – remove all carriage returns (`r)
: o' |# O- s; s5 J. U1 l StringReplace, full_path, full_path, `r, , all, y2 ~2 |" X" F0 F
IfInString full_path, \, u$ Y$ m' i' c$ q7 h
{0 M O7 F8 x z% S! ^
Run, cmd /K cd /D “%full_path%”, K3 e% D6 p% a
}
5 @& A9 A5 m7 L& t else
0 F0 m9 I) j/ G6 f3 @ { x, l" O1 Z9 B/ Z9 K8 p1 T
Run, cmd /K cd /D “C:\ ”
Z, b8 `( l q1 R4 Y$ y/ A }& C( c0 A, O" O* b. l' s3 F ?6 {( T
}3 ]4 X; i( O; q
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。$ J; m6 ?, }) p d* r
这段小代码肯能有两个你需要修改的地方3 o0 W5 e: D( e5 y# K& j8 E- I! k! @" w
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ {$ d7 g) |1 ~. p 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ ?% ?! w% G! Z; E- c L1 G |