此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# [5 S, }! s Y8 }
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: J" H2 ?6 ]% d" C
方式一:
# D# R+ b8 M3 H6 H) e 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,' [/ [2 J& R, C- D
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 }! M* ?% \, D HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 _3 @4 Q+ p) i7 [6 _2 N& u; U
方式二:0 _" y( T% ^5 [) E
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:. k# n2 D9 J5 l* z5 W
SetTitleMatchMode RegEx
. \3 Y! \$ X- S' w return0 Q' T" H! C; |& Y. G
; Stuff to do when Windows Explorer is open! N8 w% Y9 y& o6 e+ Y% P% _
;2 x6 z. T* i. U
#IfWinActive ahk_class ExploreWClass|CabinetWClass; i8 x; L& S2 S, B. `4 C' ]& Z
; open ‘cmd’ in the current directory. }6 [. `+ i4 S% D# K+ q" a
;+ |" |3 |: D/ r' T
#c::: r9 H) H. m9 l( y6 M2 {
OpenCmdInCurrent()
# T h" f: w1 r% J# K: V return: w& j7 B* g, [, b0 h9 ?
#IfWinActive
+ i: B% f7 U& S, Z ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
" j x" V9 q, b6 `2 T ; Note: expecting to be run when the active window is Explorer.
' r! ~9 U' q" _% {) |' R+ f ;% G. R- N2 F) d, s: B" |5 m
OpenCmdInCurrent()
- D9 U7 S9 I' k6 H2 ^( m6 {+ O) n {
t# g0 i: s' f& i2 n# _, m) d ; This is required to get the full path of the file from the address bar
. E3 t* t; ?* }* k1 z WinGetText, full_path, A, ^( `% k3 P- \: n2 Y# V, n- y2 g# A
; Split on newline (`n)
& {; T! a+ u$ l# J StringSplit, word_array, full_path, `n* D8 M7 _7 E ~7 o( w8 k
; Take the first element from the array+ Q$ a% H0 ?! f& q( t% Y2 {
full_path = %word_array1%$ r: m9 l" j1 v. p
; strip to bare address
% |' o' |/ c |% R* Q, Q: K' V full_path := RegExReplace(full_path, “地址: “, “”)
, g" F* P- \* X5 f& ^: J ; Just in case – remove all carriage returns (`r)
" m1 m# V) D; {- ` StringReplace, full_path, full_path, `r, , all
9 K/ Q5 r# S7 w3 U4 ]# \2 V IfInString full_path, \/ T7 a" ^7 \. \ P
{- w$ l8 H/ Y7 Q" j
Run, cmd /K cd /D “%full_path%”8 W3 {! r" C9 T* u
}
; g6 J; q \- c5 ^0 t' G8 ^ else. c3 b+ M t8 I' R
{3 G/ _% v& M1 l6 P& H/ C+ |
Run, cmd /K cd /D “C:\ ” a9 m3 p. G" D& |. E5 U8 ~1 L0 {
}. l: I! r3 y% D; h4 z4 h3 s
}/ ^9 _; \3 b0 ?, c( f
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
, o, Y; E$ O% c2 n- O( A3 C 这段小代码肯能有两个你需要修改的地方0 P- u0 T# h1 ], Q. R) B/ z
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' m& y* b/ j& _
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 ?, Z( O0 p# {. L: c" F
|