此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% A0 v H3 t0 T1 Q1 ~: v4 z# r2 ~! _
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
; c0 T4 ]# a/ k# N2 b 方式一:- W' }3 I8 r: |$ ?( A8 l
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
! |5 j1 ?" d5 ^ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和9 G5 [# S' a6 T( f: \
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- O! V2 b8 g/ N4 O$ L( k
方式二:
/ `0 `7 D6 D9 k3 {) y 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:; |2 O: H }, G, n7 ]) ~* X
SetTitleMatchMode RegEx- R' L f2 E9 h5 P1 _( K+ M% z" [0 X" o
return8 ^' w' d1 B( M" h8 t1 D
; Stuff to do when Windows Explorer is open" B5 q* i% `) `& [( S+ _/ B
;1 n* l" Q9 P( K4 Z
#IfWinActive ahk_class ExploreWClass|CabinetWClass
0 a, T3 M+ _4 n+ c6 Z: |) i+ \ ; open ‘cmd’ in the current directory
2 e* C6 I7 ~/ T0 | ;
$ ^" C! X5 L$ T/ ~) m# a1 s #c::+ A: o9 U; d7 H
OpenCmdInCurrent()
8 P3 \8 T! F3 d' M1 n3 | return
6 o% ~- ]* H4 `& z8 | #IfWinActive
4 y0 @3 u) }' j& Q0 F9 n( ~ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( ^0 b: a8 l$ O, \1 W3 @0 o ; Note: expecting to be run when the active window is Explorer.4 z0 p" ~- ~- h: K1 o
;
2 Y0 Z V4 f% R8 y$ H OpenCmdInCurrent(), x3 e2 ~& n0 _4 m
{
) U% E2 Y- m! [: |% p( D3 u6 Y+ o8 ` ; This is required to get the full path of the file from the address bar! [8 \" r4 g; S6 C1 s! e
WinGetText, full_path, A
1 j; C. K# l1 h8 Q, l- Q ; Split on newline (`n)/ R% m K+ E9 w0 c3 E
StringSplit, word_array, full_path, `n F- L; s: p9 H5 u* e" R6 j
; Take the first element from the array- I4 [: v2 v" A9 `
full_path = %word_array1%
4 s: k. x+ L% W8 h$ ?; {3 ?$ x ; strip to bare address
. U/ i( a8 x. | H full_path := RegExReplace(full_path, “地址: “, “”)
2 i2 E% `1 t4 x5 k2 p6 s3 v ; Just in case – remove all carriage returns (`r)1 D- P) p6 O# O9 G1 n
StringReplace, full_path, full_path, `r, , all
6 w4 Q6 f6 K; o4 O IfInString full_path, \
6 e. P8 J \/ w S# R+ J: t7 U7 ` {
4 O/ Y! l" _0 A9 n2 ? Run, cmd /K cd /D “%full_path%”. b, p2 |! K. Z
}
7 i4 p, ^& n% h+ e4 S else( b6 w- i9 j4 C8 G2 b9 ~
{
6 M7 o% N$ f) S H; a% t Run, cmd /K cd /D “C:\ ”
% S- D* o! p8 S) z }
( p6 z3 ?% u3 a% K- j }
( H$ Y$ U+ G( j' A q8 H6 T* I+ C" l 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。2 @- c% P/ o* n: x
这段小代码肯能有两个你需要修改的地方
* M% J- U" q& k+ J6 `) q5 X4 s& v 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键6 ]. q) i% N2 A
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! G2 j9 H' L l# P U3 V/ }& c1 {+ A |