此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 j- F( T) ^9 `. m
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
6 B; s8 T$ k9 [% A' e3 d 方式一:$ ~, ~3 C( p1 q) s/ \
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# p. r6 q5 }9 P V1 a6 U 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和 q `. n! \7 |' k* H" ^! z, V! S
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 h4 M M4 T. p* C" u! K: G! C! v 方式二:
. K. o8 l* q( K" h8 h 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
4 d+ h" J. m2 ] SetTitleMatchMode RegEx
% f! `& A4 o) y" `5 Q. l+ P& f- ~% @7 \ return
\6 B8 K9 c; _ ; Stuff to do when Windows Explorer is open
# G6 m: C# l' Z+ a# b+ x/ S0 i ;& j- }1 s2 n3 x7 O6 N0 Y' x
#IfWinActive ahk_class ExploreWClass|CabinetWClass3 O5 c# Y/ G4 E
; open ‘cmd’ in the current directory
7 e) M# l5 d/ G5 V ;
( d( l/ F2 \' y0 t1 B #c::
7 ?- n* z& l2 x8 }- [6 @2 L. i OpenCmdInCurrent()
# k* a$ {: A/ F" _. m2 s return
" l5 ~6 `, o b% E #IfWinActive
: N3 K- q) s4 v; x5 ^9 ` ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.$ m9 {$ `; K' y% |
; Note: expecting to be run when the active window is Explorer.# [4 }1 x! Q8 o4 d5 ~5 D& b7 c
;1 ?; e5 w/ Z' D1 ?6 I
OpenCmdInCurrent()
! T% o; q& L$ L {0 F0 x& _2 I5 w$ {8 U: _# ?3 b$ V& B
; This is required to get the full path of the file from the address bar3 v' q; K2 V: f7 R+ T: M
WinGetText, full_path, A! [6 n- B0 S6 l4 E: W4 w
; Split on newline (`n)1 w: r3 m1 b3 x0 G6 b) g; P, r
StringSplit, word_array, full_path, `n
\0 q8 Q( ~) s& z ; Take the first element from the array- t' B' ], E% L3 m2 J
full_path = %word_array1%6 ~& Z) H- _8 W/ r
; strip to bare address
2 g/ q* b, n/ Z% v* k full_path := RegExReplace(full_path, “地址: “, “”)
" W' E) T! \$ Z2 m: n3 K- [3 u ; Just in case – remove all carriage returns (`r)
1 f5 i3 Z5 C, Y StringReplace, full_path, full_path, `r, , all# R: e, I5 s1 f6 R# l l' s
IfInString full_path, \9 c9 C# T4 c0 @4 L& X& V( A- m
{
# Z. k& y9 [. ?7 w9 i! D Run, cmd /K cd /D “%full_path%”" c0 L' D' W% Z" z# w
}
& F0 z. R& d' w2 w else% @) {/ l0 N! E- x1 Y2 z. d& B
{- I- q# W+ e5 A6 y9 y5 I
Run, cmd /K cd /D “C:\ ” Z# x" c* a! I+ |$ e. D
}7 y" U& T1 S D; k) S! L5 X
}
0 x1 Z! r* r$ x4 }9 M" q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
; J8 z# q. X4 G4 m) Y- E0 x& C 这段小代码肯能有两个你需要修改的地方
4 b: U: \. I X; z1 @5 e4 Z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ c, R# D5 W, ^- l2 P 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
Y V, Q/ Z" H! X |