此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
* u, V8 ~6 T6 F) e1 R% g. H4 | 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% s+ t0 Z' w1 c# j: T
方式一:
5 x! R. l x7 A. k9 J 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,5 O" K/ r4 x0 M% g
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
* O7 \/ L, b7 I; Y0 {1 y HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。; s" G; n4 G, q5 N7 U- P$ ]" D3 Q$ h
方式二:
V# V8 ~& v! Y7 M1 [8 c 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
, V+ ] F+ A( j' q; x SetTitleMatchMode RegEx
( W; K) K" z0 f z$ ~, n return# x* z! j' Q# Z8 K& k }
; Stuff to do when Windows Explorer is open# a/ @9 F6 \+ J6 K( | S. ?# t
;
: J/ f5 K, |/ E0 W #IfWinActive ahk_class ExploreWClass|CabinetWClass# W+ W" u# r, P+ I: n7 O) U
; open ‘cmd’ in the current directory
8 ?$ X' O8 ]- c6 I6 m$ f1 a9 M ;
0 u2 _9 e6 d9 R+ j #c::
8 [! g) d' ] u OpenCmdInCurrent()# `+ b1 Q% E l4 j
return& K# z+ w* Y8 C$ k: @
#IfWinActive
. l X6 l2 d6 _6 ?0 F# Q% X ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.3 D6 l" z, _' ?9 x/ ^4 H
; Note: expecting to be run when the active window is Explorer.1 n+ N# I& y) Q) q" ?
;- f' `' z# | r" A4 F4 u
OpenCmdInCurrent(), a5 F4 A Q6 a& W8 B9 I
{
9 p; N/ h3 d" t q6 n$ Q7 m ; This is required to get the full path of the file from the address bar$ y1 B! r5 H4 d; u# _) c" T
WinGetText, full_path, A
3 V& m C# {* X3 ^9 u; j. w ; Split on newline (`n)& u: F& L6 t( m0 W
StringSplit, word_array, full_path, `n4 F" c% }* u# ]% `
; Take the first element from the array
( Q+ [9 Q! D3 c4 n! ~- P full_path = %word_array1%1 d2 `( p9 ?3 y8 |0 S; n
; strip to bare address
) x7 u+ w; x, j. Z8 B6 N full_path := RegExReplace(full_path, “地址: “, “”)# U" P' P" r9 O3 s% D
; Just in case – remove all carriage returns (`r)
% b$ K- Q; K2 D; k: T" a StringReplace, full_path, full_path, `r, , all
9 }; _. z& m3 \# @4 T6 N IfInString full_path, \
! i% X n: \8 K$ r$ y {+ Y1 _+ Y; h( U( b+ F; {
Run, cmd /K cd /D “%full_path%”, h3 d s5 T" I2 z+ x/ V; I
}
6 y( J" [. c( I7 B: O7 L else) o' }4 o' |, h" U' _* t. v" @
{
9 X9 h. t1 K) Y, \% i Run, cmd /K cd /D “C:\ ”( H I/ u& J/ J1 }2 b9 |9 d" d
}' p0 ^; @/ A* E% k$ P6 M4 X
}6 L! b& G& M' @* v; }- g, \
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。7 v1 G( f/ r7 ^/ H
这段小代码肯能有两个你需要修改的地方
! R1 j" m2 s1 t( i 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键. |. N' C ~( Z0 ^' j: q2 m
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “" M& S8 a/ n6 X1 q% A8 r; d
|