此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ s1 K5 {3 ?( e" U' \ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! h" K1 V5 h% g: ]% v$ `+ r! z
方式一:2 n$ C" k' d5 O6 I# j9 |0 o
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 J" p G1 R: d, [" v/ C
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 _3 N. v. a1 X q1 u! j% _8 E; R5 [ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
& H/ f% H7 g+ g$ x# l 方式二:
4 S9 Q9 ~1 Q' `( l7 p 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:1 x+ b5 c1 @% J x
SetTitleMatchMode RegEx
* s2 m, R9 `! X/ T$ a return5 U8 @" ]/ \9 n3 i9 Y& y( ]$ k+ k
; Stuff to do when Windows Explorer is open' T# [" D: I( i0 I: c
;
. I3 m# g, X/ ~5 ^! g #IfWinActive ahk_class ExploreWClass|CabinetWClass
7 V2 z" M, e4 w+ J8 a ; open ‘cmd’ in the current directory
( A$ y" D! l$ _ ;$ O$ A0 Q2 ^5 x* n/ Q) ~1 Y" M1 r* K, `" Z
#c::; R# ^3 |& i: o8 I3 {4 M
OpenCmdInCurrent()
5 f6 Z0 L, k- |6 ]4 u1 D3 s return
) u& t) r9 T2 R+ y; `, { #IfWinActive4 x/ N$ N9 _# }* ]) h9 j
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.% e8 n$ l0 \3 Q
; Note: expecting to be run when the active window is Explorer.( {0 {+ K' q& _* U* V$ Y+ i
;
, ]& O n! B9 Q( a1 A5 q! d+ t0 N OpenCmdInCurrent()5 [, ?% `2 o7 ]0 e
{
: H/ T: h! y& T& I! i3 r ; This is required to get the full path of the file from the address bar
6 I/ v+ O) F$ Z* W6 ]4 H WinGetText, full_path, A# w6 [) b9 d! Y3 e" F% s% B( Y
; Split on newline (`n)
8 V: w9 V, D4 W" X H! A/ n* R StringSplit, word_array, full_path, `n
- Q! a- v$ |- }, e ; Take the first element from the array7 [$ ?: e9 ^# `% |8 u! Z& h
full_path = %word_array1%! D9 r9 O6 I g* E1 N! j
; strip to bare address
+ X/ Y* e! v" W0 z3 ? full_path := RegExReplace(full_path, “地址: “, “”)% f6 ]* d; T+ e6 }
; Just in case – remove all carriage returns (`r), j6 a0 W1 h/ C/ F4 s# Z9 Z5 ]2 G& y
StringReplace, full_path, full_path, `r, , all
3 n$ p5 p# n& A4 b IfInString full_path, \
/ X3 |. F6 |2 {& ]0 c0 _ {
9 L3 m4 k1 [. q' G Run, cmd /K cd /D “%full_path%”
, @+ [% K$ s# o# I! r }; h$ s6 X! \" N. Z' J
else2 u3 ~# y+ N( U3 w$ ?- _
{- v+ L" l9 O: j) f6 g
Run, cmd /K cd /D “C:\ ”
# D+ y7 p. `) P" V& y. X- B0 e }& B) \! y3 c" Z+ s, F0 f
}2 G5 O; a- ?9 U, Q# ?7 a
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. ]6 W- R6 P& H 这段小代码肯能有两个你需要修改的地方5 @' x1 G- a2 J3 M
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键. e1 i0 q& j( d3 Y
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" j. \% W& L$ X6 b4 I: k |