此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
& t4 _: w# a, B, M 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 f- v* z6 G. U- } 方式一:, |! W8 P4 ^" @" l5 X5 W8 h
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* p4 C( X9 d! W z
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
. e* h& }1 e% u6 V1 S* I* C7 Z HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。$ w% F7 v3 r) e6 l
方式二:$ ~2 p! M" Q1 Z" f. F" n, C
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: Z& t1 X; ?8 r9 |: A6 u
SetTitleMatchMode RegEx' v* Z& L( X& J! c& U7 C: I
return+ j2 F' ?; ?, e+ _4 i
; Stuff to do when Windows Explorer is open
- { C3 R8 n- s# o* k5 ~ ;# h8 I/ {! L8 X0 z
#IfWinActive ahk_class ExploreWClass|CabinetWClass' {& j1 S. O( g' G' b$ {" h- q
; open ‘cmd’ in the current directory
$ O0 r. Y# P6 d. E) [' r n ;; V! V& k" V( y9 h& U8 r# J3 [
#c::. z$ s" n% o5 ~
OpenCmdInCurrent()
$ T# `9 m/ d: F2 G+ W0 r return( D. Y( q% l5 \6 _& G& u3 ^
#IfWinActive
: u* J4 e0 O7 ~9 p5 `7 ` ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
- H9 ]: c3 c* G W: q b7 a7 `% P ; Note: expecting to be run when the active window is Explorer.1 V8 B0 q1 k. z- H" R" y
;
/ p0 ], B- M6 R% y0 M$ F OpenCmdInCurrent()
* R3 V3 J4 P( f! p2 f2 a. Y" j0 I {. y5 X v5 Z7 Z1 [" ]! r: O5 {
; This is required to get the full path of the file from the address bar4 r9 M; I6 X- v+ T
WinGetText, full_path, A
$ D; ?) e; ]* B) B- a, Q ; Split on newline (`n)
' }8 i' I9 W3 X9 ~0 S StringSplit, word_array, full_path, `n/ C! c1 j/ j' L/ z; I9 |: t! U
; Take the first element from the array6 [& x* E, P D9 q( ]
full_path = %word_array1%2 T5 i* l8 S% e7 x
; strip to bare address4 \; y. e4 b+ }/ i7 w% i5 o6 v& g
full_path := RegExReplace(full_path, “地址: “, “”)* p* u3 }, y6 B* N4 T7 h" r% o
; Just in case – remove all carriage returns (`r)( N& m5 z5 G+ w A. {
StringReplace, full_path, full_path, `r, , all
o0 w T- X4 a; b# i, b IfInString full_path, \
! S: C, E7 C$ K* S {
, S- `# S3 w3 |1 i0 |7 \+ z% [ Run, cmd /K cd /D “%full_path%”
" `+ ?0 J, Z5 J- @ L5 p1 j }
0 q. W; n3 I& C! T: |$ } else A' C; [" q* X# P
{
$ O3 [* j- }; _; m) y# } Run, cmd /K cd /D “C:\ ”' X$ N/ Z% t) I! A+ @
}
' K* F* v- G, h# i2 ?/ r }
+ t. J" a) ~5 o' }! W! `+ _6 V 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& r1 @) N+ }3 |9 y w
这段小代码肯能有两个你需要修改的地方1 y( s2 ` D- w4 J/ \! B) u
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键4 A% I8 D& {0 Z9 L) b
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “0 b+ H9 Z7 N+ Y/ s% S6 R" M% t5 M
|