此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
G; A2 ?/ \2 S% g- @$ J 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
& A. x6 c/ R8 T7 [$ J9 Y0 a 方式一:
- Z" ^! U) a, w' {$ x, u, o) d/ { 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,2 A' y$ c* x; o
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 `8 k4 b$ R% I7 O3 b8 O$ t- L HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
?6 ~8 }1 T' o 方式二:7 j7 p4 a4 A: g3 A- f" r
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:1 M! G: v& P) w! n. @+ d% Z( ^- o
SetTitleMatchMode RegEx" H. y0 V+ q) G/ s. R1 L: r' }: ^
return
: B6 v {/ \, O) Q; V) { ; Stuff to do when Windows Explorer is open
3 Z" i' L) m6 j ;
; j9 [& s) {5 A) c+ t #IfWinActive ahk_class ExploreWClass|CabinetWClass
3 s7 |- O& L) g: ~" Y; J ; open ‘cmd’ in the current directory
3 r( x( ]( k$ K% E ;
+ B/ A' u+ k! j+ y& s* Q! c #c::3 J+ Q3 E) J" i$ R0 z. r+ r
OpenCmdInCurrent()
x* X8 b& S; P; g" O% l return& s0 G, l" [ R- W
#IfWinActive
: S' t. c. r6 N9 D/ f ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
& S3 Z' F- ^ q: |- }0 o5 X$ U ; Note: expecting to be run when the active window is Explorer.
% B( M Q$ W- F' u, _ ;$ Z. l! C! w3 U: n0 T
OpenCmdInCurrent()3 m3 G* z: u$ y: w9 W. i) ^
{
% J) G+ ^) t* m ; This is required to get the full path of the file from the address bar6 G! X) @+ }5 x
WinGetText, full_path, A
- l, p+ p3 Z8 N( V8 V2 R( x$ ?& D* e ; Split on newline (`n)1 [( Q( T. k; x' b
StringSplit, word_array, full_path, `n/ D- u1 F: f8 b5 q3 S% Q6 Z! A
; Take the first element from the array
- S' B( J9 Z: S. m' ?4 I# q( i9 L* W4 D full_path = %word_array1%2 B! \7 i0 ]1 g2 K1 D
; strip to bare address5 U! |+ A# Y; F- w" t
full_path := RegExReplace(full_path, “地址: “, “”). _( S3 o( c. A3 u3 ~
; Just in case – remove all carriage returns (`r)
7 j$ E$ [* u1 f$ O! M9 t5 J0 r StringReplace, full_path, full_path, `r, , all
/ q' _8 i" x3 w% q- X IfInString full_path, \
7 C0 e* U' E s/ ~ {6 q) y/ [$ ], |
Run, cmd /K cd /D “%full_path%”
4 p: l8 x1 q. H: P }
! h% P, {4 p( d else
) a5 Y' `/ Y3 s, I* k {
8 k) N( V1 v( r. @, f% W Run, cmd /K cd /D “C:\ ”" e5 R' Y x% D& U4 W0 _
}
" g. c6 F S. |. ~: j# Z }, J9 [. W/ w/ M8 A$ K( B
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# T) W! L. T( `' K9 i/ J7 i+ E 这段小代码肯能有两个你需要修改的地方9 Y; s' \+ | S H5 U
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) @0 c# `- T' m8 `% [
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ W9 R5 C! H. l% \
|