此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。& ~+ T X# E2 M' {: _
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 V7 F& j- v) X 方式一:! o( Y# S# q$ R8 {- P- ?# F0 T9 d
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
( U# W9 p. N1 ~9 Z4 e0 S 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
: u7 D% i- W5 ] HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 N! X0 L4 Q. i8 L& F- s" h
方式二:! b! |4 v) C I( F8 D% ^: I4 B
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, [/ a& K/ P) h1 x. d" S2 ~1 b
SetTitleMatchMode RegEx
" v7 u( o ^* W, u, R return
. P% E% z. z/ Y+ }5 ?" ~+ @) b ; Stuff to do when Windows Explorer is open! n) C3 o3 b, v
;6 P, h1 x% p2 A6 S8 A1 O! m' f
#IfWinActive ahk_class ExploreWClass|CabinetWClass) q/ S4 O$ M o) T! L! E
; open ‘cmd’ in the current directory
2 x |7 O N9 x( `4 o) C- Q ;
" s) I- K6 r" V #c::
# \8 X4 F# U. Y) j& s( v( U OpenCmdInCurrent(): U: Y% f% ?. m) i
return7 |+ j) V& j& C* W/ Q
#IfWinActive
. [7 Z+ I, U2 k+ C& e, x* B ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
; b$ ~. C% M. C( W- M ; Note: expecting to be run when the active window is Explorer.6 y7 y9 o N% g
;
8 B0 l/ U5 `' e$ Q5 ]2 H OpenCmdInCurrent()* k; @' `- S" g+ l
{
. B' c/ d& P9 @" c/ q' R+ o; z ; This is required to get the full path of the file from the address bar
' G0 o+ ?, r* o, M7 f WinGetText, full_path, A! D4 ` P6 l- S+ c. m4 h& i) Q
; Split on newline (`n)
3 R0 Q* W7 Z; z! b! w8 `$ N; D StringSplit, word_array, full_path, `n
& f0 \3 R, h1 v t ; Take the first element from the array
1 x- S5 A! }7 `4 S z O* r$ f full_path = %word_array1%- }& J" m4 _5 v" n
; strip to bare address
3 l8 G2 R9 y7 D, _ full_path := RegExReplace(full_path, “地址: “, “”)
s0 b, [) a& I6 \/ n% j ; Just in case – remove all carriage returns (`r)
# @5 \2 a+ e2 w StringReplace, full_path, full_path, `r, , all
# g- |( T L/ b- l IfInString full_path, \
$ X$ J: J- w( j: V ? {: T4 W, Q5 M5 @ j/ g% J
Run, cmd /K cd /D “%full_path%”
/ n$ e8 D/ m" K" N- L }
! H2 c4 g6 u4 r8 T$ [: m) W% e3 Y& m else
' u3 H2 M! ~7 t B4 j {
5 M4 S/ y) l. a Run, cmd /K cd /D “C:\ ”4 [1 a; h; i# `: m5 b4 Z9 N' E" G+ H
}& @# o r1 _4 F$ t: r$ U
}
& w; W' }" Q1 ~6 M. l% Q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: k/ a5 B3 A; r3 A8 f; u 这段小代码肯能有两个你需要修改的地方9 O+ e* f9 v# Y* n8 }. _) \
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
2 P3 L- @& y5 i- ]. p 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
' ^; D/ w: ?+ U- U8 D( M/ L |