此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 w# C1 M1 r; Z& F+ |9 b* M+ S9 A 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
2 u$ J+ N7 P) U1 p, p+ t. h7 ?; H 方式一:: d7 @; E2 }4 o7 f3 w
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
" p# \" I4 \" ^; R1 u- t; N% j 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" ^3 u/ d! d2 b HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
- S% u; }8 V' b& d7 V- X 方式二:
% t/ A# j5 m3 ^- n# g! Y 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
0 l! V# A( T7 e0 e4 ^7 u+ O6 o SetTitleMatchMode RegEx
S* p S" ` \9 A; c4 z8 p# ~! s! s return+ d) L# }4 G% Z# |2 Y6 K& w
; Stuff to do when Windows Explorer is open
9 l+ S- V" S( I+ ^2 Y t ;
" J! u8 B# v! b' o$ t4 ^* Q #IfWinActive ahk_class ExploreWClass|CabinetWClass) t, @2 w1 B2 |& u7 s
; open ‘cmd’ in the current directory
6 q% B; d# i! ~9 W" j% w ;# t: f- L7 {7 u. ] B
#c::% \1 @. [# I) a( \" A7 w
OpenCmdInCurrent()
( I3 D& Z y7 M( D1 k return* e0 i9 y! i: \
#IfWinActive6 M3 V1 `3 o/ O! u
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.9 h1 s( D2 K8 f% a N) A& q
; Note: expecting to be run when the active window is Explorer.; T* x+ O; U6 M; C9 N1 L
;) `& x- x9 K: T$ b
OpenCmdInCurrent()
( Q: q. N* V8 s+ G J {
7 h& h' Y/ n# C$ {! j ; This is required to get the full path of the file from the address bar/ b, k3 B9 X! U5 y
WinGetText, full_path, A
8 p: X* a! q+ x4 X9 j7 m" K; g ; Split on newline (`n)
8 }9 o9 s- h5 ^9 a- Q StringSplit, word_array, full_path, `n
' K" Z4 |1 u& w, b/ r' G( }( N ; Take the first element from the array8 F0 w& `9 d- n/ s
full_path = %word_array1%
+ u$ i3 h# k, W ; strip to bare address
# A6 _* A/ [, V full_path := RegExReplace(full_path, “地址: “, “”)
% Y/ Q! L f& B& Z0 S0 p/ f ; Just in case – remove all carriage returns (`r)+ @! N6 X+ w; C% O
StringReplace, full_path, full_path, `r, , all
( a$ f+ P9 k9 K0 }" A4 c6 l5 Y IfInString full_path, \
' R% g; o' v4 ~' p5 A {, z6 }% f& ?. o9 p
Run, cmd /K cd /D “%full_path%”
- \2 u" R# H$ o% S }8 x3 s& o% {! W! W/ x
else
( g5 _" P& A- i+ s9 q" R) l {
3 R0 G. g$ B$ I: ^ c( B Run, cmd /K cd /D “C:\ ” l( P+ p# |. _
}
6 y& U5 c: m: B }
% {1 G& J1 V- C ?2 ` 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
( R/ k) `) R, Y# T" C, x 这段小代码肯能有两个你需要修改的地方; Z X! a; g5 s( G) c, z8 S" Y3 S
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( t& U1 Z/ v: Q4 k3 I& v6 e 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. L! v4 F- d5 k
|