此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 R0 F, u# O- l4 G) n
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. D, S, Q% ], y5 t) {
方式一:
$ U0 m$ b% ~- J% r 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,3 d# j9 k, h' i" q1 W
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ S/ ^! j. W7 u8 K! f
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ I4 ^1 e8 y, i+ t' P3 ^4 m& ~. Z 方式二:' n: K9 I) w( B6 I/ j$ r0 Q
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: Y J3 \" ?: ?/ B7 J
SetTitleMatchMode RegEx
# f! Z8 m5 D' L% b$ c( ] return
# o, x, O; k& ~3 O! h ; Stuff to do when Windows Explorer is open
3 x+ ?3 a* S6 H; _/ ^" @! K ;' k1 N7 z7 U! P C, i" u. S
#IfWinActive ahk_class ExploreWClass|CabinetWClass
8 C$ i4 i* N3 `4 a ; open ‘cmd’ in the current directory
, i, J5 ~) g* k# t& y) t, K* D# b/ k ;9 q$ ^0 _4 {# c& Y+ P+ e
#c::! U8 o H w0 ]- p6 W8 ]
OpenCmdInCurrent()' o2 Q Z$ O% Q% ]9 ?
return
( w% G3 w* G0 e$ I7 \) ^; H" Z #IfWinActive
q7 U7 T7 T/ F ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.. H6 K$ ^3 y) Q& K+ }
; Note: expecting to be run when the active window is Explorer.1 S5 d! G9 W# U6 p/ E. v
;
9 r/ y5 K* @& _, C2 |" \ OpenCmdInCurrent()' N3 i8 C: x+ w! T D4 e' U
{
/ z1 Y* P" I! D ; This is required to get the full path of the file from the address bar7 s; ]2 e( r4 W8 t9 Z
WinGetText, full_path, A
; j, m9 {0 P( V! Q. o0 H5 C# X ; Split on newline (`n)
+ H2 k8 g( n- y* I/ T6 l* ^ StringSplit, word_array, full_path, `n
, E P; k. q% v( P. @6 ~ ; Take the first element from the array: D8 x: \* t% U, M- V* j
full_path = %word_array1%
; u5 I8 S1 g8 ^! Y: s( \4 ~ ; strip to bare address
) t+ j$ Z. x: V: n( v" i- N full_path := RegExReplace(full_path, “地址: “, “”)
" |2 l& Y9 Q$ H" C8 {: ~' F0 @ ; Just in case – remove all carriage returns (`r)
; k5 }6 T: N7 G. e& r( Z1 D StringReplace, full_path, full_path, `r, , all$ B$ C$ w% U1 v$ u- G5 u8 G! d, Z
IfInString full_path, \
' o; \4 B& t: x3 G& W {
v8 q! h* K' \: \% _2 A0 A8 ~+ P Run, cmd /K cd /D “%full_path%”
O& x" C U9 T9 x) ` }
; b" v0 B( r6 g' ~ else2 v+ E$ {: F3 [; Y
{
: h3 m4 _2 X1 Z, n Run, cmd /K cd /D “C:\ ”& D+ A# t, M$ t: q/ O
}( ?% b$ ]' n3 Q' E7 |# D/ Y% E
}
$ J2 l# U4 d! D% S J& b- @& E 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* F0 L: I( U9 N5 b" j; W
这段小代码肯能有两个你需要修改的地方
- L4 b" F9 n" a- d$ g/ e 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键, r* ]5 N( ~: ~9 Y i
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 q q: ~- ~- b! @; U3 d% Q5 D
|