此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% e- j& P: A8 F8 _0 } 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 v! Y( {7 W! a! Z9 i
方式一:. o" t# |5 s! u+ g
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
( e) a" ~# U1 j- \" u/ t' Q7 z1 } 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
% y& R4 B, Z, J: D2 ` HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。 z& ]6 E+ f9 @6 {" e6 [
方式二:
+ y! R/ x9 t/ H. c7 w( ?5 @ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
4 x( _' k- T) n! d SetTitleMatchMode RegEx
& l% Q0 ]3 Z; w( I2 C6 R return
$ m+ u) F; e8 A: l$ ]! V& `* m ; Stuff to do when Windows Explorer is open# O/ {8 p, m+ x
;" A0 |/ e9 U. J7 l5 i
#IfWinActive ahk_class ExploreWClass|CabinetWClass
9 `* A- A# p! Z' ?- U7 h ; open ‘cmd’ in the current directory0 B( j% E; A0 K& X& F- u7 _
;
5 ]# U) p* }9 v3 O- ]$ B #c::
9 R+ ?# s2 L9 F5 ~1 x OpenCmdInCurrent()) n( t& P. `/ L A5 p6 a
return3 q w) Q: S" Z% o$ p6 {
#IfWinActive
$ q( O7 H( N! `6 u8 ` ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) i6 ]& t9 c1 y3 w% j
; Note: expecting to be run when the active window is Explorer.
& }' m" _, |* X$ S3 t- | ;
( U$ r" t) f: Z. j! {8 Z, I OpenCmdInCurrent()! M. Y, q* v! L$ G |6 i5 m: g2 X
{4 M, }0 U& Q& g) ^4 }' ?4 z
; This is required to get the full path of the file from the address bar
3 {5 Y4 X( C* f WinGetText, full_path, A
: N5 J5 A" J, Z" h. J7 q ; Split on newline (`n)% P* U' Z. ?: e' c4 u
StringSplit, word_array, full_path, `n" B% q! o. P! \/ y2 `
; Take the first element from the array" R5 \; q/ Q# R
full_path = %word_array1%, @9 k- g$ H$ C
; strip to bare address2 w, T1 B8 _; S0 v& m
full_path := RegExReplace(full_path, “地址: “, “”)) x/ n3 `& ~. M( q, x. J# d
; Just in case – remove all carriage returns (`r)
4 r- b7 j# i: Z3 M Y `, _ StringReplace, full_path, full_path, `r, , all
4 n: R7 m9 H! o' [! n- S IfInString full_path, \- {6 d! N% G3 u
{
; n* r4 d+ k. D) b. S( ^ Run, cmd /K cd /D “%full_path%”
" R2 g% L4 f9 z2 u$ [3 Q }
3 E8 i* d$ s' I5 U) I' D/ T6 p; a else
5 ?& d. \6 u# ~5 ]* y {
. C/ \( o& d/ U1 g! A* m# o/ c: ~ Run, cmd /K cd /D “C:\ ”8 D2 T: N% i T4 V
}3 g4 M1 b7 l( `. Z
}% H' A& L% _! y
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。+ l; K8 J* j5 N/ j# F
这段小代码肯能有两个你需要修改的地方
9 V- h x( Y! k7 E6 Y. z" [! A 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
4 F" ^5 v! `- j$ S5 H4 Y* @" [ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
6 V. j9 m$ Y" F |