http://jiyucheng007.blog.163.com/blog/static/23057221201031372529435/
[AHK]鼠标滚轮音量调节
;使用:按住鼠标右键,滑动滚轮调节音量。 ;2010.04.12 ;NiGH优化. #MaxThreads 6 #InstallKeybdHook color1 = 6BD536 color2 = FFFFFF color3 = 94632D color4 = FFCD00 color5 = AA55AA color6 = FF5555 random,n,1,6 barcolor := color%n% ;取随机色的写法,我会看下色彩的理论,再写出随机生成颜色的代码,因为我还不知道计算明度跟饱和度的公式. current := 80 ;初始音量值 gui,1:-caption +alwaysontop +owner ;去标题栏 gui,1:margin,0,0 ;去边距 gui,1:color,3F3F3F ;随便设置一个背景色,以备后面设置透明用 gui,1:font,s16 cwhite,Arial gui,1:add,text,x7 y0,- gui,1:add,text,x190 y1,+ gui,1:add,progress,x21 y2 w165 h22 c%barcolor% background3F3F3F vMyProgress, 80 gui,1:show,w208 h26,mainboard ;~Gui,1:+LastFound ;设置为LastFound ;~GUI_ID:=WinExist() ;获得窗口的句柄 winset,TransColor,black 200,mainboard gui,1:Hide send, {volume_up 50} send, {volume_down 10} ;我的win7用volume_up&down,效果出来都是双倍的,up10就是加20,下同 SetTimer, Check, 50 SetTimer, MenuCancel, 30 Return Check: GetKeyState,T,Rbutton If (T = "U") { ;~DllCall("AnimateWindow","UInt",GUI_ID,"Int",500,"UInt",0x90000) ;以淡出的方式退出 Gui,1:hide SetTimer, MenuCancel, Off } If (current > 100) current := 100 If (current < 0) current := 0 Return MenuCancel: IfWinExist,ahk_class #32768 WinClose,ahk_class #32768 ;在右键菜单出现时关闭它(因为它会遮盖住音量条). Return #IfWinExist, mainboard wheeldown:: If (T = "D") { SetTimer, MenuCancel, On Loop,5 { current:=current-2 GuiControl,,MyProgress,%current% Sleep 50 } Send {Volume_Down 5} } Return WheelUp:: If (T = "D") { SetTimer, MenuCancel, On Loop,5 { current:=current+2 GuiControl,,MyProgress,%current% Sleep 50 } Send {Volume_Up 5} } Return #IfWinnotExist, mainboard ~wheeldown:: If (T = "D") { SetTimer, MenuCancel, On gui,1:show Loop,5 { current:=current-2 GuiControl,,MyProgress,%current% Sleep 50 } Send {Volume_Down 5} } Return ~WheelUp:: If (T = "D") { SetTimer, MenuCancel, On gui,1:show Loop,5 { current:=current+2 GuiControl,,MyProgress,%current% Sleep 50 } Send {Volume_Up 5} } Return