hjf

Wednesday, June 15, 2016

Volume Revolver - Sound control with the mouse wheel


Volume Revolver V1.0



If you listen to or watch media on your computer then you know it can be a pain to change the volume sometimes, especially if you don't have a media keyboard. Lots of people (including myself) like to use apps that utilize the mousewheel for quick, on-the-fly volume control.

There are a few programs out there that work well, but most have a bunch of extra stuff I don't use or need and even though I have a large hard drive I prefer applications as small as possible. There is nothing wrong with those programs and if I hadn't written my own I would certainly recommend them, but today I bring you Volume Revolver V1.0!!!

Volume Revolver is a very small, quick, and efficient program that, as stated above, controls your computer with modifier keys and the mouse wheel. For example to turn the volume up slowly (precise) you would hold the 'Control' key and scroll the mouse wheel up. To turn the volume up fast (+10 each scroll) just hold the 'Shift' key and scroll the mouse wheel up etc.

Volume Revolver is an AHK script compiled for portability and dependencies, if you would like to use the actual script you must have AutoHotkey installed.


Usage:

To use just place the portable executable wherever you like and run. It runs in the background, but has a system tray icon with options and a help screen, but the help screen can be accessed via the Control+Click Wheel Button. You can set this to run at startup with a system tray option and if you move the application there is a fix startup button to reset the old startup entry and prepare for the new one.

Screen of the 'Help' window

Downloads

AHK Script Source

#SingleInstance, Force

;Variables
SetWorkingDir, %A_ScriptDir%
_vttclss := "ahk_class tooltips_class32"
_vThsScrpt := A_WorkingDir "\" A_ScriptName
;_vIco := A_WorkingDir "\volumerevolver.ico" 
;Menu, Tray, Icon, %_vIco%
_fRgRd(_vThsScrpt, _vIco)
OnExit, gsAppClose

;End Auto-execute
Return

;Hotkeys
~^MButton::_fHlp()
^WheelUp::Gosub, gsVUO
+WheelUp::Gosub, gsVU
+WheelDown::Gosub, gsVD
!WheelUp::
 SoundSet, 0, , mute
 _fGtSnd(_vttclss,"1")
Return
^WheelDown::Gosub, gsVDO
!WheelDown::
 SoundSet, 1, , mute
 _fGtSnd(_vttclss,"1")
Return
;gosubs
gsRld:
 Reload
Return
gsTT:
 ToolTip,,,,1
Return
gsVU:
 SoundSet, +10
 _fGtSnd(_vttclss)
Return
gsVD:
 SoundSet, -10
 _fGtSnd(_vttclss)
Return
gsVUO:
 SoundSet, +1
 _fGtSnd(_vttclss)
Return
gsVDO:
 SoundSet, -1
 _fGtSnd(_vttclss)
Return
gsRgWrtEn:
 RegWrite, REG_SZ, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run, VolumeRevolver, % _vThsScrpt
 _fRgRd(_vThsScrpt, _vIco)
Return
gsRgWrtDs:
 RegDelete, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run, VolumeRevolver
 _fRgRd(_vThsScrpt, _vIco)
Return

;Functions
_fRgRd(_vThsScrpt, _vIco){
 Menu, Tray, DeleteAll
 RegRead, _vStts, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run, VolumeRevolver
 Menu, Tray, NoStandard
 Menu, Tray, Add, Volume +10, gsVU
 Menu, Tray, Add, Volume -10, gsVD
 Menu, Tray, Add, Toggle &Mute, _fTgMt
 Menu, Tray, Add
 If (_vStts = "")
  Menu, Tray, Add, Enable at &startup, gsRgWrtEn
 Else
  {
   If (_vStts = _vThsScrpt)
    Menu, Tray, Add, Disable at &startup, gsRgWrtDs
   Else
    Menu, Tray, Add, Fix &startup, gsRgWrtDs
  }
 Menu, Tray, Add, &Help, _fHlp
 Menu, Tray, Add, &Reload Volume Revolver, gsRld
 Menu, Tray, Add
 Menu, Tray, Add, E&xit, gsAppClose
 ;Menu, Tray, Icon, E&xit, %_vIco%, ,16
} 
MouseOver(_vXa, _vYa, _vXb, _vYb)
{
 MouseGetPos, _vPx, _vPy
 _vDtct := _vPx >= _vXa AND _vPx <= _vXb AND _vPy >= _vYa AND _vPy <= _vYb
 Return _vDtct
}
WM_SHOWWINDOW(){
 WM_MOUSEHOVER()
}
WM_MOUSEHOVER(){
 If MouseOver("72","246","192","272")
  _fGCntrl("230","238","42")
 Else
  _fGCntrl("246","246","26")
 _fHdShw("8","64","38","1","2")
 _fHdShw("42","64","72","3","4")
 _fHdShw("76","64","106","5","6")
 _fHdShw("110","64","140","7","8")
 _fHdShw("144","64","174","9","10")
 _fHdShw("178","64","208","11","12")
 _fHdShw("212","64","232","13","14")
}
_fHdShw(_xb, _xc, _xd, _a, _b){
 If MouseOver("8",_xb,_xc,_xd)
  {
   _fGCntrlShw(_a)
   _fGCntrlShw(_b)
  }
 Else
  {
   _fGCntrlHd(_a)
   _fGCntrlHd(_b)
  }
}
_fGCntrl(_vY1, _vY2, _vH){
 Global t15, t16
 GuiControl Move, t15, x72 y%_vY1% w120 h%_vH% 100, 100
 GuiControl Move, t16, x72 y%_vY2% w120 
 Control ExStyle, -0x20000, ,% "ahk_id" t15
}
_fGCntrlShw(_vTStrtIndx){
 Global t1, t2,t3, t4, t5, t6, t7, t15, t16, t10, t11, t12, t13, t14
 GuiControl, Show, t%_vTStrtIndx%
 Control ExStyle, -0x20000, ,% "ahk_id" t%_vTStrtIndx%
}
_fGCntrlHd(_vTStrtIndx){
 Global t1, t2,t3, t4, t5, t6, t7, t15, t16, t10, t11, t12, t13, t14
 GuiControl, Hide, t%_vTStrtIndx%
}
WM_LBUTTONDOWN(wParam,lParam,msg,hwnd){ ; Move window when grabbed and dragged
 PostMessage, 0xA1, 2
 If MouseOver("72","246","192","272")
  Gosub, GuiClose
}
_fHlp(){
 Global t1, t2,t3, t4, t5, t6, t7, t15, t16, t10, t11, t12, t13, t14, t15, t16
 OnMessage(0x201,"WM_LBUTTONDOWN")
 OnMessage(0x200,"WM_MOUSEHOVER")
 OnMessage(0x18,"WM_SHOWWINDOW")
 Gui, Destroy
 Gui, Color, 0093E4, 333333 
 Gui, Add, Progress,x4 y4 w192 h272 cFFFFFF BackgroundFFFFFF, 100
 Gui, Add, Progress,x4 y4 w64 h272 c0093E4 BackgroundFFFFFF, 100
 Gui, Add, Text,+BackgroundTrans +Center xp+4 yp+4 w56 h30 cFFFFFF,Ctrl+Wheel Up
 Gui, Add, Text,+BackgroundTrans +Center xp+64 yp w124 h30 c0093E4,Volume Up - Slow
 Gui, Add, Text,+BackgroundTrans +Center xp-64 yp+34 w56 h30 cFFFFFF ,Ctrl+Wheel Down
 Gui, Add, Text,+BackgroundTrans +Center xp+64 yp w124 h30 c0093E4 ,Volume Down - Slow
 Gui, Add, Text,+BackgroundTrans +Center xp-64 yp+34 w56 h30 cFFFFFF ,Shift+Wheel Up
 Gui, Add, Text,+BackgroundTrans +Center xp+64 yp w124 h30 c0093E4 ,Volume Up - Fast
 Gui, Add, Text,+BackgroundTrans +Center xp-64 yp+34 w56 h30 cFFFFFF ,Shift+Wheel Down
 Gui, Add, Text,+BackgroundTrans +Center xp+64 yp w124 h30 c0093E4 ,Volume Down - Fast
 Gui, Add, Text,+BackgroundTrans +Center xp-64 yp+34 w56 h30 cFFFFFF ,Alt+Wheel Up
 Gui, Add, Text,+BackgroundTrans +Center xp+64 yp w124 h30 c0093E4 ,Mute Off
 Gui, Add, Text,+BackgroundTrans +Center xp-64 yp+34 w56 h30 cFFFFFF ,Alt+Wheel Down
 Gui, Add, Text,+BackgroundTrans +Center xp+64 yp w124 h30 c0093E4 ,Mute On
 Gui, Add, Text,+BackgroundTrans +Center xp-64 yp+34 w56 h30 cFFFFFF ,Ctrl+Click Wheel
 Gui, Add, Text,+BackgroundTrans +Center xp+64 yp w124 h30 c0093E4 ,This help screen
 _fMkHvrBttns("8","1","2","Volume Up - Slow")
 _fMkHvrBttns("42","3","4","Volume Down - Slow")
 _fMkHvrBttns("76","5","6","Volume Up - Fast")
 _fMkHvrBttns("110","7","8","Volume Down - Fast")
 _fMkHvrBttns("144","9","10","Mute Off")
 _fMkHvrBttns("178","11","12","Mute On")
 _fMkHvrBttns("212","13","14","This help screen") 
 Gui, Add, Progress, xp-64 yp+25 w56 h26 cFFFFFF BackgroundFFFFFF, 100
 Gui, Add, Text,+BackgroundTrans +Center xp yp w56 h30 c0093E4 ,Volume Revolver
 Gui, Add, Progress,x72 y246 w120 h26 c0093E4 Background0093E4 vt15 hwndt15, 100
 Gui, Font, s16 cWhite, Verdana
 Gui, Add, Text,+BackgroundTrans +Center xp yp w120 vt16, Exit
 Gui, -Caption +AlwaysOnTop 0x80880000
 Gui, Show,w200 h280, Volume Revolver Help
}
_fMkHvrBttns(_vY, _vVrA, _vVrB, _vMsg){
 Global t1, t2,t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14
 Gui, Add, Progress,x72 y%_vY% w120 h34 c0093E4 Background0093E4 Hidden vt%_vVrA%, 100
 Gui, Add, Text,+BackgroundTrans +Center xp yp+9 w124 h30 cFFFFFF Hidden vt%_vVrB%, %_vMsg%
}
_fTgMt(){
 SoundGet, _vMtSt, Master, Mute
 If (_vMtSt = "On")
  SoundSet, 0, , mute
 Else
  SoundSet, 1, , mute
}
_fGtSnd(_vttclss, _vType = 0){
 SetFormat, Float, 0
 SetTimer, gsTT, -750
 If (_vType = "1")
  {
   SoundGet, _vMt, Master, Mute
   _fIntTT(_vX, _vY)
   ToolTip, % "Mute is " _vMt,%_vX%,%_vY%,1
   _fCntrObj(_vX, _vY)
  }
 Else 
  {
   SoundGet, _vMstr, Master
   _fIntTT(_vX, _vY)
   ToolTip, % "Volume: " _vMstr,%_vX%,%_vY%,1 
   _fCntrObj(_vX, _vY)
  }
 SetFormat, Float, 0.000000
}
_fIntTT(ByRef _vX, ByRef _vY){
 _fGtScrn(_vScrnW, _vScrnH)
 _vX := (_vScrnW / 2)
 _vY := (_vScrnH / 2) 
}
_fGtScrn(ByRef _vScrnW, ByRef _vScrnH){
 SysGet, _vScrn, MonitorWorkArea
 _vScrnW := _vScrnRight - _vScrnLeft
 _vScrnH := _vScrnBottom - _vScrnTop
}
_fCntrObj(ByRef _vX, ByRef _vY, _vTt := "ahk_class tooltips_class32") {
 _fGtScrn(_vScrnW, _vScrnH)
 WinGetPos, , , _vGtTtX, _vGtTtY, %_vTt%
 _vX := (_vScrnW / 2) - (_vGtTtX / 2)
 _vY := (_vScrnH / 2) - (_vGtTtY / 2)
 WinMove, %_vTt%, , %_vX%, %_vY%
}
GuiEscape:
GuiClose:
 Gui, Destroy
Return
gsAppClose:
 ExitApp
        


No comments: