此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 G! ]. l$ L) E- d+ L" N
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ O7 i, T* m8 H% x% p6 { 方式一:
1 k5 J- c5 |5 i* G b/ z' g 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 T9 Y% ?" e+ n9 x7 N0 ^
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和. {( G8 u; D; a/ D2 x
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。* [. b9 J! I+ I( Y- M0 y7 y* N
方式二:/ x* m* P( b6 M) ]' k; z
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: `; D. C* Z* p
SetTitleMatchMode RegEx
' q1 Y" K, M0 m z return! I5 z+ h3 F6 m! M$ S
; Stuff to do when Windows Explorer is open
1 u6 o9 H+ V: H$ Q ;
: G5 H$ N5 G* U# ` [. o3 r# n$ z #IfWinActive ahk_class ExploreWClass|CabinetWClass; W1 s# S1 j7 c6 Z% Y
; open ‘cmd’ in the current directory4 m: b# K( }; Q
;
/ j8 W% m# m) L5 P7 b #c::" y0 Z& o) L2 t: F& ~0 \) _/ `- H/ e' o
OpenCmdInCurrent()
/ \- u# S R( n: \! ^. _8 [ return6 j9 I4 e9 \8 H* |2 U) T0 S6 [6 }
#IfWinActive; e. [! `! g. l- ?2 S! O
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.+ e9 d7 J( q! f+ N" E0 l( i3 e
; Note: expecting to be run when the active window is Explorer.2 g. y1 g4 p$ ~0 D8 M' @# f
;4 }* B; p. E1 b; S
OpenCmdInCurrent()' ~$ A* W* F( q- T. @* |6 p8 b v
{
) M- h7 h& f/ X& l) N! C ; This is required to get the full path of the file from the address bar( ~$ K- k5 `& i# {7 s# z
WinGetText, full_path, A
# N) L i3 E, q4 b0 T ; Split on newline (`n); x# ? x# [$ V1 k2 P! C0 ^
StringSplit, word_array, full_path, `n+ E: e# F( h3 k$ _
; Take the first element from the array
2 m' L4 o2 F6 E. x full_path = %word_array1%
; H- x4 N7 `1 }9 R$ \ ; strip to bare address
7 Y4 z1 E m) U* Y, `2 t3 r full_path := RegExReplace(full_path, “地址: “, “”)" }$ X6 ?5 ^$ B: g0 s: B$ P- X
; Just in case – remove all carriage returns (`r)
6 y$ ?9 z, c. f3 ~ StringReplace, full_path, full_path, `r, , all6 T0 R: j9 x6 s* O8 B( L
IfInString full_path, \
( ?8 E( A) c" \ {
/ Z) c5 W# L5 x. A7 P' _ Run, cmd /K cd /D “%full_path%”' y3 J" M, s; T8 U8 {" G; a$ `
}
. s3 @; [; T- N0 b# h5 L$ P else' {& X5 _$ b7 Z
{
1 g( ^! f* @, p% l- V5 C Run, cmd /K cd /D “C:\ ”1 h/ b/ ~& `+ i' L0 D1 ^( j
}
. s( f- ~+ g2 P$ c }
) A4 Y' @, e. w# n/ b+ q* w 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* x' g9 c* E4 `' K, u4 H 这段小代码肯能有两个你需要修改的地方
& d8 c7 F# P. X7 e$ I 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键+ y2 o' c! h' O& x5 M. X% v: w8 |
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* S6 E' l7 z4 w, ]5 k' W6 V# } |