此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' y8 Z; C) O/ n% o6 { 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。& T1 i# d: {) A: x: ^8 ~4 b/ A: s
方式一:
# g2 ^' u2 `$ f 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
* l4 c: J- L! a, d8 e! l 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和& V" u7 A, h. |+ i, t
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。, A' t$ y0 X. J- ?
方式二:: X) O6 K; r/ |" E( ~# q$ ^
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# M2 u7 W! k9 {+ c) L1 k SetTitleMatchMode RegEx
$ n# c3 r# u3 X6 z4 K: S return
0 c- J( @* t6 Z, I- Q, I$ d ; Stuff to do when Windows Explorer is open
1 E6 N7 n$ Y: ~- ?, q5 @ ;
( x7 Y8 T: a* k/ |. }. T$ y& q) m #IfWinActive ahk_class ExploreWClass|CabinetWClass
4 _0 S* C% M, A3 {) B9 D; s( w ; open ‘cmd’ in the current directory T7 ^; _4 I& J! q8 X0 r( B9 }
;
7 F3 G4 p5 i& k" q #c::
& |1 x- S9 R6 n; m; R/ ~+ O& R9 b OpenCmdInCurrent()
2 T6 Q4 T. J ^; M return5 P2 s W7 W( X
#IfWinActive
( f, r0 f- r T$ \ f/ A ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
+ M* x: z3 ]+ Z' e# q2 t ; Note: expecting to be run when the active window is Explorer.- k V8 o; a# t5 i
;6 p: {( r4 A6 `( ~
OpenCmdInCurrent()" @3 {/ X( Z7 R, N
{5 g: Z( a- }* q, ~5 G
; This is required to get the full path of the file from the address bar1 g! O' t+ U/ p0 s$ E7 ^
WinGetText, full_path, A1 h% Y5 G* ^# h) m: V! @( [$ k8 [
; Split on newline (`n) D) Y6 \ Q0 x
StringSplit, word_array, full_path, `n
X4 t2 N( u6 a4 a& d4 `2 } ; Take the first element from the array! ^/ o: m% F, s0 g
full_path = %word_array1%+ A3 D8 v- H2 o. _- M9 {# o
; strip to bare address
. W# a$ ?. U; y3 s* D7 k: E& `! q8 W7 W full_path := RegExReplace(full_path, “地址: “, “”)3 D: ~2 h+ _5 a
; Just in case – remove all carriage returns (`r)" [4 L8 g/ u: x! U
StringReplace, full_path, full_path, `r, , all& ~- u! H& _1 {6 S& G' o9 n
IfInString full_path, \
( V, o* ]& d7 y/ Y3 l/ s- } {
, n' y1 P& h8 M' E- P( Q Run, cmd /K cd /D “%full_path%”
) m7 Q! m$ m; W8 c% f( z# K }; A2 a& b2 P8 A6 e
else
" r& R1 s2 R7 X" ?& h {9 c8 M& L/ p% e8 V& L& p
Run, cmd /K cd /D “C:\ ”
; T! x( F7 k% D. m5 | }/ [! E% B% L+ X5 l$ ^
}
0 s& G/ T; s* b, A! @ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" P# T& A" {! T/ y- B
这段小代码肯能有两个你需要修改的地方
! ~' Y1 C. s/ M' U" F- k3 v 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
4 u8 j7 Z) X# c 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 F1 B/ s+ z' ~ |