此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 J# S+ v! H. H 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
s. R9 ]( z' C: d 方式一:
, w. E0 X& ~+ V( j8 {% r* s5 k 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,' q7 Z# ]& C* X% f; b
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 e+ q$ n& f& ]* M6 b6 Q- ^ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
# D5 a! {9 \$ Z- M) w 方式二:
$ C6 H4 X" p) p, Y' k 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: x& h. N5 B( z8 m' w. ~: V
SetTitleMatchMode RegEx
! }2 F, x/ A7 \7 Q4 o return9 J j- t" K2 p, X' s4 p0 Q2 ?
; Stuff to do when Windows Explorer is open; V0 h7 H2 W/ S! m+ X) s) E, O
;3 h& O' U1 c: o! f! Q8 k0 A
#IfWinActive ahk_class ExploreWClass|CabinetWClass
/ K- }+ W# N8 K7 ^# w ; open ‘cmd’ in the current directory
' ~% {* x* Q! v7 A9 J9 L ;: \" {+ ^& Q7 X9 f8 P
#c::% Y& K9 h5 s9 M( ^" r3 m: R
OpenCmdInCurrent(); C; x/ J7 _$ @
return
- q8 @* L6 O' F. r2 @1 z( Q C& {3 ~ #IfWinActive! n4 b4 N6 I: s( F0 @; u
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 `' b9 o# ?/ i1 `
; Note: expecting to be run when the active window is Explorer.8 W/ Z/ J, U3 j
;
2 E' W- _& j( d$ Y( g# I OpenCmdInCurrent()
, E: I/ @1 i9 S z1 p {
: ]* m' m- ]7 s ; This is required to get the full path of the file from the address bar
" T% x& B& l6 V2 I WinGetText, full_path, A5 s, f! g* B2 i
; Split on newline (`n)
8 f; g* Q7 a2 c( _7 R StringSplit, word_array, full_path, `n4 A8 R& ^1 [1 E
; Take the first element from the array' `; g$ k! m9 h
full_path = %word_array1%
) X' k+ f6 |& m% k% J+ f ; strip to bare address
/ S) X7 M3 Z3 @1 ? full_path := RegExReplace(full_path, “地址: “, “”)) [0 j& R- O/ |/ o% G* ?7 ?& I4 C1 x
; Just in case – remove all carriage returns (`r)
& m( d9 A. W. v" b: k StringReplace, full_path, full_path, `r, , all
6 E5 v3 T( L4 S) V IfInString full_path, \
) |4 p- {: ]* }' w {+ ]% F3 F* S( b' W
Run, cmd /K cd /D “%full_path%”
/ o' B/ n2 n$ q6 c* Y8 R }
& i$ F e2 E7 v- a4 {. {, q5 \. k else0 r; `2 ]! @" J1 i p( x$ h
{5 B+ H. L3 T+ s" C; L
Run, cmd /K cd /D “C:\ ”0 w) n3 V; v+ U! B5 M( C& C7 }4 c
}" @5 i! g) ^2 f# n; o
}
, E% [8 h( W/ l" S: B4 j 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。, N) O2 l! e7 G' {; |* }
这段小代码肯能有两个你需要修改的地方& x' E" ~/ i$ S' j' X; |
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' o4 |7 Z M) |, q# t
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
: E/ G: o$ c/ }% W* ?" u |