此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; B9 w2 a0 Y+ T5 h* }$ ^$ o1 M 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 f1 O4 i& x; `6 y0 m- j1 m 方式一:% q0 R0 X W4 l/ n' R$ ]; o: v
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,$ Z1 C) d. o/ a# S$ t' `6 {
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; C6 q* \. h/ V; P HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。# }5 _8 {, d. s2 o/ o2 M; l
方式二:
4 b, G* R8 J+ W* U* R 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:4 N6 S+ b v4 Q
SetTitleMatchMode RegEx9 |4 e. M6 ^! |& B% j4 c
return# _) E9 t4 c! _4 J0 d( Z
; Stuff to do when Windows Explorer is open0 k3 _0 {3 H6 L
;
) i5 y5 w' }0 [& E1 g$ Y #IfWinActive ahk_class ExploreWClass|CabinetWClass: F- l4 Z1 A: h* r; @
; open ‘cmd’ in the current directory
" i( o/ a( e5 {+ ^2 [ ;8 b9 v+ ]1 J7 N7 j0 s2 v5 Q
#c::
' O* x# ~8 O" } OpenCmdInCurrent()3 f5 L6 ?* u3 P( P2 n7 I
return/ c3 w0 S2 @+ T. K. s* q% P7 d
#IfWinActive
4 E* Y! j5 _, l$ l ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. S+ ?& V5 T0 a, b+ B7 l F( M ; Note: expecting to be run when the active window is Explorer.
' o, e- Z& U( ?# A: x# e( s ;# W+ L& Q. `: n! T/ I7 R& T: z
OpenCmdInCurrent()" K- a! ?$ X8 A
{
- J$ N; x) Z1 @, c9 O" l! b ; This is required to get the full path of the file from the address bar* x' H! R! |" w' {
WinGetText, full_path, A$ E/ d5 P( u" {" |, e# q8 g: X1 d
; Split on newline (`n)
+ ~2 Z: d/ S& G1 k' O( B StringSplit, word_array, full_path, `n
$ H( w2 o; L0 n1 ]6 }% X ; Take the first element from the array
7 o N/ c, z- ]' r full_path = %word_array1%; N; |9 f" q- h' Q, `. M9 a5 ?4 z
; strip to bare address
]. E( J4 t& ^% V full_path := RegExReplace(full_path, “地址: “, “”)
4 q) w; x6 W& Q' u8 d ; Just in case – remove all carriage returns (`r)6 R* U! u: m$ |
StringReplace, full_path, full_path, `r, , all
. Y' ^) Z7 `5 o2 F; S1 E IfInString full_path, \) W/ ]4 l* V! `' D$ z* x% R! E
{7 s9 l& k1 M& u: b- V
Run, cmd /K cd /D “%full_path%”
8 V( U/ X& f- P5 F2 t }4 u# S, \3 h j/ [
else5 l, g% z8 i3 {( r
{; @% x! y, {6 q: D
Run, cmd /K cd /D “C:\ ”
, n9 k& U7 \) {! q }
u7 M0 q H8 y6 o3 f }
4 }6 Q- d, M: J! c: ? 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 ]! `. [- F9 E0 h/ S3 U2 J
这段小代码肯能有两个你需要修改的地方! \( B' C# l3 d
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
6 {, b" u1 H8 ~) Y4 j 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 W6 i8 R% ?# h' r& a h. z |