此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
: X, f- o6 N/ }, l 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ \$ T+ }* N" M* o% E9 r/ W1 ] 方式一:0 y% U% \3 _- v4 p0 v O1 q; k& m
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, v$ K3 [- @$ [, U( V
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和$ `% D) ]# l4 @8 d6 b& w
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 S$ z J7 }9 k% d! g 方式二:
+ B( L% r0 |6 G) q* _ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
3 d* I* J5 c3 s4 j SetTitleMatchMode RegEx
/ r! c, |( s; x9 M9 | G1 I' T return
: X; d" N6 o- k( w/ L ; Stuff to do when Windows Explorer is open/ t3 U; t, U I) W+ G4 w% f0 S* G& b
;
9 V5 a, t+ ?# g; J, N9 i# q8 `) ~ ` #IfWinActive ahk_class ExploreWClass|CabinetWClass; L& `7 F$ r m1 n( I. u
; open ‘cmd’ in the current directory. E' Y! h% O6 t. D$ O0 P
;$ l# \0 a" G; p% a& @: o7 U
#c::
! T, g" m1 O- D OpenCmdInCurrent()
, T$ ^5 x2 v$ b# a4 ?: ?" E return4 Z7 j/ k! x; h8 Y; A% ?5 Z
#IfWinActive2 D* J2 A) b3 M2 X6 p
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.1 {$ T; X W, B6 M8 C5 B
; Note: expecting to be run when the active window is Explorer.
& P! }# l6 B( f/ K) R* Z5 ~ ;6 l5 b* K% e/ `: \! K; a% C
OpenCmdInCurrent()
( w3 \% o+ H% I* N {5 N, i: q4 V) @0 |* Y% P
; This is required to get the full path of the file from the address bar0 Q+ h" \: n; ]) g
WinGetText, full_path, A6 G5 @6 e% G2 }8 `8 @! N# u/ ~
; Split on newline (`n)& B- h9 i* F. N ^: }
StringSplit, word_array, full_path, `n
6 x8 W6 R5 n2 E2 ?+ P" t ; Take the first element from the array/ S/ ^- d v9 i, c8 ^' d
full_path = %word_array1%
5 V1 X6 Y0 f& C, Q ; strip to bare address5 |9 V5 A" R. l% Y
full_path := RegExReplace(full_path, “地址: “, “”): M9 [( Z5 k! J) |2 Z# Y# Q! `
; Just in case – remove all carriage returns (`r)
+ O2 g7 g: n0 z6 H/ m7 ]( Q5 D StringReplace, full_path, full_path, `r, , all- c7 J! A' C; w6 O3 n( b$ S- j7 b
IfInString full_path, \
" ?% n' p0 I, I/ C+ S. a {
" m3 S; H, s$ R6 | Run, cmd /K cd /D “%full_path%”' k0 h) U, ]# R" V- F: _
}
* G8 w `& O! q0 |9 y- t else0 [) |: s2 V* K) M
{" T! c% r* L4 O
Run, cmd /K cd /D “C:\ ”! s% ?( A$ M# [- y/ Y/ ~
}2 L. H R: w0 ]$ B2 N, L+ o) Z
}
' e5 b3 @+ h6 s# F- F. B: R 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。; ]( P p( V0 E8 }; F! w
这段小代码肯能有两个你需要修改的地方2 ^; N* B, D. N+ D8 w& C, ^
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ w0 N& F* v) K 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
5 E7 c. F7 Y! u |