此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
1 _/ S3 `& ?9 g* e/ F* t' q8 s 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 ~5 ]7 ^0 }( Z. U0 K/ u3 G
方式一:& l& o" k* W7 o7 W2 K/ [* p# y' B
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ h7 ^8 ~' f ~/ v. a
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
2 J. c5 ]6 H; M HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。% N/ K" X- _5 F0 O9 M% u3 F) }
方式二:
1 u+ ]& |3 ^4 c$ |* N0 Y( Z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" }0 E2 N# V) E1 g) h- t SetTitleMatchMode RegEx
/ @: d D' ~* q! T' H2 ]" \ return8 `: c% {' s; Z1 ?
; Stuff to do when Windows Explorer is open
1 p& M# m$ X0 q8 `' l4 t ;1 u# C) Y* j% X4 P0 Q
#IfWinActive ahk_class ExploreWClass|CabinetWClass# V- f+ m/ ]2 F) f/ Q
; open ‘cmd’ in the current directory
]; w+ t/ e9 {2 W! C9 O2 Y. G ;1 M, O4 p5 u% f
#c::
; F' p" s1 _' c8 B1 K$ i3 x: O OpenCmdInCurrent()
/ ?5 Q: s5 v g7 a/ s$ u9 V0 S0 D return' S3 a3 @ ~ i% S% t# i# y# T6 x
#IfWinActive& Z, A) P* a' a# Y! G$ _2 I
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.* [$ {3 Q! X" Q6 @9 N" |' K7 a
; Note: expecting to be run when the active window is Explorer.! L# V8 K: K: [" p8 \# z/ H B
;- i5 M9 X& N: f9 n3 p( _8 {1 m
OpenCmdInCurrent() W: p4 h5 N; s8 p/ _
{8 L0 O. b- c( S7 L7 y/ W2 V
; This is required to get the full path of the file from the address bar
- t d/ u1 N# J4 _: R1 q; g8 C WinGetText, full_path, A$ |2 Z% }; E0 G0 h
; Split on newline (`n)
+ \. T5 v$ P6 m( ?! U StringSplit, word_array, full_path, `n0 V. M- M0 \# \8 O8 p# ?
; Take the first element from the array) N3 O$ ^0 G; D5 u, Q( h4 R
full_path = %word_array1%/ c! ]. X+ F; h* G4 i& v+ d6 @. i; m
; strip to bare address/ l9 P5 h# C) O" ^" y3 s# F8 D
full_path := RegExReplace(full_path, “地址: “, “”)* e* J- t7 i% Z, [ i& S
; Just in case – remove all carriage returns (`r) i; S' ^* ^$ }1 y3 _% v2 X$ b0 ^
StringReplace, full_path, full_path, `r, , all2 X* f i" T M' d2 d. u7 ~! v- e) v7 Z' @
IfInString full_path, \
- C4 _& @; f7 ^0 { {
" ~5 x' Z% u% V* V/ s Run, cmd /K cd /D “%full_path%”" G& r$ }5 u/ D$ I& T
}7 l j C: }5 J6 K6 G5 n# M
else
. ^; N" O2 t" N: U! `7 T {: _8 p5 z$ z8 c6 {" W9 L$ c
Run, cmd /K cd /D “C:\ ”
9 q( p" a; d+ X9 A* [ }
+ t" l) e+ K _$ L! a; f }" o, E' p0 P% R" y/ N i
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
, @/ X1 i, m& w5 x5 R; S8 G 这段小代码肯能有两个你需要修改的地方* p* w$ Q G3 _
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& _8 h! [ i9 y8 [3 z5 f
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; q( @' @5 S! J, p |