此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
" e) O+ O3 q8 n( {' t' v( } 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ E% i# i9 \# Y$ L, F6 q" f 方式一:1 ~( K. l. ^/ U& h7 x1 B
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ `" T9 w* Q B* k# ]. p' {
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和2 Q, R0 |2 H o6 u$ g: H( V
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
8 n e: E% V" \+ U+ W$ O 方式二:' o6 P9 t& j9 ~" [ A+ d, W
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:; j' h& Q) y9 H) q$ n( O9 R" f7 U
SetTitleMatchMode RegEx
. L" Z/ u, y4 [3 x return0 H* z! c4 y! m% u6 r: f/ d9 d
; Stuff to do when Windows Explorer is open) i3 B$ T4 K/ c( u
;
' {" C) X1 T$ P, X' u1 w- c: L #IfWinActive ahk_class ExploreWClass|CabinetWClass
: D2 H& c$ y( s D ; open ‘cmd’ in the current directory
" M1 ? Q7 q: T' c3 p4 R ;
2 V3 J3 u1 I* G8 m4 @+ r #c::
2 d/ G2 J7 R. t a OpenCmdInCurrent()
. k- I2 b2 ~9 y3 ` return
# @( v" [ Z0 r0 |& i# u #IfWinActive
8 E/ ~, I3 G9 Z$ N9 ]2 }1 ^' H+ g( I& [8 N ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
& r n, c7 H2 T4 s+ F' L ; Note: expecting to be run when the active window is Explorer.7 K, u q# R W l. C. ~2 n
;0 Y; R5 u! b6 F9 P6 a/ z
OpenCmdInCurrent()
5 l0 D# G1 [8 f* _ {4 v+ K. J4 |, M
; This is required to get the full path of the file from the address bar2 ` g% ^' T! `" ~
WinGetText, full_path, A
' z- N% c5 V$ c/ | |/ A ; Split on newline (`n)& K# ?* G }3 D ?
StringSplit, word_array, full_path, `n, J7 J) \6 n: n' x# H
; Take the first element from the array7 f x5 ^' B# `
full_path = %word_array1%
2 K' f2 X# J; u0 B ; strip to bare address6 Z' l7 J8 U+ Z6 C, W: Y
full_path := RegExReplace(full_path, “地址: “, “”)
! l& M. }# a) | ; Just in case – remove all carriage returns (`r)$ s' O0 m8 g8 }5 O+ f
StringReplace, full_path, full_path, `r, , all% T+ a7 r% E/ X8 M- g, m, _
IfInString full_path, \
" a' Q! L" `" S9 e) T {
- {+ y- [5 a$ v Run, cmd /K cd /D “%full_path%”
# N7 ~0 s8 U: a. F2 b4 R }
0 c4 @0 C# R5 e) z else
% G3 A- V+ f7 ^/ o% ^% {4 J; b, s {
$ Z3 k+ h; ~/ @! K: P0 O2 K Run, cmd /K cd /D “C:\ ”
* r) N" ~# ^. ` }% ]% M U M: g
}/ q7 a h' ?: w
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- T: \) U9 a# f3 n( s& l" s& U 这段小代码肯能有两个你需要修改的地方
4 R1 K) x" P# s; ?. a. k$ B 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键/ [7 i9 C3 G( u0 E
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 z4 i, h2 W/ R& J* R
|