此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) ]. `4 h6 W( C+ k/ Q
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, K4 c- j: n* p1 `' t" v/ p. ?
方式一:
! C0 C( j6 _ J 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,: R, x7 |1 }4 ^" v0 @5 K# I g9 ~9 C
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
$ e, \* S) b* c5 P( ^+ l3 m HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 O2 F, \9 m0 h7 h4 c' c
方式二:! F, Z, J+ l8 |8 D
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
! c- i3 N( D, ~4 F) i SetTitleMatchMode RegEx
`5 @' T7 p7 I- j4 ] return. N$ n$ Q$ R! s8 a5 S- a& Z6 L
; Stuff to do when Windows Explorer is open2 D+ M8 A" r% k4 S. r0 K0 m+ G6 U
;! F* n/ r; F0 a! }7 e+ ~
#IfWinActive ahk_class ExploreWClass|CabinetWClass# C" L2 x x' U8 j7 l. ^: u
; open ‘cmd’ in the current directory5 \& w! k. ?4 Z: Y
;2 o) E( A5 {* {) E, g2 J
#c::4 w: |1 H4 {. C0 m. D7 m' H
OpenCmdInCurrent()
' e0 i& w: g1 a) s5 K" [7 G return! }- l- [7 ]9 Z9 [+ s( W
#IfWinActive
' ^6 X- c) C V1 e1 P ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: p; n T" A& g5 l" `9 |
; Note: expecting to be run when the active window is Explorer.
, w2 R! ~( Z- v* c1 {6 u) E- [ ;
; \6 N. U; F& K6 Y/ J OpenCmdInCurrent()) X% o9 ?' I" l7 T
{' I% M4 X8 {: @+ E( A7 v- N3 o. G
; This is required to get the full path of the file from the address bar, s4 P- |$ I* {% ]1 e* Q8 n' P1 ~
WinGetText, full_path, A4 H4 p% G( N+ `" S |
; Split on newline (`n)% K9 q# B$ a* o3 Q" @/ E/ w8 U" A
StringSplit, word_array, full_path, `n
$ g9 q9 o$ r5 N. c% r ; Take the first element from the array! @9 q3 h; r4 _" b$ i+ O
full_path = %word_array1%
3 S! R/ x. {, T ; strip to bare address4 P+ N5 `: t8 t! ?+ L6 M
full_path := RegExReplace(full_path, “地址: “, “”)% [0 o) N6 H& o- T# P; V& ]$ W
; Just in case – remove all carriage returns (`r)8 T: C- c' L) p8 B" v, T ?& Y
StringReplace, full_path, full_path, `r, , all
5 b0 ?" u, u4 x: {1 } IfInString full_path, \4 v% [ R9 p* `' _; Y. }" h
{) z. O8 n9 ?' Z
Run, cmd /K cd /D “%full_path%”% ?! Z& z. N1 E* t" e; I) f9 r d9 L% v
}- Y7 U8 L% c# x0 A Z8 H) I4 I
else
% Z. G1 a# \3 @ F { i2 a' m3 @: I; G1 W+ L: ^. e
Run, cmd /K cd /D “C:\ ”: `) l6 M: _" i) U' U' o
}' E* j, A/ z* b( d
}1 e/ z. e+ U. q/ r( M, ]4 x
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# J8 z, ?$ f8 z: j 这段小代码肯能有两个你需要修改的地方
5 u+ y! o6 F u. u; y! k 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
6 l" w7 `8 V1 S 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “" g1 [! a- s" W1 q: q6 H
|