此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% L3 p8 N' j# F7 f7 |* E- g/ F
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ l! A4 C% Q+ b; l: R. P0 e 方式一:
f7 W: j0 ?: q 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,' {; m- a# B2 T9 ?5 f* `
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
/ R& `& ~4 U/ H) t HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
( p1 w) L: a1 Y4 q9 M2 r 方式二:1 Q9 c4 N0 j- q" i3 j
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:# n0 V. T# B& N9 p6 ^7 Z; n$ O2 I
SetTitleMatchMode RegEx+ \7 m7 i6 C5 g) D- W e/ {
return
+ J7 W Z; M- m, }" j/ P/ Q ; Stuff to do when Windows Explorer is open) z y8 m: u8 W h! I+ S. T5 t
;
8 e$ V! F8 n7 h( D/ L5 N #IfWinActive ahk_class ExploreWClass|CabinetWClass+ e$ T% q2 b( J
; open ‘cmd’ in the current directory; l' Y$ m% z) N y3 s6 j
;. p) I1 l7 S- ?, L% u
#c::
: [4 H D/ `( y2 p( z, G8 b OpenCmdInCurrent()1 D& w# R1 ?! L# n5 H
return+ w& i8 k! H m$ [! n" k
#IfWinActive
3 K3 S& a# I" M# i ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
6 n N5 Y) p: ^! `2 k% |# F ; Note: expecting to be run when the active window is Explorer.: F- M; A! X; a. D$ e8 a$ C& g3 m
;0 T* h6 D* i" U: n. ~& S7 o
OpenCmdInCurrent()
, g0 q6 _! {1 ~; k |( P {/ w4 T5 a" d+ d
; This is required to get the full path of the file from the address bar% T& d( m' P, q# @3 I- m
WinGetText, full_path, A4 u4 u9 `$ l% c; u! D, v
; Split on newline (`n)& y/ Y* ~; d! M& Y
StringSplit, word_array, full_path, `n# Q; x X; ~1 t D- f; F9 k! D, F
; Take the first element from the array2 V% n; f% d3 |1 Z' X* {& _; ~
full_path = %word_array1%8 y' D4 h6 c2 C1 B6 R* ]
; strip to bare address( M) [% x$ o d& Z
full_path := RegExReplace(full_path, “地址: “, “”)
: C, R! w5 m; F& g5 b ; Just in case – remove all carriage returns (`r)
]5 v+ @8 B6 Z7 c* v StringReplace, full_path, full_path, `r, , all
# Z) [4 z% B [! J X5 L# I IfInString full_path, \
! \/ c& m* d; q x. q3 J1 D; v {/ y$ f! `# P5 a% Q" i
Run, cmd /K cd /D “%full_path%”+ B3 Z2 G8 J7 I: o6 `/ S. P! g
}# P I, ~* R1 o% P
else
( q' T7 e% m Z {
/ `3 l5 s7 K0 c/ j7 g Run, cmd /K cd /D “C:\ ”
0 x2 `8 \9 v7 s; u7 L& \ Z5 z }
$ x; v* G+ v5 c. M }
: Q" x5 X7 M- J- M+ X& | 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。; U! t, x! ~0 t+ s1 ] [& H
这段小代码肯能有两个你需要修改的地方
( n% e" q& f* n5 {& M 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& \$ l+ s& g& q4 ?
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; E9 D, {' {2 p" z4 @
|