此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
, L5 K+ A( @+ O1 ` 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。) u- X8 g4 ]4 b3 Y, W: x7 ~
方式一:
" s# F3 I. R/ E 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,! |% r7 K" W! V' W1 D; j6 ?
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ {0 b$ S, h; [4 ^6 E7 k3 }5 ^
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ _3 d/ H7 K: I! Y
方式二:1 B; s3 D$ K- }5 b: z4 `
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( W) [& s# U5 y% z7 {( _ SetTitleMatchMode RegEx% p) W+ l, n) N' Q) ?
return# ]' e; k! _3 w% B
; Stuff to do when Windows Explorer is open
* C; K" D; b6 @& Q4 @ ;
! s( F) ^9 K* G. c# \ #IfWinActive ahk_class ExploreWClass|CabinetWClass+ ]1 ~6 G: w* N7 t/ ]' J7 V3 S
; open ‘cmd’ in the current directory6 j0 w/ r4 u1 o5 X! L
;
e5 _% `8 {4 r* E8 j #c::
& j) ]# ?* l. \4 E( C# N OpenCmdInCurrent()3 Y# @2 x! u- ~1 |! L; q
return
& X2 s( ^2 o. s2 s7 W6 p #IfWinActive( f" h: K. q9 r7 c! |, B
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
: O% @" J l p/ U3 F& H+ | ; Note: expecting to be run when the active window is Explorer., P; F. q) M5 W/ k& l7 k& |: R
;
7 I3 W1 b C5 y) z/ O OpenCmdInCurrent()
. W) T) V! B$ ]' T/ O D" L5 [ {
! K8 H/ k+ q# r( L; A ; This is required to get the full path of the file from the address bar |* K3 [9 g. d' f2 k6 a
WinGetText, full_path, A
& M- D" Z" n0 T* ] ; Split on newline (`n)/ I x$ u9 M; Y' @7 s, V n
StringSplit, word_array, full_path, `n
: Y' |8 q. y4 f ; Take the first element from the array
1 M! u# T* K o8 j! _) m* j( L8 k: Y full_path = %word_array1%
* u$ y; |2 Q3 K1 |" { a: x7 g( T ; strip to bare address
" \" Y( U6 y0 v$ ?+ o7 z full_path := RegExReplace(full_path, “地址: “, “”)5 x1 O# M+ D6 s- C Q) W
; Just in case – remove all carriage returns (`r)+ Y" b8 T& b8 d9 L7 i
StringReplace, full_path, full_path, `r, , all2 l+ u8 |1 v1 e
IfInString full_path, \7 h, w' w9 p" T
{8 h! ?/ [ y0 ~# Q4 f L
Run, cmd /K cd /D “%full_path%”& w0 _, l, S3 c* ~) o0 h' n4 d. F
}% P a0 R6 I0 `" J. [8 e% \' z. u! O
else
9 W1 l' a2 T4 N2 ` {
3 {' U) T5 k2 g! u& _ Run, cmd /K cd /D “C:\ ”
7 _" n$ c; q2 L9 X }
( K6 q+ ]; p$ P1 V }
9 `3 ]0 q' s: z- g 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& W G& @) a# l; R3 s3 B4 G# _
这段小代码肯能有两个你需要修改的地方9 i* r7 X+ k' l
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; W. q" O' M& H) @5 R: Q! i5 y
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 I/ G7 O8 }% h2 ~ |