此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
6 D) e7 E3 q3 R" N/ v" j4 r 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
5 ]" w$ Q- b9 b3 z+ h8 A; `/ s S 方式一:
2 W: q7 _/ u2 e @; ` 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
. i$ t& W7 r. x/ C$ Z4 B$ W& s 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 o7 Q: ]6 |( S; q HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
- ~$ C" J* m1 T6 @( G, r- X 方式二:7 `0 ]* r' K; ]0 n) `
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:- d0 c0 e: O/ p" E' [
SetTitleMatchMode RegEx0 ~ ^. r- t- f8 g6 E1 c
return) T4 ?4 g5 o; [/ Z! {
; Stuff to do when Windows Explorer is open
% y+ J u$ H8 n" X+ i ; V( m! V6 ^4 ~2 ?6 l
#IfWinActive ahk_class ExploreWClass|CabinetWClass
/ w( p3 \" m- P- c5 y ; open ‘cmd’ in the current directory) \+ j+ x J/ c U( t) [+ r, z$ W% f
;- ^ Z$ I7 j* d+ A- \# y
#c::* N0 p' p. Y6 d' g* V
OpenCmdInCurrent()
; i( w! Q* c- T& F" k return1 |/ f- L# G) u) \: N9 G
#IfWinActive
; c" t+ h' d8 ^ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
* l$ P$ k. X- N+ @' p ; Note: expecting to be run when the active window is Explorer.: j% n% i; n0 v1 B$ b; j
;
* W0 k# T) @; `2 q: C' `( x; K OpenCmdInCurrent()
1 h' ]. T$ `( D0 x4 B {
+ o. d1 ]6 z$ k* Y. u ; This is required to get the full path of the file from the address bar" m3 S" _* X m6 z
WinGetText, full_path, A' O% G, y" I: O% Z9 C' a, R
; Split on newline (`n), E* J' y) n1 H: N8 Q/ s
StringSplit, word_array, full_path, `n! p0 x3 B5 i V) r
; Take the first element from the array
, ~. o4 V1 y( J2 X" {3 q$ c full_path = %word_array1%2 c( w3 v( J, M) w( P
; strip to bare address
2 C6 Q0 P6 E R; i- d# x, m+ ]" z full_path := RegExReplace(full_path, “地址: “, “”)
4 T4 r( A+ o, a. b2 F7 J ; Just in case – remove all carriage returns (`r)8 {/ z9 w0 |- @5 \
StringReplace, full_path, full_path, `r, , all6 R) Z: G+ ~! w& n2 z+ m6 L
IfInString full_path, \! p R/ J9 y1 G7 Z5 }
{
7 z2 {6 z" T. |- }6 y Run, cmd /K cd /D “%full_path%”
5 b! i4 M8 ^0 D$ j: z& P* k }4 ~1 H5 s3 S# b% |* B
else$ N2 u4 E3 x4 @: g3 m+ D
{* r5 l: J9 Y/ e
Run, cmd /K cd /D “C:\ ”: E( S9 p& O* L8 B; j
}* H+ E% J O2 A5 X9 ?1 v2 ]
}
" U9 m5 S, q* Q* | 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* u% v$ a3 }( [ 这段小代码肯能有两个你需要修改的地方
7 @' Y7 J: d+ k0 m 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
: h4 d9 h% m& K. j 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 ?% d- E4 w! {" b7 E, r* D
|