此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% L. k" E- F; e! F Y 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 _ p+ ^1 S- ]! A- N8 F: { 方式一:
; R. c+ H9 s' k8 i6 r 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 e1 t- _7 e% J3 s! R5 `/ | 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
6 q7 c2 T0 _% d) E; |% N HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
6 l& T7 }; q4 {4 d$ M, r' } 方式二:) l% c8 m+ M! A# p) |
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" _& d0 y) z0 L5 E2 b SetTitleMatchMode RegEx
& ~9 T( q1 ~* Y- l$ E return
5 o; {+ W( |3 g0 m Z/ n0 N ; Stuff to do when Windows Explorer is open3 u, b1 A' m; O1 c+ U6 G/ w2 C
;
: m& n/ I6 |/ @2 j* }* Z" p% [ #IfWinActive ahk_class ExploreWClass|CabinetWClass( _+ u/ G1 \* v' |! `4 M
; open ‘cmd’ in the current directory! ]" [( z5 H% H; x% H0 B
;/ ~+ T3 y6 v2 G& P3 G8 r: W4 i D
#c::1 Y( O3 |0 y; ~
OpenCmdInCurrent()# J7 S, C3 X6 G3 y2 U6 z7 @
return
2 l0 k$ f6 U8 p #IfWinActive* P3 x; N1 [" Z! G$ ]
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
; D/ {* T) {$ ]( Q z# G) c6 r ; Note: expecting to be run when the active window is Explorer.
5 M( U: Z& H1 t ;
$ V$ l# j0 D# k$ n! s OpenCmdInCurrent()
+ Y1 E0 S+ n; X& i2 |6 ?% V7 Y$ I) U' @ {
' i, U& O* s% n' ] ; This is required to get the full path of the file from the address bar
' d% X. X5 T0 T WinGetText, full_path, A9 n l" t+ h X4 e/ K% v# G
; Split on newline (`n)+ t# x% e& @% `* k2 g/ l& N
StringSplit, word_array, full_path, `n
3 K. Z* ]: a$ J- F4 W, U ; Take the first element from the array
s. Y; ^) F r1 r! @" t9 K6 z( L7 r full_path = %word_array1%
5 ]8 y, S3 M K5 P" n8 p ; strip to bare address
- \ `& @+ t8 \: I# V full_path := RegExReplace(full_path, “地址: “, “”)- B! R: Y- i T" x
; Just in case – remove all carriage returns (`r)# _5 p2 R7 I6 `) s
StringReplace, full_path, full_path, `r, , all4 P. |! v" q0 b; ~- U% g
IfInString full_path, \# ~% H \9 S/ I* |! H
{ w+ R" c7 A) V: g7 F$ r
Run, cmd /K cd /D “%full_path%”: m6 r$ Y' s7 B0 j9 u7 e3 W1 H# L
}0 M! L9 {$ }3 |5 i4 o$ W3 O
else
, W1 v0 W0 @ w1 {& J1 t+ y6 ] {# W- {, j3 m5 B& M1 F4 t" B
Run, cmd /K cd /D “C:\ ”
8 \7 R; w9 h! S }- p! @$ V. e7 l0 I3 ?' R
}
+ b' ?/ G1 u6 Q! w) g 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。; Q$ p+ e6 ~ B/ `+ P3 w+ ]
这段小代码肯能有两个你需要修改的地方
5 C; ~* k8 k+ ?! V. z0 h7 E# A 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( w! t! z, t& ]' Z, h7 G 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 q7 A7 |' e6 Q& S
|