此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
& W! c: E- a1 A8 e/ w 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。/ z& c3 G( H8 J8 y9 b2 p: |
方式一:
: P, w( I* R1 x" i$ C3 ?; Q 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
4 o! O( C1 l: D/ D V 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和4 H. {. h& G& G" {0 f ]2 y* ^0 J
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。7 O: x! c8 b- z; \0 P
方式二:
( i! l: F& [3 T 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
8 J# G6 H6 \8 v1 v SetTitleMatchMode RegEx( @5 C% R# A0 F$ {
return5 N& w3 V8 v9 [+ y5 b4 m+ \
; Stuff to do when Windows Explorer is open
$ y- T. T' M0 a* d- k ;; ~+ h8 q- k% O6 j, S
#IfWinActive ahk_class ExploreWClass|CabinetWClass
/ O9 {( ]) ^; F5 u4 l" C ; open ‘cmd’ in the current directory) x* P3 x7 Y1 g. ^
;! {% V" P3 q/ P& d2 }
#c::
" w3 U! Q% L6 @& Z" C5 S OpenCmdInCurrent()
- b5 B7 l2 q. l7 X: g: M8 f+ W, { return
: B: i$ t9 h3 I5 c #IfWinActive/ K# d* {5 c! v4 b4 i( [1 k
; Opens the command shell ‘cmd’ in the directory browsed in Explorer., Z9 ]' d5 n4 e& `( ^6 X) D
; Note: expecting to be run when the active window is Explorer.
3 x$ h3 G; a9 v/ v ;7 G9 D) I4 O* [* t$ O9 {; o
OpenCmdInCurrent()8 o8 O# M/ l/ o# \5 J
{* }4 e+ f2 L4 h
; This is required to get the full path of the file from the address bar
- T. E' {+ u, K2 u* M WinGetText, full_path, A
; X) |) b6 q4 ?: _+ q1 \; q9 N ; Split on newline (`n)
: i! S: A3 t1 `) h/ u! w. c StringSplit, word_array, full_path, `n
# P/ I) L5 S1 z u7 f5 t ; Take the first element from the array
) o" v/ P4 e( ` full_path = %word_array1%1 \# n$ {& h3 }; C/ ?' v3 ^' b
; strip to bare address
7 ] B& x5 g t, a! D" V, O! ^ full_path := RegExReplace(full_path, “地址: “, “”)$ I# k$ {2 C" n; d+ V3 U, Q' k! B
; Just in case – remove all carriage returns (`r)( o! q# j6 ^% n# }/ i) k4 U- R8 k
StringReplace, full_path, full_path, `r, , all
5 a i5 k! G- }8 n- J" I6 o IfInString full_path, \
3 r7 j7 O$ ]" H/ j. t {) n; x% n2 T Z. I& w
Run, cmd /K cd /D “%full_path%”9 B6 ~0 d+ A( O$ s
}+ E* [: o+ w, L
else
( @/ x" O. ?# y( x {
0 p3 \ q) j/ O& p1 d2 ]! K- B+ g Run, cmd /K cd /D “C:\ ”
7 v- k3 Z$ t" m5 ] }
& j% {5 Z% r4 X1 r8 o3 B/ X }" N8 |! p2 `* e
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' A; P( e9 d$ Q6 ~ b. x8 S" E
这段小代码肯能有两个你需要修改的地方" L, _* B* ^+ w/ X
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
4 r3 l8 K. t9 i' h 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “8 J* {) Q! ?; {5 P- c
|