此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
& {" X. m9 n4 S 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。1 T# e6 a; b+ F' B
方式一:
5 P0 _7 Q+ _ s+ v* y* c 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,: ~1 q, {$ m4 A
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 Q- {1 g/ f' Y0 a2 X
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
& o- ?2 ?4 t r3 E# j ^ 方式二:3 J" x9 r" Y! i( Y1 H
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:1 g' X$ i4 ?+ F* {' h! b& B
SetTitleMatchMode RegEx
. |8 O9 O8 V6 ^2 o' r return
) s/ g1 u# y% Y0 [ ; Stuff to do when Windows Explorer is open' g+ d+ m: E" k
;1 @; x7 Z0 I' \1 J, _6 Z
#IfWinActive ahk_class ExploreWClass|CabinetWClass
' Z% y" d( }+ P- |5 \ ; open ‘cmd’ in the current directory
( P8 z- c" r& i: N& @# P9 N ;
2 {1 {' n h/ f+ X #c::! q+ C) x! ]: w/ e$ D" D
OpenCmdInCurrent()7 d3 N- i: }& m
return0 ]- ~# p! R6 R# z
#IfWinActive. q% g7 L, O; [; g/ j2 _
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.1 d, t- x' R4 f- {+ ^' K, z& r
; Note: expecting to be run when the active window is Explorer.9 D2 f2 R2 }! \2 ~3 L% r1 f/ w0 y
;
* L- T7 A2 p8 A% Y OpenCmdInCurrent()
( R) \$ v8 \- Q0 k9 W0 H7 j {3 V' E. f/ T5 J' |6 A C8 a
; This is required to get the full path of the file from the address bar3 i% W3 U3 D% }" r0 q2 @: r
WinGetText, full_path, A
8 L1 ~3 e: W- F1 B0 B ; Split on newline (`n)* t, N( u9 U. X/ _9 R! z$ l0 S' L
StringSplit, word_array, full_path, `n
* Z3 t( Z% q w ; Take the first element from the array
4 L& U% K- T$ ?, `. j7 m8 }7 o full_path = %word_array1%, s) }5 n' [3 _7 r
; strip to bare address( W: I" Y6 R) } q7 T
full_path := RegExReplace(full_path, “地址: “, “”)7 ?5 D8 u0 P" J9 z; f) t$ W% b3 j
; Just in case – remove all carriage returns (`r)2 g' \ W4 M! [8 p, Z% y" [
StringReplace, full_path, full_path, `r, , all
9 z$ o5 s2 P8 _) a; m- w IfInString full_path, \! q% a9 a" C. o2 R' Z
{
8 j( M+ N8 ]" W Run, cmd /K cd /D “%full_path%”( ~& s( g# E) d) o( K+ p
}
/ z6 t& B. O, Z4 J else# \# K% e& m+ f) c
{, a6 k2 G" G/ p0 T& o* t
Run, cmd /K cd /D “C:\ ”
! e7 c1 e/ ]. J; v& B }4 y' g3 B. _" a+ `; `- C
}+ j1 ?, C% x2 E7 f4 A9 }- D3 y5 T: t
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% z# K+ C# W1 I: q
这段小代码肯能有两个你需要修改的地方
; N2 g9 E( @. ] 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 f! N, E2 }$ U% X
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
1 v5 r$ }9 v5 N( E# b4 u' ~ d; @ |