此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( a' o8 K/ Y* x% z* O6 n. [
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。$ [+ u3 j, V! l( z! d0 v' d
方式一:; `3 [- s$ V$ s. o
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
. U! ]. v/ m3 L+ M' U 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和+ o, o7 L. z' z9 _
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! r) O' t3 J) t8 y% ~9 J I* S: U 方式二:
: Y7 M8 \0 H# X% p; e: C6 f9 } 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
. u4 B, T# u0 H8 _3 x) ? SetTitleMatchMode RegEx+ ~1 D) y% D) |
return4 U9 x) j$ M- U `8 f
; Stuff to do when Windows Explorer is open
; j* d9 z, |5 g! B ;
$ W+ J! ^+ A, W; I8 _/ @' L' M" c #IfWinActive ahk_class ExploreWClass|CabinetWClass
, g5 ^. x0 a" b: @" y% x ; open ‘cmd’ in the current directory
+ B/ o4 S7 L' E- Z" p ;# p- m( E9 r% `8 ]) |* V9 I
#c::! Q& y. a' P8 V7 t5 O% g
OpenCmdInCurrent()4 [ N- ^- B0 \! w+ p
return
. K6 {, |+ u4 b6 @5 Y# Y" n #IfWinActive
) B8 F# J. o; G9 s4 Z. y ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
* c% T. S% ]8 C8 ]0 f ?0 f ; Note: expecting to be run when the active window is Explorer.
! w& s: o. n* Y1 p: K1 e* N ;& ^+ c w, Q: X
OpenCmdInCurrent()
) k' ?3 V, R' q) \! f# r {
1 [* M$ x3 W6 k3 f' k ; This is required to get the full path of the file from the address bar
2 Y+ k3 x# d" p WinGetText, full_path, A
5 q0 {( a. N( a1 j) z% O4 \ ; Split on newline (`n)3 d% G9 J9 \/ [
StringSplit, word_array, full_path, `n
4 x& ^2 E: Y+ t2 B& k, K& j0 S ; Take the first element from the array
- p0 y2 Y9 ]" y2 c7 {7 r1 j full_path = %word_array1%/ \" u4 A \5 T4 o2 B
; strip to bare address R9 c7 `# V* ^( F) G. W) Y# \
full_path := RegExReplace(full_path, “地址: “, “”)
$ }# @* b; g& q' H7 D2 l5 M; V ; Just in case – remove all carriage returns (`r)
j8 s: X; {, V" Z; _! A# { StringReplace, full_path, full_path, `r, , all
! M3 {, T9 c8 k$ b3 V# } IfInString full_path, \$ R4 e1 Z% c" w9 K- U) O. _
{
8 B. L- m$ v* I4 P Run, cmd /K cd /D “%full_path%”+ A: U, d7 D2 \ u$ `% E
}
7 {4 `$ i5 \7 a2 [& o else/ L+ l( C2 D) E9 B. L
{
' ^3 H& x) e& M) M N. e: H Run, cmd /K cd /D “C:\ ”
3 F$ I& K* k) M. j }, Y3 e. ^( {% @' I e# M* ~; y k
}, J0 V) d+ d% b8 U: O2 ^! F! x
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。 i: K! K- G3 k9 ^* r
这段小代码肯能有两个你需要修改的地方
7 z) V- }" a7 ?) X 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 ~/ ` ^% b; g, ^ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 a5 @2 i$ w0 V0 B, i
|