此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
! P+ w( S( Z6 y, }% h* o 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: b+ e5 Z; e; g3 x: g
方式一:
8 s' Z8 k4 e8 Y+ ?% [ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
" C: k5 G0 }/ b: y* v5 \# a1 V 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和 @ F ]1 I9 u5 Y0 w8 c1 n
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ C7 M T* e3 ~* A" A 方式二:
1 n( Z7 V- q1 h# V9 { 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, i( o k. z' @" g: b
SetTitleMatchMode RegEx
5 K7 Q0 j9 V- C7 O return
0 z( r, w- s; j0 \: Z ; Stuff to do when Windows Explorer is open6 G- X) a6 g1 g' l" R6 N/ C
;+ P0 ~6 W/ ]/ N1 u
#IfWinActive ahk_class ExploreWClass|CabinetWClass
% \1 A0 F6 s& F3 Y1 m. r3 z; Z S ; open ‘cmd’ in the current directory8 ]# ^: W: l: z c- j8 ?) b* g" E" `
;7 \$ M# L9 X" g) V; Y) N
#c::" b' Q1 W0 s V8 v1 q- x, H$ E" b$ f
OpenCmdInCurrent()4 H& _. v) q4 |6 }% F6 l( f7 j; u
return6 E" X0 i" u. G1 t# B( h, s7 Z
#IfWinActive* g+ l0 x1 D, p7 E* M
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 }3 o( m6 ~ M1 x. | ; Note: expecting to be run when the active window is Explorer.* e8 A V) g, V* q: s
;0 s9 l3 g' {5 ^2 X
OpenCmdInCurrent()
8 a7 @, [8 P0 M4 c4 S* r1 q# L {
( H" t! m8 C! k6 S: K# j ; This is required to get the full path of the file from the address bar
; H6 U" k- ^; y1 N' \ WinGetText, full_path, A
1 S5 f) v- J: Q, T ; Split on newline (`n)
& \" Z+ W; A3 ?- i* v8 `7 ] StringSplit, word_array, full_path, `n- w Y$ Y9 j: H2 R) P8 r+ Q
; Take the first element from the array
% ]7 z+ K9 r: a6 ]+ i/ n$ s- H ^ full_path = %word_array1%
4 \* H$ w" S7 p% T: w! l+ M ; strip to bare address5 _6 @( r0 {, z6 \
full_path := RegExReplace(full_path, “地址: “, “”)
2 }4 W& H! A; }( P& A+ O$ T- K4 [ ; Just in case – remove all carriage returns (`r)
]- T/ v3 N# h0 g" C1 Z StringReplace, full_path, full_path, `r, , all
$ X* m2 `9 T3 A1 L4 T# d( g: `. `" c3 Y IfInString full_path, \8 A9 L7 p! s6 T% D7 O# z, Z" g2 G% _
{
& }4 y9 ^8 I8 T& X: h( U Run, cmd /K cd /D “%full_path%”2 o; x4 Q2 A0 f+ h
}
8 H$ w1 [$ d6 |% m else
" W" A0 I5 M7 z$ H {8 @4 C7 O$ K( V* e
Run, cmd /K cd /D “C:\ ”
" E* H! v. k9 U }
" [8 X1 e% j8 U3 v! ~ }
& t* h4 n: l- a: \ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 A/ ~7 A9 `1 Q: l" f6 I8 b9 ~6 x 这段小代码肯能有两个你需要修改的地方
: p; x+ {6 F1 S2 |& E8 Z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
8 p4 W( ]5 }+ h* t5 s8 ` 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
: T$ z9 h- e% S: }$ F |