此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。" a3 m, {3 S3 `0 c
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 q* C8 N8 k+ E; Y+ _& h4 S
方式一:* @& F" h3 ]% @2 |, j; \
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
+ S3 U( x3 ^$ K$ E7 }( y2 z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
b. o7 A9 X& k1 l HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
: W& z8 X/ d8 u* J- T U 方式二:
( N2 T7 a% P9 ]" l3 V8 f 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 ~( `8 |+ b& `" z SetTitleMatchMode RegEx$ J, H; V# i$ G7 |$ U( [
return
3 s0 U# ~ V) X9 D; D, k" P$ L ; Stuff to do when Windows Explorer is open2 V8 q0 ~0 r4 n1 y% `- ~
;
# a% h5 m8 V% L e$ B #IfWinActive ahk_class ExploreWClass|CabinetWClass
8 E) }4 s$ n. Z: H ; open ‘cmd’ in the current directory. r" r5 c+ [8 t& M
;6 s7 Q9 r; `0 \, D
#c::
# j1 q1 y. s" x( I& d- F OpenCmdInCurrent()" C2 T% W+ `- }
return
6 S2 O/ d* G) T, y" b4 ? #IfWinActive" \( x7 N1 p4 `1 l
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.7 L$ ~( A) y; L& B0 p" ^
; Note: expecting to be run when the active window is Explorer.
7 v; D; ^9 D. D9 y. B( m2 \* S ;% w3 f7 o& n! G5 Q4 F$ j6 A( ^
OpenCmdInCurrent()
% Y B% i1 F" K& e+ G7 p7 w' b! Q, A {
7 M6 Y! U* ^- q+ j ; This is required to get the full path of the file from the address bar3 Q& z* K) |7 N5 ^" d
WinGetText, full_path, A
5 _, z/ |6 y% E& [; w) u9 j- F ; Split on newline (`n)
3 {# O; v# b& O5 Y- P StringSplit, word_array, full_path, `n" J3 R! d- J8 ~. y
; Take the first element from the array: _" o4 Y# q. S' H' G, r
full_path = %word_array1%
& Z( y6 n: d, j6 U% j ; strip to bare address
% Z' _( [; x& l# F3 J/ Q full_path := RegExReplace(full_path, “地址: “, “”)
. z) Z/ n+ L+ P ; Just in case – remove all carriage returns (`r)$ g! @7 `8 I ~6 o! Y
StringReplace, full_path, full_path, `r, , all
( D K- o4 B, m$ f IfInString full_path, \. Q" S" c7 I: e( l
{
% t U/ \! y4 D' t- o. Y; s Run, cmd /K cd /D “%full_path%”
) ~( h& z3 F7 m+ `2 A. I }3 m1 X* p f c6 y, A S
else* `2 V5 b. d' G( s
{, n% s7 Y6 \ w; Z1 f$ D2 e- \* e
Run, cmd /K cd /D “C:\ ”5 Z9 K- D2 x2 \; V! m$ u
}1 Y9 @- q( d C# q
}( ^' n! Q8 U( m+ U7 f) k, ~
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
! h5 `0 Y! x2 z! Q9 W( L, a 这段小代码肯能有两个你需要修改的地方
$ W: H9 m) Y; G0 b 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键+ f6 m- }! I+ q4 t6 T
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: b; X9 V5 [; `4 Q- L
|