此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 I; l4 c, [+ Y% M9 ^1 \
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 |) i/ V, A; C' w 方式一:2 }' d# A2 N7 d9 W
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
) I! `1 t# r7 _1 E/ O# M 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和6 G. b4 p' k, t0 N7 L" w. x" y
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。( K9 X) m2 F# H. |5 V$ E+ h! ~
方式二:
, w. B4 c3 ?7 y" |: M7 `- w 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ ]! v8 w' S% X& s# [ SetTitleMatchMode RegEx% A2 s' z5 S$ s# u- d" W- g
return
9 x- v4 Q* }. x9 z* B$ u ; Stuff to do when Windows Explorer is open
; P$ W% i& g. R3 T# m( I ;
6 _! W- ?% g; n3 O. D C# I #IfWinActive ahk_class ExploreWClass|CabinetWClass8 o/ p% r: h. D0 H' a' P3 }
; open ‘cmd’ in the current directory5 ~% @% z- i3 o3 e L
;
# [$ @: C+ \( @3 }/ c #c::
( Q& J6 v0 _& ^6 M7 o, ~/ y OpenCmdInCurrent()# C* X, [8 r2 O8 }! [
return
( p; B4 `, e% v2 J. N; C #IfWinActive9 H7 G4 k- Y- v1 ~
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
6 i/ A, Y; Q4 o% J6 r* T* { ; Note: expecting to be run when the active window is Explorer.% Z( B$ X% q5 d6 K) G& S
;
$ Y; g* K }2 E$ w" t8 l OpenCmdInCurrent()
; t8 q" R9 S' P% d( T; d5 u {" P: l& R6 e# C% i
; This is required to get the full path of the file from the address bar
1 B3 ?; d7 u5 a% N WinGetText, full_path, A
0 U' d& b! Q( Y1 J, q% f ; Split on newline (`n)
5 V2 \$ M9 t7 ?) m. \9 A$ V StringSplit, word_array, full_path, `n
% F: z7 G$ o+ |- J2 A ; Take the first element from the array( c) D7 }5 w' g- ~) G# t: H
full_path = %word_array1%
+ f, [, A, h2 j2 C- g6 m: s ; strip to bare address8 W: F' n& v/ j7 }: }- N
full_path := RegExReplace(full_path, “地址: “, “”)% H; O( ?9 w! y' g' ~
; Just in case – remove all carriage returns (`r)
# p0 C' F& d, N w, ~ StringReplace, full_path, full_path, `r, , all
- w4 P% d) T. q {- \+ s IfInString full_path, \
1 s+ D0 @9 {" T4 ^ {
8 e4 q8 |: c) b, |9 g1 e Run, cmd /K cd /D “%full_path%”
+ d4 Q+ z: @* R. Y; V }
7 Z0 Y! l S C1 X3 b else! A/ K' X9 Z1 G
{
t9 e7 G+ u0 c l; U- X- O! W3 y Run, cmd /K cd /D “C:\ ”4 f3 P0 j/ q" s
}
8 ]5 M) G# [: D% s0 c6 H4 R' a) v8 ? }
$ N0 S2 A1 A- l9 |9 i8 \5 ^4 D; E 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
8 B7 L$ {- u& G 这段小代码肯能有两个你需要修改的地方
4 u9 K( c% |' T6 ], i# [" S3 y 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
" a2 n! W8 E1 S, P9 Q 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “' K& R3 y9 s( z: \5 W* g3 r
|