此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。* X& H/ k5 N5 N7 A! k
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
) t: g# o8 O! p' |1 T 方式一:% n9 a) ^5 ^4 q; Y/ V
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表," M, E+ g4 r7 X% B. A1 t
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
* s/ i- i, W# G2 o7 q: [- a HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。9 H% _& g. C1 d9 ]; l! u
方式二:
1 ^2 f* g5 _; n7 K2 k P 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:" q, m* j# y; m" S* E- g7 U
SetTitleMatchMode RegEx
- Q" }5 a* k0 f* J return# o$ q& h: n5 ]" ^
; Stuff to do when Windows Explorer is open O" i: L. H) b ~2 T
;. B5 J8 ]4 p" l, }+ B- _1 ~( r9 ?
#IfWinActive ahk_class ExploreWClass|CabinetWClass; G( Z) _0 e3 m& `+ P, X
; open ‘cmd’ in the current directory
" G m3 x) r8 q/ J1 Z ;
- a" b D& v$ h. L E #c::
/ r( @9 r7 h4 P$ M OpenCmdInCurrent()9 _+ H+ N: I+ n8 C4 w! K
return
7 s* I% I7 I; [' k( ]: C( `/ k #IfWinActive
; f( r+ d: ?3 {1 j* n ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
5 E( g* x5 t* [8 j6 U. ^0 Q+ | ; Note: expecting to be run when the active window is Explorer.4 e" m& W: d; ~, j
;$ W; X* C0 D0 J; o
OpenCmdInCurrent() A0 f9 E5 X2 H( X
{2 Z( O* g0 c8 g e% C1 C9 X/ C! }4 _
; This is required to get the full path of the file from the address bar4 k2 c- A% r5 A
WinGetText, full_path, A
+ T8 e* f9 d7 I$ ^* b7 P ; Split on newline (`n)
F) ?; d# B7 l7 d StringSplit, word_array, full_path, `n
9 z4 x& y. N) c$ `5 V2 h' T- c ; Take the first element from the array
/ ]2 q0 @# H; Q C) k/ w full_path = %word_array1%
Y8 L; K8 t2 |. | ; strip to bare address W1 t4 o% F; U9 j' ]' i1 v& |
full_path := RegExReplace(full_path, “地址: “, “”), s& x: o0 Y3 Y9 o
; Just in case – remove all carriage returns (`r)! t2 \+ x f5 j. [8 E2 U1 `, M* _
StringReplace, full_path, full_path, `r, , all
, N4 s2 a( O: o% p: X5 q IfInString full_path, \
_( h! O- x$ t8 D$ ]9 Q {! h* m& `$ _8 Q: u
Run, cmd /K cd /D “%full_path%” ~; p; i. A4 a
}4 J7 H) R5 @3 ^+ h& k5 w
else
) d* ^; I1 c+ m9 J F' C {
4 C! X5 z( }- v3 P$ d Run, cmd /K cd /D “C:\ ”4 R4 w' i" u/ z* {
}- p% ?9 R$ U; u- b9 }, Y
}- h- \- J' R8 b; ? ^: F/ d
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: a" P% E" }4 i& s7 U8 G 这段小代码肯能有两个你需要修改的地方) Q. n+ T( E+ g
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键- Z+ c) R: O+ L: Z
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 _1 Y( |( D; }* E/ A |