此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。" f. O- g/ c0 _" Y2 D; s" N
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 v; J) ]) P# A+ l+ H0 L8 ] 方式一:: T! D1 ] x6 y
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,7 [ w3 S* I I# [% p
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
L) x4 m W. |9 Q, T$ c HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! i" j7 c. [0 p( p 方式二:
* V( [: ]+ C6 ?; O 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:% r" T& I! {7 f
SetTitleMatchMode RegEx
6 p# i2 F) d( M( T% _# I( [ return; u) C7 ]* r3 c9 E! K. c8 {
; Stuff to do when Windows Explorer is open$ i: a; q# J! j5 I; `7 J; l+ ^. o
;$ T N7 n/ q( r/ s! O
#IfWinActive ahk_class ExploreWClass|CabinetWClass
& K s5 D1 V' O! Y: z; o ; open ‘cmd’ in the current directory1 w9 y3 F2 e% @$ Q8 e# q8 \
;
0 N, ~! q. v" T- v8 D" s #c::
6 n5 u" S3 c6 w6 | OpenCmdInCurrent()5 a3 ?; c8 z+ L' a
return) o" b6 v' H! r: Z8 E! @
#IfWinActive
u8 m5 z1 y6 L ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
" W7 a6 |: ^0 {0 i; h8 N i ; Note: expecting to be run when the active window is Explorer.5 F$ F+ M @' I( a5 O: M/ R/ Z+ t
;
4 I5 y9 y- g0 a! r5 j2 L4 ~+ {/ ~5 x OpenCmdInCurrent()/ [. [9 Z/ A" V6 t/ p5 F5 H4 i- {
{& _$ H0 _2 K5 ^1 {
; This is required to get the full path of the file from the address bar
0 E, n1 m- D V& I WinGetText, full_path, A
! U- m/ A( S% h ; Split on newline (`n)9 G( q2 P8 o3 R3 ], w- i
StringSplit, word_array, full_path, `n& |- ?: y) z' m4 I" [4 ^
; Take the first element from the array
$ \6 m/ e& t, |7 x4 w. q full_path = %word_array1%( a5 {; Z9 I7 @4 c2 A# I( b
; strip to bare address# H: a9 I0 s7 x! @3 ]
full_path := RegExReplace(full_path, “地址: “, “”). o/ j! D) c# j, @
; Just in case – remove all carriage returns (`r); T7 b3 ]1 g' g1 Q! e$ {
StringReplace, full_path, full_path, `r, , all8 G8 s( b" S1 P' O# u1 w
IfInString full_path, \3 x. I+ ]# ~) ]. C9 I8 J4 Q
{2 j3 z; x, |6 A1 O7 m
Run, cmd /K cd /D “%full_path%”
8 W! f4 q7 j/ z- E* r }
1 b1 U+ x# c; i1 ~! X else
- Q4 }0 S) q) d0 y, d {9 l1 ^% a4 R1 s. j
Run, cmd /K cd /D “C:\ ”7 V/ T9 k) R% T, F! L! E2 f
}" T* S* r8 R( o& M( m4 g
}4 R. o8 X4 w' A3 P4 i
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ V& K+ _! p I+ p! @8 F; J2 [ 这段小代码肯能有两个你需要修改的地方
2 }8 g i0 J' }7 s; o% J 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键+ o/ L, ?0 I' s! t: m* Q
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “) H2 k |6 D6 D
|