此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。$ B9 B3 x- L6 P% e* s1 G
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
6 v" s a+ |3 B% W5 q 方式一:
& s) ~' g3 W+ G: m. E 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- {7 c! c N S N$ u. T- q. R6 z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
% K0 M& ?; [5 Q& \0 o, s Z, c HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) }& ^$ v2 L1 u _' a 方式二:- x* q% j7 x$ i. q
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
9 i* T& i/ _* Z1 F8 ] SetTitleMatchMode RegEx# V1 \1 o0 k& ^* [
return. U; n( }* [1 y9 ^6 ^) E8 q; v# s
; Stuff to do when Windows Explorer is open
- T; _6 Q( T) p L* ] ;( O+ o7 `2 e( U- r6 ]; L8 _3 R
#IfWinActive ahk_class ExploreWClass|CabinetWClass
) a2 g+ x: P% \: ~, ]4 l! h8 k% _3 [" ~" R ; open ‘cmd’ in the current directory$ R2 X" n4 Q5 X: I3 o& }* L+ V
;' c8 T" k" T% N& l m
#c::
$ F( ` n9 v/ c2 H OpenCmdInCurrent()
! [/ Y% A2 n" ?/ R2 W& H, ^- b return( M# B& P4 X( D. R8 p6 U: x
#IfWinActive
3 {8 I0 L0 g3 t: Q% f ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
`3 x* ^9 ]) X4 H. a ; Note: expecting to be run when the active window is Explorer.
4 O" z8 X, W) V( n ^- f7 k ;) p/ m5 q' {, l5 V' q- O
OpenCmdInCurrent()
4 d5 k8 s' }3 N" E. N$ d- O! Y {
( M% b5 t2 b1 s1 y ; This is required to get the full path of the file from the address bar
/ r) J. O U0 ~. K8 W& w3 a WinGetText, full_path, A1 _6 d/ z; h; U# h& z2 E4 d
; Split on newline (`n)6 _) D u( P0 t2 G$ i0 [
StringSplit, word_array, full_path, `n
; m$ v+ ?6 D: K2 v0 H9 r q# y3 G ; Take the first element from the array
/ T7 Q/ N8 M/ C- U5 G full_path = %word_array1%4 K. P6 @5 `& r5 d- Q
; strip to bare address
6 }: N' W4 i( `& | {9 ]3 s$ m full_path := RegExReplace(full_path, “地址: “, “”): C! [ {4 ?2 e: s- s
; Just in case – remove all carriage returns (`r)( F! v7 H. d4 x0 ~% r6 I. J
StringReplace, full_path, full_path, `r, , all
$ G7 ~/ Q8 R& c IfInString full_path, \; b$ S/ `3 Y* W
{
9 Z# M* J' a& {' w Run, cmd /K cd /D “%full_path%”$ Q. P- N' z% j) X& B
}+ @% N8 V+ n% W: [; Q' ?
else
/ J& r) j1 p9 K* v {' }/ Y Z' a# |" `
Run, cmd /K cd /D “C:\ ”
& R( U2 l- m- \2 x/ U }6 ?/ e% S l$ N# q% t5 s
}
% \. U; `- v2 ^" Z7 \ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: b: {; y8 y' w& Y* b0 \; k 这段小代码肯能有两个你需要修改的地方: y$ H5 o5 z3 v1 ^
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键# Y( Z+ {. { ~8 |6 d
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “# M" x4 N* N! Y& @
|