此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 v: ?0 P+ v- t d* \ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
6 A* `) k( v- F+ b4 ? 方式一:5 l! q9 R1 k7 C; D. o5 o
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
: ~4 r! V3 F s7 t" d 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和% @2 w7 \' R$ p1 f6 V( a$ j
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
. b4 e; n$ h2 E* C 方式二:
* y8 d3 f- v& L/ M, b" h$ J 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ }* g2 }5 ~. {" F& m SetTitleMatchMode RegEx7 l' }5 S5 H2 S' I6 [
return
6 c% z9 h. A. e, }0 |% ?! W3 t) ? ; Stuff to do when Windows Explorer is open( ]7 r0 R& @, f Z6 q ^. L2 x
;
6 w; R6 Q3 \! H3 q #IfWinActive ahk_class ExploreWClass|CabinetWClass: F' i9 ~' }7 a! F9 ]" x
; open ‘cmd’ in the current directory
7 |" g! m) R* l7 x: x% F ;' S+ ?! E/ B! W6 D3 @4 V" c
#c::
5 w( h6 Q5 D8 u OpenCmdInCurrent()0 h# a- \/ y5 b4 M* i; n& ~
return
' @+ @( f" @; v1 t& d$ h- U! | #IfWinActive6 V# a9 M& r2 Z& s' ?
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.9 {. }, z$ T4 J; P3 a* C' q1 S; h
; Note: expecting to be run when the active window is Explorer.
6 q& z* v, _& m" w3 X3 _ ;0 k4 N5 q& w: F: T5 m, q
OpenCmdInCurrent()6 M% t, I/ y J
{* M% p) l2 T. k. {' p
; This is required to get the full path of the file from the address bar
# x- F" g1 C2 l- e$ I% T WinGetText, full_path, A! s( q0 B+ D0 T/ N8 r$ y
; Split on newline (`n)
9 A6 @ m' q0 j) F- @' d( J StringSplit, word_array, full_path, `n
2 w/ `" s) \* P& I! ~* s+ u ; Take the first element from the array
0 R, P! ~. _) o6 f9 c5 F! J+ n full_path = %word_array1%
2 p) a( R6 H8 H5 Y: C ; strip to bare address
0 S. p' t' H4 `" w0 ^% z# A) ` full_path := RegExReplace(full_path, “地址: “, “”)- G8 Z8 f* j: ^$ V. J0 L- _
; Just in case – remove all carriage returns (`r)) A" R$ P! J# P8 C. [: C
StringReplace, full_path, full_path, `r, , all3 X) \ a; T8 x$ Y; C, J
IfInString full_path, \: j$ O. Y7 ]; B0 Y) x
{
1 L! v8 w3 B; @6 ? Run, cmd /K cd /D “%full_path%”( i5 s; E4 J3 t9 P
}
" N1 U# I; I2 c! Y! @ else t$ _, V5 a9 e1 t; l7 E
{
& T! q6 W; s" E4 x2 w Run, cmd /K cd /D “C:\ ” l% @3 N; o7 \/ p+ [, E
}# I; p' y+ {9 v. H0 ^2 t7 G6 V) O
}6 ~' [) }0 Y, Y9 I
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。. [: |* H9 V1 i* c* `/ V, y
这段小代码肯能有两个你需要修改的地方
. ] Q3 r" L" W3 k: E9 H 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
8 x! s9 K: ` V5 u2 A% V: G 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “3 B0 e! `1 V, V R6 z8 _
|