此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
1 W; p x7 u7 T- ?! F 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 o2 w- |) ?% O* K$ g/ _$ m 方式一:
' R7 q3 e L, u5 f 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,% L. ], M+ ~! L$ C7 S5 y7 f' ^
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和. g3 b8 Q# u2 I! W0 c% Z
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。% g% [) `6 f$ e7 N5 ]0 F! I
方式二:5 J8 x" P; e8 V0 h% F) b
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
5 Q' p! y/ y! o8 u SetTitleMatchMode RegEx" d) J1 o: ~% `' M* `( L
return
% K" m% Q' M) T; q ; Stuff to do when Windows Explorer is open' m2 J( a/ o# ]; O; |" {9 ?
;
# |1 p6 a: p/ w$ M4 c: S #IfWinActive ahk_class ExploreWClass|CabinetWClass
8 d- {0 N' P6 I ; open ‘cmd’ in the current directory- @7 [: c: Y: ] x8 p: _0 u$ `5 l
;( \! I' P) N' M% c$ e; ]8 o; ^
#c::
7 g9 |1 D F6 t- i OpenCmdInCurrent()
& y/ c) D0 O! X4 Y+ C& y* } return
/ ~+ u7 K9 V' U+ n! o #IfWinActive
$ z" s: F/ k! |1 r* z2 W: c ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.+ ~5 S- z4 a* T$ x5 v5 W; d ~, y6 U
; Note: expecting to be run when the active window is Explorer.
! J7 z9 i8 R) [: K$ |9 f ;
' Z7 \( I2 f- i2 I4 W3 K# L5 s7 r OpenCmdInCurrent()" w1 e$ N- v5 ?4 S& s: c
{
$ L1 s) N( Q6 ^0 B3 U5 X5 U9 i# p ; This is required to get the full path of the file from the address bar
( Z. o8 J0 y6 w WinGetText, full_path, A5 Y9 Q7 f4 b" k
; Split on newline (`n)3 r! T; Z$ Q0 f( X, ?5 I
StringSplit, word_array, full_path, `n% K! }' [) H/ J$ K: D, m
; Take the first element from the array
% D0 f: a, S+ j6 X4 v$ } full_path = %word_array1%- X& F" p( i: b1 P
; strip to bare address
. Z; m" `) w" M9 S; P, D* g) I, ^ full_path := RegExReplace(full_path, “地址: “, “”)
! M0 C1 Q) V" h8 R& k, X* { ; Just in case – remove all carriage returns (`r)* M4 {, I" U" L( p% n" e
StringReplace, full_path, full_path, `r, , all8 E2 I" F$ j9 @4 r! Q8 m) @
IfInString full_path, \
* m! L W7 l0 z9 O+ N7 H) g { S" W8 H ?9 c2 M ]% t
Run, cmd /K cd /D “%full_path%”7 U* x; O- f$ k& d* N6 U
}
+ n" s0 p8 f! d6 i. K, I else0 S( E( K+ D$ u! `
{( ^6 j4 Z5 x: o3 u: I. y
Run, cmd /K cd /D “C:\ ”
. x/ n% S* n7 t/ g$ M2 D4 a; k6 |7 ~ }
: o f. [. L* Q }8 k& Q6 d1 a4 N- D% a6 ?
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。; _# `2 S1 t; ~, s4 V) |+ E! q' B8 d
这段小代码肯能有两个你需要修改的地方
0 d$ [9 F w: U7 x2 C 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ r% Z0 Q! `$ i1 S$ ]! ^ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
+ H: t. Y$ t- e9 H, z# M0 ]7 Y3 U4 ~ |