此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。1 H3 z+ V; q/ l( }* D
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
& q% O2 s% u" i1 K1 B0 W/ }' q' c) w 方式一:* R3 c; x( a8 v- _$ }4 N
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 S2 ?2 E ~6 ]6 E6 {* Z, y F7 J 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和; i3 h* e% q0 o0 X* N g4 u
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 c( _ s& E5 h$ a9 {* Q
方式二:
2 ?9 Y6 ] L2 O0 Q2 A 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
; a8 \- L. H' L" C i( s& S SetTitleMatchMode RegEx3 W5 V3 |. a: a+ K+ [$ m! n3 h, e
return" e! M2 c7 b& ?6 g# X
; Stuff to do when Windows Explorer is open% i4 U- I$ T- g/ ]
;
- y, X$ K/ [$ J) n& @ #IfWinActive ahk_class ExploreWClass|CabinetWClass( V+ Q' r& V7 G: w; |3 C
; open ‘cmd’ in the current directory
, a2 j8 k e& ~# H* M) N ;
0 Z5 R n! t& T' ?0 l% n6 f8 { #c::) _6 t1 `9 X4 C9 z8 k9 D
OpenCmdInCurrent()" E" z! t- V. Y' x6 I" t
return" }& i7 J8 F2 I: a; q6 t
#IfWinActive
/ x. h( E3 F8 S. ]8 k/ |* H6 I ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 _$ C8 s+ @: D
; Note: expecting to be run when the active window is Explorer.
5 F% P2 ^6 X, u/ \ ;; ?8 S. Z6 h, \
OpenCmdInCurrent()( f, f+ f% b5 Y- p& O/ ?9 u: `
{
' e0 B1 g; Q; k6 i ; This is required to get the full path of the file from the address bar/ G9 }6 l( ?( C% @3 k! p
WinGetText, full_path, A
/ o+ `. E$ H4 p5 m ; Split on newline (`n)
1 o" D. [7 k! s T StringSplit, word_array, full_path, `n& @1 z3 v$ _* p
; Take the first element from the array
2 J* {4 _7 s! P/ Q# ]! X" \- N full_path = %word_array1%
+ i. s4 _' X4 }9 n# M6 M ; strip to bare address
% R: S5 |+ D W1 W; B full_path := RegExReplace(full_path, “地址: “, “”)
" ~9 |2 x8 `* {* s5 u+ y ; Just in case – remove all carriage returns (`r)
2 m2 l8 H. _4 S+ J' u) W6 ` StringReplace, full_path, full_path, `r, , all4 E; o( q/ N M* U! I
IfInString full_path, \5 `; P% F1 w' H- `& v
{: u$ Q% O7 B+ n5 r
Run, cmd /K cd /D “%full_path%”
# L! V, B. |2 O; q* a' j }: R; |0 ]6 X, m8 b6 ] S8 L
else
$ Y) I' l* g" R; A3 M+ g# z6 ~2 ?' z { W" I# _0 @% @1 y3 g! l
Run, cmd /K cd /D “C:\ ”
" B h) w, K+ O3 H) J7 s }
! @2 {* S; `7 g; U! Z }
* u9 V' T+ m" m) W1 N9 i, D 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
5 _1 D% h) L6 L& P3 ]! b# x 这段小代码肯能有两个你需要修改的地方, F+ O1 K! g1 M7 L
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键6 g" L) C% x- d/ T+ _
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
5 l9 A/ s3 m4 x+ Z3 a |