此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
/ v0 T/ ]& v6 b5 x' ] 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 [' D3 L+ P r$ h, J 方式一:
& X; K9 Y& q( G# i7 ^) C0 Y" _ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,6 M! j8 `4 ~9 N+ X
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和- Z# [" }# ]4 K; T' i( |; }5 ~
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
6 C1 s- T) ~1 j3 o3 K \. }$ k 方式二:+ W* y; ?' c) _5 {
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ [* c7 x: _$ C a0 I9 P6 n SetTitleMatchMode RegEx
$ n$ @( I/ i- m* D: w return
3 D8 c5 {) o1 @4 v; u+ s9 z* z* o ; Stuff to do when Windows Explorer is open2 b( n9 J2 ~5 c8 @: d- j
;
: O+ x4 L$ B# Y J! y #IfWinActive ahk_class ExploreWClass|CabinetWClass1 C7 [7 `) s# }- [
; open ‘cmd’ in the current directory5 }! Q" y0 |* T
;
) V _- d1 w7 Q* a3 |0 a) X #c::& u& ?6 w5 c& l: _ {1 O! G- t
OpenCmdInCurrent()
/ v: E+ }) D5 M7 W5 }% O- { return" j4 r! f2 f2 Q! y$ z9 A+ S( V1 u
#IfWinActive
. j6 A: u/ w$ \2 h ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.% O6 y* {& N! \" k6 V
; Note: expecting to be run when the active window is Explorer.
+ S& V9 p$ y$ r4 d ;: A7 \9 `, K t+ l/ |: x
OpenCmdInCurrent()# I5 y$ \ C6 G$ a1 J8 T7 _3 X' E
{. w, i6 T3 a6 x
; This is required to get the full path of the file from the address bar: I; r- ?7 }! j( Y+ F) v* D5 Y
WinGetText, full_path, A8 J+ x1 c! L7 c% J8 k2 k
; Split on newline (`n)1 d3 D+ k6 I9 ?$ L9 h
StringSplit, word_array, full_path, `n
) a+ j( P2 Z5 X7 Y: @( R4 f7 @- Y6 N ; Take the first element from the array
' a( l# X8 B: f7 ~ N2 K3 T full_path = %word_array1%
+ N* n. I$ ~2 c ; strip to bare address
% L" |4 C* [2 O) b0 C full_path := RegExReplace(full_path, “地址: “, “”)% Y# i4 z; ^5 |
; Just in case – remove all carriage returns (`r)
, w( L- c3 e& R4 `# u5 S) D StringReplace, full_path, full_path, `r, , all1 Z$ }( o, p* V) X2 q
IfInString full_path, \
0 b2 Z0 Q% x$ `6 ? {7 [: R" @( a! z' W/ q3 ?( @
Run, cmd /K cd /D “%full_path%”; Y# U" K6 ^; N/ ^ U
}
9 J6 w, w! g; o/ G else( J1 g) s5 k) i, }1 x0 x! q8 f
{
: K+ m' i0 x5 R/ X" e' G Run, cmd /K cd /D “C:\ ”8 E/ W( D, X1 ]% i! i+ |+ e
}. e" _% [2 G; H3 u& E* c/ m. J4 r1 B
}
% x: D8 ]' l$ {) P% M) H 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。+ F* r1 Z% f3 p+ z; B
这段小代码肯能有两个你需要修改的地方 _1 g! N6 B- v. h! B/ j& V
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' n; j7 o: `; R$ I; {
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “/ ]$ M; q6 u7 [' ~* k
|