此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
! A2 x: g! w; O9 ]" g g; L; q2 | 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 ^6 V: `' g1 I" Y1 J8 f1 M
方式一:" g9 g* G5 A; ]$ K7 C5 }: Y
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,% k# v. t e* H$ H
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
- m% e" I5 {5 B9 N HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
: t6 R. p8 x! p 方式二:
6 `' R, `/ `0 V5 l* ]( r V 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 o' n u# P. G% v
SetTitleMatchMode RegEx
% Z+ [& `; y L return4 X$ Z" g# R" Q
; Stuff to do when Windows Explorer is open E! n% o5 a( k/ ~$ g
;
& r v. U, X0 `- L$ I5 m% ^ #IfWinActive ahk_class ExploreWClass|CabinetWClass% m7 b; W' `- y+ O" s# Q$ P* e- j
; open ‘cmd’ in the current directory E! v8 ~. _+ k- }, d. m" z
;
- K' B* N/ R1 Y" o6 l7 \ #c::) M9 L7 C( l2 E# g3 j
OpenCmdInCurrent()* ]! l% \7 y8 J% x. l- g
return
' }3 Y; s4 r3 o' ]( @ #IfWinActive" v' J H( k) S
; Opens the command shell ‘cmd’ in the directory browsed in Explorer., p! N: o& i: k
; Note: expecting to be run when the active window is Explorer.; T" E& x5 t+ `
;' s6 D& X4 _: F" J
OpenCmdInCurrent()2 N, m- P, V) J! _
{
9 I# @- Q: l3 Z* K1 o ` ; This is required to get the full path of the file from the address bar
) q" J% {2 v* E( U; C0 u WinGetText, full_path, A8 s0 `- j5 _* E7 z
; Split on newline (`n)3 Y- \* Y2 o1 }0 g) a: D
StringSplit, word_array, full_path, `n
9 f1 P4 Q( E# ~ ; Take the first element from the array+ E! t# l7 q4 B3 b" H2 D
full_path = %word_array1%) ]2 d( K6 T: F, E$ h0 w
; strip to bare address. D1 u( U" ], s0 G0 h
full_path := RegExReplace(full_path, “地址: “, “”)8 ]) O2 b2 `/ h5 l
; Just in case – remove all carriage returns (`r)
' ]; K9 F l# t: P- ? StringReplace, full_path, full_path, `r, , all l, P/ X _4 u; j" F: j
IfInString full_path, \1 h8 G$ O+ G7 u5 D' W! h
{
, X5 h! ^1 ?, X0 Q6 P Run, cmd /K cd /D “%full_path%”
3 G0 E, M! L# J# D) N3 F }
% B G* L9 R c, l* S) y$ } else
! Q) [3 t7 J: l7 ~- B8 k) Y# u {+ Y/ ?# o9 V Z, c; \; m7 T- H
Run, cmd /K cd /D “C:\ ”
- T* k# f# s, P( s+ e }& X7 I1 v6 [5 {( A" _+ Y
}- M1 K6 ~" ^9 Y& A) a
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 Q+ {8 w1 m+ n# \2 o. W 这段小代码肯能有两个你需要修改的地方. a" p+ n# n. C2 h
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键" ^+ P/ o+ J$ h r
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “ p* k2 S( I4 I/ }8 @
|