此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 N8 ?3 `& g$ V& q
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。 S8 I6 _' g0 u
方式一:
" A8 @# x( D( b0 C0 }. r' f+ G0 B 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
! g" h* E& c- x2 b9 R. S; H! Z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! D" J9 w. G7 ^ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 p& \2 r; a8 y2 x& b. N
方式二:
" \ j y2 L+ C& X5 I 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
: \7 l `( B; S* r$ l* W SetTitleMatchMode RegEx' }7 {; o) c5 C# X, V+ n
return. y' i0 |; h2 u: y
; Stuff to do when Windows Explorer is open
6 b2 J1 K- B/ z! }$ o7 x% t ;; D. G( l) I( n k
#IfWinActive ahk_class ExploreWClass|CabinetWClass0 u. O1 Q$ g* \8 H/ Z5 J
; open ‘cmd’ in the current directory- p' M3 d* C1 T$ m5 b4 H
;3 Z0 g% {% x N; s, H7 U4 B c# I. G0 [
#c::) y- ?( h# \/ o
OpenCmdInCurrent()
& C0 N# ]6 x" n* Z# y( k return
1 |$ `/ _& m- o: \" H! N% f #IfWinActive
4 l$ k% N* G" O9 [3 p) n ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 m# N3 L, Z: {, \
; Note: expecting to be run when the active window is Explorer.# w |% G3 v& w" ~6 l# }. V
;
6 C7 t7 d$ _) i- u2 }1 R OpenCmdInCurrent()) o) |2 L9 \% A2 @9 ?$ z6 F
{) Y: b3 b! J( R0 I `+ m; [
; This is required to get the full path of the file from the address bar; _' S. a j6 ?- n
WinGetText, full_path, A
9 N0 s* y) x5 E2 z% e. t. F- o/ Y ; Split on newline (`n)8 Q4 I4 I9 F$ v, U- I. ^$ Q' X1 L) t7 X
StringSplit, word_array, full_path, `n
" L9 c& f+ N" ] ; Take the first element from the array% V1 w# q7 I! S" h$ C! j0 W* \
full_path = %word_array1%$ D2 Y; S6 B3 a4 t
; strip to bare address: e, H0 M- W% s( _! ?
full_path := RegExReplace(full_path, “地址: “, “”)
7 @4 ^' X' Q: ?6 }' m4 O ; Just in case – remove all carriage returns (`r)
1 T7 k3 n4 ^! ~3 [ StringReplace, full_path, full_path, `r, , all
6 N( S( K4 P8 M% u IfInString full_path, \
- n4 ?( o; Y. c! ^% l, o; k' X; A {
* J o1 X+ ?1 [* w Run, cmd /K cd /D “%full_path%”) G4 f2 V) Y. S0 g
}
- t" u) j e0 o0 [9 @8 ? else
) p. x7 N" y0 E# Y3 \. t6 G {( e( e C6 g, ]% W7 M, O
Run, cmd /K cd /D “C:\ ”* Z0 ^5 D0 P! H7 R
}
1 z4 i8 |. c9 w8 }' U }1 F" \/ u0 P A6 {4 o) N$ U( G' E
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- i8 L8 E" t. l: p! J2 r
这段小代码肯能有两个你需要修改的地方
9 S+ p2 s0 b0 {; d. J- o 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
- d; `7 Y) F& S) y( W# Z1 [* r 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “& f u5 B% y b. [5 H/ Q- m. J0 i
|