此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。* W) Q6 [! @ b& K: Y
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。0 f. S' q9 Q# {8 A1 y R& k
方式一:) W+ ]9 o$ S% Y7 J6 l8 J- v
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 h& l7 B/ ~, G3 }9 K. n
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和4 p$ i9 D- }8 N- t4 Z0 B. p
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。! G- D9 i3 m. j1 [
方式二:
2 I% }1 t4 z$ x7 T4 r2 [* m 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 ^8 ?8 q9 A5 c* T
SetTitleMatchMode RegEx
, J/ r" d; s E$ D return
4 R7 c# C( b; S4 o& e ; Stuff to do when Windows Explorer is open
% U6 [8 Y u/ c; D/ k ;
& N( W, v: j5 a2 a6 ~$ D3 e #IfWinActive ahk_class ExploreWClass|CabinetWClass
: u) J- R+ ?* d. p# g ; open ‘cmd’ in the current directory: \+ q6 F$ X. x3 `
;
( ^; W, w; {) W9 w #c::
7 L7 B: Q0 [* W4 m; s) e( A7 l OpenCmdInCurrent()$ i4 r2 g: C2 V; X b
return( G K( p& G3 M+ \+ e
#IfWinActive
) V) V; }# q- S; G. n' I ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
! u$ O& t4 Y) c ; Note: expecting to be run when the active window is Explorer.( c1 P% z8 a4 U: j
;
+ m9 S3 ?5 I0 f4 ~; i6 L L4 s OpenCmdInCurrent()- G0 k6 I; t; T% z/ a5 g$ b3 E
{
: d) o: x! Z# T( B ; This is required to get the full path of the file from the address bar
6 O+ P, m8 F4 K: I WinGetText, full_path, A
) W" K- r; o0 s! i( j- r ; Split on newline (`n)) t/ Q/ w% t1 m; z5 u* {
StringSplit, word_array, full_path, `n4 X- [6 Y0 ]: X$ K! T; A7 D& h2 z
; Take the first element from the array
1 x6 A: h* Z! H2 ^- c9 V! Y full_path = %word_array1%
! B9 `9 x2 _7 u+ O9 e( V1 b5 p ; strip to bare address
; u7 o: v$ c3 j1 G' m* A" @. O2 \/ t full_path := RegExReplace(full_path, “地址: “, “”)
% Z- J/ a; U# n. x0 R ; Just in case – remove all carriage returns (`r)
6 {, b" B( m! B# o' o z StringReplace, full_path, full_path, `r, , all0 V6 d9 h/ G& Z2 ^
IfInString full_path, \
* t/ Z5 U- f5 I# H {
+ n$ n' p7 F8 A. p9 P Run, cmd /K cd /D “%full_path%”
! k. L+ N8 A; ?3 ?* l% ~4 Y- K; d }, k& ]' z; o! I ?) o% q/ t
else0 [2 p: j* }3 ]7 T
{9 I; S& S7 V) V$ b" m4 q" Q
Run, cmd /K cd /D “C:\ ”
2 y) _5 y/ U! Q/ Z }
% X+ H! }- Y, s }5 d" q/ r, \ ]& x" a! p% T
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
( B L3 Q. W( v7 J& L 这段小代码肯能有两个你需要修改的地方4 S9 M* d6 @ |5 c& \; F
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键 \# Z8 A5 U; @% h( a! m
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “6 J8 v: z4 K0 Y6 W
|