此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; n; G7 {3 P% b, Y9 U
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* s# [9 `& P0 t8 g
方式一:
% _ v5 q; o2 N* @ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,2 u. D ], d$ _
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; p4 j; f& H6 _$ Z% g7 D HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- ~: Y W ~7 o5 L
方式二:( s* S4 s- X4 P" j' Y( L) B( J9 B
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:* N. }' C6 J3 W6 l4 X6 X
SetTitleMatchMode RegEx
- a2 {% ? I% a return" y+ \+ X; c5 {$ t
; Stuff to do when Windows Explorer is open
0 M) E' E( Q5 k# ]2 ]4 {8 l2 p ;
, R; |+ G( U& D3 w #IfWinActive ahk_class ExploreWClass|CabinetWClass
7 L$ G1 b' l8 n" ] i, X ; open ‘cmd’ in the current directory( b2 N) I; D) a3 }
;
, ]6 T/ k3 b6 f w0 R #c::
o" ]& x$ _, }) Q7 m OpenCmdInCurrent()7 K( a( F5 K9 S' b9 _( {2 o$ T
return
! ?, H5 ^" p& H! T4 e$ z6 _ #IfWinActive
% Y9 p9 o# J0 x( F \4 J ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
# ^8 ]1 Y, a2 c7 m2 ~& _2 \ ; Note: expecting to be run when the active window is Explorer.
& P* [& @. `2 R/ W7 g$ i7 k8 j ;
! j) d$ S3 L8 `. h1 L OpenCmdInCurrent(). J5 y3 S- o+ y7 }7 @
{. \; k8 \2 |* G* Q1 F# v
; This is required to get the full path of the file from the address bar+ @% g: A" V% y; C4 C3 K- _
WinGetText, full_path, A4 g, @; O$ E2 T+ b5 X0 U
; Split on newline (`n)
4 e- O9 M& ]/ }. K% |; B StringSplit, word_array, full_path, `n
$ E# }( P, C# l( m ; Take the first element from the array
! w! Q9 Y: d. ?5 D! B full_path = %word_array1%8 w! ~9 X% N5 |8 T5 F* U
; strip to bare address6 U+ ^% K: X; c2 x% J
full_path := RegExReplace(full_path, “地址: “, “”)' y7 b' T: ^! y6 _
; Just in case – remove all carriage returns (`r)" [! p! R4 B% n1 F/ e. x
StringReplace, full_path, full_path, `r, , all
: J& e0 P$ r5 o0 U% F IfInString full_path, \& x1 `, B7 D, r4 t7 \8 m1 a
{# Q. m8 s/ B* V& T! O1 V
Run, cmd /K cd /D “%full_path%”
* e. }, d3 p* O2 B( t, b# l# { }: G' X; y( H) }0 v8 j& w4 e
else; ~% z0 @3 U& X$ R5 D
{3 y) j# R* }! W/ D+ |- i# `
Run, cmd /K cd /D “C:\ ”
0 c3 H) w0 e |9 v# }4 h0 i }$ r0 S' o; N3 k
}: T7 O5 @2 T P% T
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. T1 X4 P; Y6 [- W% b0 w# U' e/ U" o 这段小代码肯能有两个你需要修改的地方
' U0 u# e( @/ R6 J: C& T 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
& X, K Q5 X$ i, l, c 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “) _ C0 A6 Q! q& N# [7 c7 [4 `# d5 f9 m
|