此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
, n, E7 r; J; ^. }6 n7 h2 m# c 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
! ]5 I# z4 ~8 p 方式一:! ~3 t5 d! @9 n- [
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ r' g5 W) ?; f* e- N/ `. x P
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 D; e+ w! Z) ]# T5 l1 Z% Y HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 A ~, R5 v6 U+ W/ l; s* `
方式二:
+ [% w1 ]: Z0 F I 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( i/ r- p G2 K2 ]7 @. } SetTitleMatchMode RegEx" e# f- }9 K# j( }& |9 Q+ j
return0 i! p3 E0 H. {9 Q; k
; Stuff to do when Windows Explorer is open
" i: K8 B: T& t/ w* }* n ;5 M; h% Z% E: u1 D1 o1 x
#IfWinActive ahk_class ExploreWClass|CabinetWClass
2 Z! ~3 b0 W- L ; open ‘cmd’ in the current directory
* U7 {6 m& w. l6 b0 u8 E ;2 U" p% E- O8 D( Y* F8 j
#c::
' Y* r$ F# d1 Z6 a OpenCmdInCurrent()
3 |8 o, d; d; {; F( D' w3 J2 \% S return( L0 x* I5 K1 o3 N. X% u e: N0 @
#IfWinActive
: w. g5 v' R( }3 `! \% p' l! j ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) B8 e. S# r# d9 O$ K r/ P7 J, l ; Note: expecting to be run when the active window is Explorer.8 n b% i1 m. N$ n) [- M8 B
;
: Q b7 _% \# Y5 s: ~, i- b5 b OpenCmdInCurrent()7 v( r0 s# F; |4 H+ n2 N+ R, K
{- E1 E6 a7 `/ [9 H2 }! @
; This is required to get the full path of the file from the address bar
( H/ ?/ ~6 P0 T! y3 A" n0 N3 _. o WinGetText, full_path, A
8 U2 T+ ?, V. X0 B! \ h L ; Split on newline (`n). `2 B4 l" G# b
StringSplit, word_array, full_path, `n
% b$ C. v# o+ G7 V# O ; Take the first element from the array
# s; C2 r9 ]1 M6 n" H full_path = %word_array1%
' T; v6 z; I# { _ ]& k- O ; strip to bare address
, h3 A7 e! o" e full_path := RegExReplace(full_path, “地址: “, “”)
; X* I2 z0 H& S$ f9 X ; Just in case – remove all carriage returns (`r)/ e( I A8 l2 p% p
StringReplace, full_path, full_path, `r, , all
; f) ]4 H T* a8 I IfInString full_path, \& g& G( l6 {' Q' X$ B( ]
{- _! H8 A! ~% W6 D
Run, cmd /K cd /D “%full_path%”
% h* j# h% Q: D7 ]; x$ V }$ I' Y& r& t2 R0 V) f7 |, J
else2 |3 p$ R9 m1 q _+ e" Q
{
L+ ?. E; O% }; t Run, cmd /K cd /D “C:\ ” S+ g* K. S; J& j r) p
}% `/ j ]. g5 p& L
}
" E. q2 `4 U+ S8 _/ v& @3 Q9 o 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% |& n0 Z$ V8 O7 [$ F4 `* B* v
这段小代码肯能有两个你需要修改的地方* B6 O' s3 Q z
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键2 m4 m) |3 o* Z* r0 }9 U
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
- G9 V: ?) @, B |