此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
0 m4 z; m: `. {7 A7 E/ \( N 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% v1 F8 }. l/ \
方式一:/ }5 V0 R3 O5 f
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,7 N4 D5 o' ]9 ^
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和9 A+ ^8 E! @9 i Z6 g$ D
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ f9 R$ v e5 S3 d% \9 H' m! D
方式二:/ N. v! g M5 `( D0 H$ i
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:% k# V; s& V- X1 \& d
SetTitleMatchMode RegEx
Q7 V7 v! N# H% t! a return9 h+ L# l3 M5 }) |! q# v c
; Stuff to do when Windows Explorer is open+ M! B3 ^! v8 {' P5 a z3 V
;7 M W/ s+ s- c; e- q
#IfWinActive ahk_class ExploreWClass|CabinetWClass5 ^2 r, e n6 G; P- V$ O$ b7 j* ?; A
; open ‘cmd’ in the current directory8 Z% X" T# A( I* K2 X& H0 D
;
& S4 ~) t* T S" t3 e; ^: b #c::9 S$ v% A/ P: D$ L) B+ ?/ E
OpenCmdInCurrent()2 k" `8 `; [& Y) w* I
return
) j3 V9 X3 ]! z4 D ? #IfWinActive
- c7 U5 o/ i, y5 J+ @ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
! r: M1 N5 m2 Y. ] ; Note: expecting to be run when the active window is Explorer.
& {7 P; h; y% ]9 V3 x ;
. j/ @) L( k' C' \2 y- h/ E* h OpenCmdInCurrent()' T% m/ k" F; q$ D/ g/ y1 y0 K: T
{) Z' W6 r2 _9 X4 p; U3 d
; This is required to get the full path of the file from the address bar
& f- ]( R7 ?. ~) | WinGetText, full_path, A
8 {( @- ]: r* v$ ]" S' Z9 w( @ ; Split on newline (`n)( q' S/ t) v! X* [% e4 P
StringSplit, word_array, full_path, `n
7 k! c: K- H$ A/ j ; Take the first element from the array5 p; O8 j+ e/ ^" P
full_path = %word_array1%
2 G" g0 z8 R& c2 }4 u ; strip to bare address( p d7 H3 Q2 h
full_path := RegExReplace(full_path, “地址: “, “”)
$ k& t9 ^0 B9 K% \2 h1 u; K ; Just in case – remove all carriage returns (`r)
3 ~3 S9 J# ?+ S4 y& r; S1 J StringReplace, full_path, full_path, `r, , all
- C3 R8 D7 F9 {% J- F* |% w IfInString full_path, \
" M. ?1 u3 j* Z: c5 M {. Q8 Z. x5 q9 K5 L; _; d
Run, cmd /K cd /D “%full_path%”7 B \) N2 v2 A/ `* h
}
. L% e9 o R& W9 f7 ?9 R else% c8 Z7 d" w1 r* L. I, E! ^) G5 m
{
3 a" Q2 E! a/ S3 w Run, cmd /K cd /D “C:\ ”+ F( T& M1 j7 J- }& X/ H
}% o$ `+ M: w. n$ {3 v" H
} B( s5 Q0 U7 V, t) G* _) U7 s
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
! A1 t, B5 r% W 这段小代码肯能有两个你需要修改的地方) p6 }& y% M" z2 F
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' j8 e4 B+ V6 @3 I) i2 ` 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 x! V& f# s# e# c3 f) l0 `1 q
|