此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
# W; N' X/ f+ G) Y% ~2 i 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。1 }) i4 M" d5 K) D8 ~! S
方式一:
! i2 H8 H& }* b3 b% h& o9 W% }7 A8 Q2 G 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- Z; Y( M7 W3 W" c% y8 A
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
' `' \( L$ [: b, S4 {5 I# v HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
9 w% Z2 @" w4 y& M$ ? 方式二:
' O+ n! k$ j7 p0 B- G 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 T: r- r) n7 _/ L
SetTitleMatchMode RegEx
( W6 X8 X9 T7 |; Q4 J \: \ return1 P* d5 o$ j& E
; Stuff to do when Windows Explorer is open" a$ d% H: E& g& y2 l3 K. G+ ^
;
9 o q4 s, x! W9 k* ` #IfWinActive ahk_class ExploreWClass|CabinetWClass
8 H( y; W* t& @5 V& k! ?* F ; open ‘cmd’ in the current directory+ r4 c% P, g2 H0 T& a( u
;
" @. e4 X- S8 d6 H+ N$ ^$ d D #c::
5 y, s1 R! U1 d0 I4 q; q OpenCmdInCurrent()1 N _; H4 W/ o1 i
return
& Q9 Z H/ s% y2 z, C #IfWinActive
( v y# q9 y1 y* C& }( ] ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% p8 m; [1 ^1 T9 j5 } ; Note: expecting to be run when the active window is Explorer.2 h% x# e; M6 Q+ k! p
;
% H* l; i' X7 ?& Y: b7 D OpenCmdInCurrent()
' X9 c a* e ] {
9 |$ L7 a- Z* v3 Z: U3 c8 K ] ; This is required to get the full path of the file from the address bar
& U3 G$ v" G4 o% C$ A WinGetText, full_path, A; `9 d g' h) v8 w
; Split on newline (`n). i U; |7 L/ x0 T
StringSplit, word_array, full_path, `n, _8 V3 D& j) _
; Take the first element from the array6 v1 o/ |* D0 ] f o6 S
full_path = %word_array1%* E ~% w5 o, A; |5 M2 K
; strip to bare address
/ V) z( L8 q- p# m! x$ w* } full_path := RegExReplace(full_path, “地址: “, “”)" f: B# ]/ Q& [2 F8 i0 @
; Just in case – remove all carriage returns (`r)7 N9 S/ M/ Z! ~# p
StringReplace, full_path, full_path, `r, , all
) }6 P- Z# B+ m- H$ L- {6 ]: Z IfInString full_path, \
' c/ J% g# g+ G! c( N7 I7 }$ E {
! W! @4 j1 E/ M9 T* ^/ F% B7 n Run, cmd /K cd /D “%full_path%”* T; j' o3 S% ] e9 q
}
5 h. ^$ }& G2 B" y- i& f else& P. G$ f2 h( Y0 ?2 p) y( B
{0 s1 y) }1 r o
Run, cmd /K cd /D “C:\ ”7 \3 M* g& V# L4 a4 C+ j7 y
}
$ `6 J' E# }$ N2 Y+ x/ L/ A }
* B7 q" q0 l, w 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
" A3 y7 \- T" R: m+ k7 S7 o 这段小代码肯能有两个你需要修改的地方
( F2 l, c- l' ? l 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' Q$ a% s+ T+ D. a+ M6 U 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “0 T- \1 G+ A3 t8 O6 U7 P1 G# k
|