此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
?$ r9 L$ O2 K; i 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。3 I+ A, x" N: t' ^
方式一:
' V |! M1 u8 F9 O 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* T0 e1 u9 W1 c& _: @. y3 c: f
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 x* }$ \) @ q2 Z! b HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ o% h# u, k& x! o' o% g, X# J
方式二:: L+ m* z$ k* j7 ?" D8 ^. u! @
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:% V, @+ j- X: b! t& N
SetTitleMatchMode RegEx4 B6 C; O( T3 V. N
return
2 G: N4 A, C9 f! ~4 t4 t' G4 T ; Stuff to do when Windows Explorer is open
g% O3 m8 e, r8 x8 P: N$ u% E( D ;+ H1 D3 E# d# a7 ~) `. ]
#IfWinActive ahk_class ExploreWClass|CabinetWClass
5 ]& K1 }, h. Q ; open ‘cmd’ in the current directory0 B9 d. D1 h Y0 Z# p- @$ H
;$ U0 \" `. n4 W' l% S
#c::+ I1 Z# a+ m0 j, c' A) y# i9 {
OpenCmdInCurrent()
( p1 A; N9 c. c6 i' C return. h# |* g5 v5 K- m) ]. ^$ H" s+ x
#IfWinActive
7 t) I6 e1 f% H4 B) ^! N$ z ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.7 `, g! L- a0 j8 U% N3 a
; Note: expecting to be run when the active window is Explorer.9 w+ X0 D- a( M( K1 W% p. u
;
( u" L# a, O2 n/ T% `" @$ T OpenCmdInCurrent()" K2 k* D: Z0 g/ H, D
{
8 X& ]# } I' p* A& n& _ ; This is required to get the full path of the file from the address bar
+ s' d6 j5 W* l4 |8 S WinGetText, full_path, A
% I0 P: M6 |/ I8 v4 _% \ ; Split on newline (`n). J1 P; I+ P) o
StringSplit, word_array, full_path, `n" p# m) g/ d0 p5 O4 v
; Take the first element from the array
F% u r* ?; d& ^ full_path = %word_array1%/ O! Z T. B+ E6 p8 g& Z% b
; strip to bare address
) M5 a: n2 L6 b1 p3 k" \ full_path := RegExReplace(full_path, “地址: “, “”)" G2 R' M J6 N& @3 G
; Just in case – remove all carriage returns (`r)
% L) a7 H O# Y2 T StringReplace, full_path, full_path, `r, , all4 M. D! A X$ U- K- {
IfInString full_path, \
5 |% @2 u" b" q, F, J) \ {" D1 o x+ L$ c3 {% _, x& B: }, Q
Run, cmd /K cd /D “%full_path%”- ^ D5 f% B. f2 U: a; J
} _3 w5 K( ^! E# i
else
. J- Z- N3 o5 [6 S" v( e7 V {
7 U4 |6 O5 L8 n Run, cmd /K cd /D “C:\ ”
7 `9 x8 i) I( q1 j. m% ~ }
. {3 k% n5 t; z5 U }' B, n" h3 q p
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。# J _: E- o a) ~1 l' ?
这段小代码肯能有两个你需要修改的地方( g) @% n/ c/ z' J5 t5 r2 v
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 G5 O( t* s3 S, O+ p
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 K# F! C. B" h2 C! q# I& E- k
|