此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
( @4 r& x L; E, L8 c ] 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 M1 A3 D7 v1 H. S 方式一:% t" L# k$ ^7 |9 S
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( g( F9 D8 W% C, W* C7 x% S) i
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 j2 v: x1 q2 {' F W
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 t* Q5 S8 J/ z# w6 M9 \. x 方式二:
2 z4 ^5 s+ M7 w 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:2 E2 d( l* Z, o6 w% [' @
SetTitleMatchMode RegEx: b1 Z6 c2 Q; N
return
4 n6 _% l3 J( [ ; Stuff to do when Windows Explorer is open
6 W, O( J, `$ T3 l3 D ;
! g# R1 h) v' L0 Q4 Z9 p #IfWinActive ahk_class ExploreWClass|CabinetWClass" i# u+ Z- Z0 Q6 l
; open ‘cmd’ in the current directory
) ^% K8 Y U; C8 C6 m0 j# l7 | ;
! w' A+ h% G) W. F #c::
& f" v* N1 }7 h& ^0 C OpenCmdInCurrent()
1 O; L+ @8 ]( C( l& h5 w) a return( P4 t: ?( {' T# w
#IfWinActive
+ s8 d2 K" R$ v( U, j& D ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
2 F) \2 e/ J+ u& n ; Note: expecting to be run when the active window is Explorer.! u/ k( T; B7 V
;1 U# T! n9 m% l! y5 w' r/ r8 S
OpenCmdInCurrent()
) a7 _; B2 P* X( G7 [ {
. d' N& _6 b' z/ _& ?5 Z2 h ; This is required to get the full path of the file from the address bar
N/ N0 y% V& B. g9 t; k WinGetText, full_path, A
) w; e7 q, J& i, e' a$ z B ; Split on newline (`n)
\% D7 M, ?; ] StringSplit, word_array, full_path, `n# C) A8 v2 m! S ^' C0 o5 d' A
; Take the first element from the array
0 X7 g9 D$ Z+ b* i8 m- B full_path = %word_array1%5 j& a( C5 ?/ u* B
; strip to bare address1 T- R4 `4 l/ ?) a" B. z" z
full_path := RegExReplace(full_path, “地址: “, “”)2 @9 h+ d2 K/ Y5 I. M
; Just in case – remove all carriage returns (`r)6 {& i- a9 T) t8 m: j( f
StringReplace, full_path, full_path, `r, , all9 A8 g4 Z7 ]3 O
IfInString full_path, \
; g/ ?4 G; t5 _3 ` {, Z- Z1 {# s. }( t4 M8 Q( \. v
Run, cmd /K cd /D “%full_path%”1 F8 P- O) q* H1 t7 ?) x0 t2 R
}- o. I+ v) Q7 u
else/ r/ @) J, x7 b# L& h) @
{
8 ~% G: f @; z4 U6 x7 v Run, cmd /K cd /D “C:\ ”0 J2 j7 H. G. Q( p) T
}
P1 ?/ b2 Z" q. p0 \3 Z }
7 C `: {, }8 h& p6 q' c" C% n 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
6 r9 J, j9 o b' w2 y( c# O 这段小代码肯能有两个你需要修改的地方6 J6 V) `# z& I8 t+ f" Y+ U. l: i
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' {: K% M; P. h: m7 p
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
{ X$ o& H; r' W! b4 a |