此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
1 v: |' S* p7 g& e5 u. y$ I 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% _$ w" O" f) @6 O0 ^
方式一:7 ^; p' i7 Z0 [$ p, u; _
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- m4 [; I9 V1 i5 S) c' G8 ? 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) L& e0 N% l. v1 C& c" T
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。) e- P0 I2 f* W ^
方式二:* i+ {; b/ W2 O* m7 u
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ N4 ?0 w4 d9 A. d SetTitleMatchMode RegEx, q4 m4 G1 X y& ~% W$ l' Z
return
1 v' q6 i" @. M+ x0 N ; Stuff to do when Windows Explorer is open/ b+ y/ n* q5 |8 D+ m2 V5 ?
;
4 N- ]0 `5 I# {; } #IfWinActive ahk_class ExploreWClass|CabinetWClass2 S" H2 h1 w, b/ S, e" l0 Q
; open ‘cmd’ in the current directory
: A4 d' a) h4 @, ^9 @ c ; F# J' e/ I+ p! m0 j0 ^" q* V
#c::8 v: B7 W3 u+ A
OpenCmdInCurrent()# K- E) D. A1 Y) [9 P, L
return
. i, _/ a! Y. D #IfWinActive
' W3 U$ g( N+ x3 k+ s/ J ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
! G4 G* u$ X1 c; C& ^: N ; Note: expecting to be run when the active window is Explorer.. ]8 t( x0 J( k$ _* @: S1 `
;
0 d9 E2 T% H$ M @; w) l OpenCmdInCurrent()8 R3 e" u, N* Y& S& B& Z1 L; {
{: V1 d4 r' v' P3 A! w
; This is required to get the full path of the file from the address bar
( Z* Y! l% V6 R WinGetText, full_path, A. u) I9 U8 ]3 {8 L
; Split on newline (`n)
! s9 ~) Q4 D; ~3 { J* P StringSplit, word_array, full_path, `n# X; M# b+ s! B. l b1 A
; Take the first element from the array" d: ^ _9 f' Z/ D* g3 q) g
full_path = %word_array1%
7 Z/ r5 L$ |' P6 A5 w ; strip to bare address! M8 l; o9 t3 q, F$ z
full_path := RegExReplace(full_path, “地址: “, “”)+ o% _, [% \7 l9 w; r. {" `2 X
; Just in case – remove all carriage returns (`r)! l E) q2 _0 R, j- ?
StringReplace, full_path, full_path, `r, , all/ u* c2 h' |1 S: `; n
IfInString full_path, \3 K# e$ `8 U% m# M# H
{
2 x4 m" a( l2 f: u4 I Run, cmd /K cd /D “%full_path%”
3 H2 t0 r. B: T V: I }7 C9 U4 G6 G: S/ P- `0 d3 u
else
+ `6 k; h- H9 Y6 j8 A& I {
) i/ w$ Q, w, V" f+ }. E Run, cmd /K cd /D “C:\ ”+ B% h s2 q+ G a, @
}
' w3 n% g% [' D3 F. D9 n }
/ F5 @& E9 [- u5 B 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。# }' r( {! b- i, |5 P+ P
这段小代码肯能有两个你需要修改的地方+ i# ? Q; D+ C( ?
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) z8 g- I, ]3 I0 x4 |$ t! M 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “8 |6 E1 }6 C8 k
|