此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。* X7 l3 C% O5 N) }
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。+ ^- l+ H5 b7 V& X- P+ E! f& A+ l
方式一:
, ~. H; x ?. b0 a 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
$ o, \& N9 [; \3 | 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! B+ ]/ Z/ h6 c: G HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ P/ ]8 ^( L: n+ d3 n$ R 方式二:# W0 A, N: s- d9 M
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" ?1 E7 K, l1 x5 X* p SetTitleMatchMode RegEx
/ L7 o) f2 P" Q0 Q/ a1 k return
3 {: M4 r; M' w! x, L; I- U1 ~9 Q ; Stuff to do when Windows Explorer is open5 B4 F* y7 Q7 x* E1 m9 s; z5 M# {
;
8 ^. r' t% X# S& d #IfWinActive ahk_class ExploreWClass|CabinetWClass X2 K5 N* s# g* u" D8 R2 h
; open ‘cmd’ in the current directory$ R b2 E* J$ A( g# c i
;
) R- P! Z- x4 d. T #c::: u( ~( C4 r1 ?4 Y
OpenCmdInCurrent()
% B( S! j1 y0 w7 m n; T return
+ C5 E# X& ^( A0 ` g #IfWinActive: f! ]# c; b( F/ q* I! B
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.! T4 i6 L! F; x
; Note: expecting to be run when the active window is Explorer.: x) O0 R9 i' q9 C: {+ A- c+ z
;
% j! q# W- ? P* ]. f6 a- k$ [( B OpenCmdInCurrent()
% x' H0 F) U; J1 ? {
3 k& @' Z/ c1 \$ i0 g ; This is required to get the full path of the file from the address bar
/ c; N& K! L1 E, @: K( i/ J( B WinGetText, full_path, A. a! ` Q' @* P7 s! v0 N3 n
; Split on newline (`n)
; r) X k/ K. T, R% q/ z1 q4 ? StringSplit, word_array, full_path, `n# X1 }8 w! f( [! |5 [3 g3 B7 _ c
; Take the first element from the array
- U. K9 A* G6 ]6 a/ z* ?, Z full_path = %word_array1%: g/ m( @: k# }$ M, }
; strip to bare address
' O7 S0 }" ~2 A, u o full_path := RegExReplace(full_path, “地址: “, “”)
" |5 c$ H, P( Q! ? ; Just in case – remove all carriage returns (`r)# K" x- \0 D! I
StringReplace, full_path, full_path, `r, , all5 t( f, d" b% K1 P; {9 }# o' E
IfInString full_path, \
; z- }- g( F( ^9 p, L) [ {0 o$ j$ S* Q: n2 ^: @- w5 l
Run, cmd /K cd /D “%full_path%”4 n& H" f- X1 ^4 ]# n
}: J! {5 x( I! ?3 H" Q
else
* A* B! k1 n4 ] {4 N' s1 o- d% E& x( {
Run, cmd /K cd /D “C:\ ”& ]! n+ @3 w( g3 X; D4 ?$ e8 Y
}
; k) O6 A+ ^* t3 D% f% ? }
8 l, u5 H% t+ I5 ^ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 m) x+ ^; R1 a% i z8 G
这段小代码肯能有两个你需要修改的地方
: v: ?( s) ~5 q' X8 \( ] 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ F- }4 b$ I$ |7 s) ^) V* k
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
% G& P, \: R! q. p# N! g |