此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
: J: E7 O0 b0 L8 e) ^ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。$ [, b G1 P& t1 j4 r" X
方式一:
# u9 j+ n' `5 k3 k# G( }9 J 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 l8 s+ H, j4 p9 Z' U( \9 L 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 e/ Z4 k. z4 S) H8 v) A HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ y& [$ a" q; O
方式二:2 ~; w6 R' C; b
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 R( v* k* E5 |2 ?" ^# U* G
SetTitleMatchMode RegEx
$ R" _$ O! U8 a* o return
7 U; g6 r) l1 _- r ; Stuff to do when Windows Explorer is open
. r- k" H. ^# v2 X ;
* r ^! n& t# d5 { #IfWinActive ahk_class ExploreWClass|CabinetWClass
9 N1 L, ^8 j3 ?! Q ; open ‘cmd’ in the current directory2 h; H q* U7 y. p5 K r
;
' N( N, u! p! k1 s* { #c::
+ E0 P- b2 S& X$ H% f+ _( W4 Q OpenCmdInCurrent()! L! o5 J5 K& Q' Q! d
return
! L4 b, M5 G4 ?; U #IfWinActive
7 ^8 F8 a% m" @, I ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.- O2 u3 X; J; q( f0 |) Z2 r) w0 R! U
; Note: expecting to be run when the active window is Explorer.
% [9 F& F& a5 o( }( m. a. Q ;
7 Z3 e" k) }7 e OpenCmdInCurrent()% M W4 u! T2 j/ E
{- R& [$ g3 e, m+ j5 @, K9 E
; This is required to get the full path of the file from the address bar
( B; |2 X- a w- q3 \ WinGetText, full_path, A
$ }& ~/ [; l: y, c5 t ; Split on newline (`n)
1 [# G: S. n n. F8 j StringSplit, word_array, full_path, `n
. D( b b7 p; r9 i ^ ; Take the first element from the array
4 A8 O9 a0 @ E1 Z& C full_path = %word_array1%$ C) ~4 f2 [' B( A* L; ~0 Q3 P
; strip to bare address7 n; b( }7 ~9 c; n2 u
full_path := RegExReplace(full_path, “地址: “, “”)" @6 v* }) t& B3 @
; Just in case – remove all carriage returns (`r)
8 D8 ]# ^; M8 `! l9 @ StringReplace, full_path, full_path, `r, , all# a8 {3 r% ]* P% w/ E# H7 H
IfInString full_path, \
* |& l2 x' w8 r& m9 u2 Y F- [ {
: d: ]6 Q) v { Run, cmd /K cd /D “%full_path%”' D/ {" t; c ~5 W' e# I* C
}
% v5 I# ^' u' ?- Y! z0 Q else ^# \2 n- M4 f
{ O4 }+ ^2 i0 R! E2 [% c
Run, cmd /K cd /D “C:\ ”+ B' M( v; G! J
}9 p9 F* `( d0 M* j1 u z O) O$ w9 j
}
7 y% `* f" m+ a) x# e4 N 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
7 X ^- ?' z7 o 这段小代码肯能有两个你需要修改的地方 [2 U. q$ V' K1 N: s( Q
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键* ]0 L6 v1 }2 ]7 _/ u, V
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ g6 v" r" C* f6 T s |