此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。& I" `: _. W8 j" q4 P7 [
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。 u9 f3 ]% U) i& L6 h+ \4 `% p
方式一:
0 m; n# n2 ]* x! t3 C 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
2 t3 i! @2 C2 G1 m% ]" d) C! ^ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
. Y' L; g$ I, r' e% d HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 a7 l, H9 D$ I# \0 X! Q
方式二:/ Q% W1 i( }* J( F0 s) Q
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 B0 ~, D6 f6 ?# h6 e8 j SetTitleMatchMode RegEx
( z+ O# I( q2 u7 o' z/ [/ z return
! c( J0 T! \# d- R& E" R) i ; Stuff to do when Windows Explorer is open
5 I0 N1 `+ c$ L; N& s, W ;
4 b7 r; c) O0 M% M( |5 x. ~; Y& m #IfWinActive ahk_class ExploreWClass|CabinetWClass5 n7 N& a \, ?9 m" b, ]% ^8 C4 E
; open ‘cmd’ in the current directory$ Z( K1 J6 I% b4 ] N `* c0 H: a
;8 ~: w# g' C5 x3 T" [! R( M. L- `
#c::4 v3 M5 P k/ t# t+ W+ a4 f1 R
OpenCmdInCurrent()6 G7 T: r/ a5 L8 ^' B' M% L+ ^
return0 Z2 U% w, P; `$ c
#IfWinActive v+ S8 m9 A3 C" B( G9 T
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
+ L& d9 S0 I& h" T$ D ; Note: expecting to be run when the active window is Explorer.2 R* C" ~& e% E; S* {+ f- }7 C! A( k
;
, Z5 z: o, q4 a OpenCmdInCurrent()# u, k+ K Y/ L& f; @9 @# L
{
) K% f9 G6 l& O U* } ; This is required to get the full path of the file from the address bar8 D* {* k6 K# B' a, Y! D
WinGetText, full_path, A) M$ D: ?3 z5 o, M9 F8 [- i0 a
; Split on newline (`n)
2 y* \5 J5 Q5 n, t0 d1 I; s StringSplit, word_array, full_path, `n
! e D) Q8 H* N$ E v ; Take the first element from the array2 a- f7 o6 L# h/ Y \3 [( F6 Q) Y
full_path = %word_array1%
. Z1 Q/ N0 {/ I' ]$ S+ G ; strip to bare address
9 n S- t( w2 z v8 A full_path := RegExReplace(full_path, “地址: “, “”)
$ p% u6 o- l8 w) U, X% r ; Just in case – remove all carriage returns (`r)3 e8 |# m3 O z- r
StringReplace, full_path, full_path, `r, , all
1 X0 _! D$ N; W( | IfInString full_path, \0 K& V/ P$ j) f1 \& n+ D) p" q
{5 [4 h% x: b1 p: R5 ]6 s: b
Run, cmd /K cd /D “%full_path%”
8 ]7 p+ Z* }! k0 A$ c3 }% k }
6 {; m! l9 q2 f) m9 A9 i else
0 \' S* e3 h$ y3 ^ m {
) g! v2 O& b" u$ O; l Run, cmd /K cd /D “C:\ ”+ t( r7 B$ C* M2 g/ o. e
}
/ z' U N: Y: ?2 s& w# ?* X }
/ B9 U5 h; K' a' Q$ N: K5 ? 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。$ |' k3 y5 V; V; G2 B
这段小代码肯能有两个你需要修改的地方2 p5 f$ Y( M" W6 I9 n$ R6 E
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' S, k& b5 U' s6 O' r3 k
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 E$ v! C: [' o" A5 N/ D |