此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 b5 t4 @( Z# u# a2 D5 n! y- S, z* [8 ? 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。) h+ v8 c# q e8 D# _* E8 g- ^
方式一:% n; x; W5 b1 l9 F( I
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
( |! A+ n) I; @' [5 }- Q; Y( m/ P! O 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和* `0 C! {' P0 {1 c5 b/ _. ~
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 o! H& k7 H1 W i* m
方式二:4 u6 h q' _1 a8 ?: p5 \
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
8 R1 P! \8 D& w. O SetTitleMatchMode RegEx: T- G' M, C) T. k4 i% o
return$ b/ [1 a5 r$ g$ W1 ?; ~
; Stuff to do when Windows Explorer is open# ~3 a# s& q7 ]- [+ s
;
3 R1 l' Y$ i6 f Y #IfWinActive ahk_class ExploreWClass|CabinetWClass
' [. b1 n& Z& X; c. Y ; open ‘cmd’ in the current directory
# y8 k) C& {) C# R P ;
# \( o+ S# T9 a8 v6 c: ^& S/ k# a* Q #c::
1 F) Z" D7 `3 }! c% j OpenCmdInCurrent()
, P! ]+ U* [5 i# _- q; b: j$ Q* h' R. M2 b return
9 n, R! h, q$ a: C( k #IfWinActive
r3 U5 b9 E& L J1 L# N. T* K; W ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
5 W% d! W, L, O- { ; Note: expecting to be run when the active window is Explorer.
0 F. P9 k& H: \+ Y7 N, M% a ;
, c; }$ c6 K) b! I OpenCmdInCurrent()) ~% V: L( w% G1 f' L* ?+ ?" P
{
! B" ~9 m# H9 C9 i ; This is required to get the full path of the file from the address bar$ D9 J s/ }/ b% R
WinGetText, full_path, A/ q. b- b3 ^0 W/ |; q$ O
; Split on newline (`n)
$ B" S; f! q6 ~* F9 N4 c3 X StringSplit, word_array, full_path, `n6 D, N' M* ^9 ? y% J9 E. z$ X {
; Take the first element from the array9 k' {2 W( y3 d
full_path = %word_array1%/ X8 ^' A: |( U/ _+ o1 L
; strip to bare address
' t1 {: U: Y: Y* S' e0 L7 B2 \ full_path := RegExReplace(full_path, “地址: “, “”)
) R% u. N" S% U* J( c% i! S7 n ; Just in case – remove all carriage returns (`r)" b# F* A7 |$ f
StringReplace, full_path, full_path, `r, , all
) X6 O6 Y G: ? IfInString full_path, \
' U- g: [, p" u {
, c) q+ l1 g G: `# u9 ^1 G9 @- N Run, cmd /K cd /D “%full_path%”
; e( Y) j" c, C9 d) s) A! @- ] }0 _! W+ x! l9 J$ e4 i
else' x) V) x4 Y# ^3 |! o# H- `
{" U9 w' u2 t$ }/ a
Run, cmd /K cd /D “C:\ ”0 a# K- c ^* `& P6 f( d
}
5 s4 e8 D" ]* T7 H, a q }1 d% n2 p) l+ e- R
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: \; p4 J$ H' G7 Y 这段小代码肯能有两个你需要修改的地方
3 f6 h$ i* H$ J. E 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键# [7 E( a: M5 \; i
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
6 m0 n& w+ R4 i1 z1 L |