此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
: g8 k( O4 `1 p' {: L* W% ]/ l 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。 @; Z' }4 u2 t" V. g
方式一:' z! E, T4 E' H5 s
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 H/ \- K3 R5 e' ~+ w. t( Z d8 e
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
* ?$ l8 }% C7 M& ^ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 I7 P' I9 ]0 |$ C' s( G) B! G
方式二:
" Z7 m+ s' l3 Z) q: @7 { 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
X- A% E0 [0 e SetTitleMatchMode RegEx
& X3 Y. z- x8 F7 ~ return
& H# N- \; k; t- m& A# N& e ; Stuff to do when Windows Explorer is open8 O4 c# U M. s# ?
;
3 I5 \9 c! V# w #IfWinActive ahk_class ExploreWClass|CabinetWClass+ e( X1 L" k( Y5 g
; open ‘cmd’ in the current directory
7 ?' G o% E! C, u# {+ O# I8 \ ;
6 j7 p7 |0 C6 ~* e; d #c:: U4 U( g" c L( b3 d; w( |6 q
OpenCmdInCurrent(): P4 p3 @ n+ J N3 g5 W
return
0 z& k! A! K. U1 u7 c8 U, }( V #IfWinActive& {8 X4 E; w* u0 h7 x: T
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.* j$ P; F( n% c6 x- Z
; Note: expecting to be run when the active window is Explorer.
2 C% E9 d4 [& Y) | ;
O0 D+ G7 C, A! d7 K+ y8 L d, A OpenCmdInCurrent()
5 {% e; ^! m# d P0 F {
2 N# ^7 @: d* N6 r) u9 r1 } ; This is required to get the full path of the file from the address bar2 s1 c! S) K3 K0 t/ r- L
WinGetText, full_path, A
$ y' e% p% h3 s4 Y7 z ; Split on newline (`n)% \8 @% \$ d+ R! S4 y, l/ `! p/ z, V
StringSplit, word_array, full_path, `n4 \. [& Q# `# r! f( G# U
; Take the first element from the array- U" h7 x3 J0 |
full_path = %word_array1%
: _& \: V: ` T0 b7 v ; strip to bare address
3 M3 I% A4 O' K% M7 d full_path := RegExReplace(full_path, “地址: “, “”), y4 {, T7 q7 L; E( M& f- {
; Just in case – remove all carriage returns (`r). e- Y! R% s" p* F/ D4 w; G9 E$ k9 w
StringReplace, full_path, full_path, `r, , all
* w( K, Z+ q! D& E2 G/ C L IfInString full_path, \6 ^: L, H4 `! y @8 l. C5 o& V
{
: J ^( a9 J' ^0 x Run, cmd /K cd /D “%full_path%”4 u2 I, x* x# Y+ ^5 k; L
}; u" j% ^9 I$ m
else
5 U2 b& K/ f) D9 V {0 K6 }8 D* a; ^0 J# b
Run, cmd /K cd /D “C:\ ”. Z2 X/ _. u; N, W( D4 u% F/ ~
}
0 L3 R" R2 E; d9 U r, j }
% b, T( g! i0 e8 X; S4 @* X 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
! u) s3 g/ T; ~* ` 这段小代码肯能有两个你需要修改的地方& f) A! O5 U1 X8 r& n+ |& d
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键6 @/ H- k8 j: |
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “7 w0 x* @2 ?( H, I# z$ p: o3 p1 t5 e
|