此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' E0 ~1 S& T- Q0 [ ], z 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* I2 U7 s0 n2 e3 {7 Q) F" F 方式一:+ }+ v) [3 `+ c6 W% U, @" Y* m
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
5 T* z* i+ u) U 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 n' V9 u: J8 `: t$ B HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。) Q1 h: q/ Y. G O) g( G
方式二:" N9 u2 @8 n* R: N
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: x* _4 R! T3 s/ i- H
SetTitleMatchMode RegEx, m4 x# \7 F: p7 N3 |) \1 V6 a3 a
return( N5 q; `, B# k' B( _3 u9 n! }
; Stuff to do when Windows Explorer is open; E/ h- e; M2 H3 d( F
;
0 x+ a9 M6 |* }( t4 c5 h8 x #IfWinActive ahk_class ExploreWClass|CabinetWClass9 r* E3 I" k4 o4 ], U+ T! y6 D
; open ‘cmd’ in the current directory
6 X* F8 N8 O8 \3 X% A( K: S+ [( b ;1 c7 \5 _5 g) y5 Q& k
#c::) n! o, ?$ U5 X4 e: M$ M) z
OpenCmdInCurrent()
& Z" O+ G/ u+ r. \ return
: C5 U! c m) |4 p- W* T6 A- Y" ~ #IfWinActive" Z; m% d. `* }% `8 X* Z8 q
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.$ |2 G# g+ N" y* s4 {. x' ]
; Note: expecting to be run when the active window is Explorer.5 P |. q t. c# B! I* u
;
" Q6 p$ x6 J! x) ]2 W OpenCmdInCurrent()
! X: W5 w- e/ i9 N' E7 o2 W {
! K& ]( k2 ^7 P( M+ o& I ; This is required to get the full path of the file from the address bar0 I4 j4 P9 k8 f/ [) h# n# }2 n: v2 N
WinGetText, full_path, A
: p& L' E5 A/ \' G( D5 R ; Split on newline (`n)
9 i/ {/ O: `: R T3 F; w0 f7 | StringSplit, word_array, full_path, `n
# M& `( z% k: k9 I' `% y: Z ; Take the first element from the array _" O1 G+ B w, Z8 s# u
full_path = %word_array1%
# a0 s" p9 Q4 R' N/ m; E3 B6 ^% ? I ; strip to bare address
W# r9 n5 @9 t full_path := RegExReplace(full_path, “地址: “, “”)- ~; f$ J# Z: L2 T: p- s
; Just in case – remove all carriage returns (`r)4 Y4 X# P$ G. r p' `9 h
StringReplace, full_path, full_path, `r, , all: W3 k" G. y0 Q& N9 V
IfInString full_path, \
1 {0 v0 ]5 {9 b ~4 O( }8 f" _ {
- B# b0 W: u* ^+ @ Run, cmd /K cd /D “%full_path%”
7 a8 R5 ^7 H9 v$ F& L! N. Q }
/ ?3 r5 ]# A6 w3 h5 k) S S else5 K. y+ r7 P. H: ^
{3 C7 x# z7 V1 k3 l% A
Run, cmd /K cd /D “C:\ ”# K" o& w" q1 Q! s$ H' z
}
: a$ b* G: o8 L* S8 Q }
4 x( C ~% L' w+ @3 O, V; ^ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) h) F; w# E7 H5 n. |4 z
这段小代码肯能有两个你需要修改的地方6 a1 w# H% `: Y0 C: G* y
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; U1 p0 H* i4 _$ O
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “5 G; F e0 |* D J( a
|