此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。5 Z5 @6 X, I; W3 o+ |" t( ^9 _
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。/ N6 N3 N) e% @) ?
方式一:
Y, b4 a4 R. n6 h; p) |" L 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
* Y+ E& a: e B 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, l8 j8 ]7 b" n6 N6 u; o7 p% i, I/ k HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) a9 H( \: Q0 | 方式二:! \- ?: Y4 E" [' U, i, D
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 B4 h# v1 M+ I/ _8 f1 [
SetTitleMatchMode RegEx ]* ]! `9 d& i% W: |# }" O
return4 g1 o& a# g& b" d& z, U/ \
; Stuff to do when Windows Explorer is open
& v1 ^) m2 D; W2 O ;5 C! g- N& r) Z d$ A
#IfWinActive ahk_class ExploreWClass|CabinetWClass/ f/ F2 s# W8 Q: Z; n
; open ‘cmd’ in the current directory
# c) B7 V# v( A) J( n ;
8 t/ P, |' \9 X7 A' { #c::
# i# I9 T( I O. j g4 d, w: E4 R OpenCmdInCurrent()0 C1 X& e/ ^$ F4 h9 V% y
return* e4 B* M" a b6 z$ a. g, C8 A0 Z
#IfWinActive
7 d0 e$ ]& ]: m2 D* C4 b; `0 | ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) m$ {2 }# }5 H ; Note: expecting to be run when the active window is Explorer." }' d1 ^* J, L: {& M, B) v
;
7 L. N: O- Q. S# l" a% Y OpenCmdInCurrent(); U# o/ s7 W6 z% D
{+ b% H7 p) h) K. u( x0 o% u7 E% ?0 t
; This is required to get the full path of the file from the address bar8 _# k, Y1 _/ J
WinGetText, full_path, A
' b, e$ h, n9 e; ~ ; Split on newline (`n)' c d( b: R) B( T- u: \, _: O& Q
StringSplit, word_array, full_path, `n
( k* ?6 ]$ M6 ?2 x V ; Take the first element from the array
9 V& P1 t& h, ~) j$ o5 O6 g/ r- A full_path = %word_array1%
& s) ?9 m I9 W2 m9 L: {4 N( D$ L ; strip to bare address
" M0 \7 g* S! H' E, t full_path := RegExReplace(full_path, “地址: “, “”)" g4 o9 F3 s! `+ D. y
; Just in case – remove all carriage returns (`r)- v" H! ~2 }" m0 w. b% j! f' H
StringReplace, full_path, full_path, `r, , all& H M K+ [9 h/ V- @$ G
IfInString full_path, \; R; C% F! D2 N9 X
{
1 T3 S; \9 F* n5 R) S9 u Run, cmd /K cd /D “%full_path%”: [2 v( t( @; O! L. s( T1 Q. O
}8 z4 @0 ?; F* z& j* p
else
% M$ N, G$ {: D9 i( O% Y: l/ v {+ R1 D8 P4 X3 l3 v
Run, cmd /K cd /D “C:\ ”# m9 p& \1 j6 l$ |5 n
}
' A C; @* H. q }2 ?* s3 Y& g7 E" X& s+ Z8 o$ d
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
) G. C: X2 r+ z; N. @ 这段小代码肯能有两个你需要修改的地方
+ k' T$ f* q/ x0 m) x1 A- v 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) R; @' ^" m% u% X3 A! D 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, S! T8 s# d4 \4 g
|