AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Volume-set + OSD script mod

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
catch17



Joined: 07 Feb 2005
Posts: 4
Location: Vienna/AUSTRIA

PostPosted: Mon Feb 07, 2005 11:33 pm    Post subject: Volume-set + OSD script mod Reply with quote

hello everybody,

have read the article in CT´ today and was happy about getting such a tool... - thank you Smile Smile

then I start trying and testing and then I do the mod for OSD-Volume-set-script (I use the script of Rajat and hints from CT´ - thanx to both) -

here it is :
Code:

; AHK-script by catch17
; 07-02-2005

version = 0.9
title = 'Volume_By_Wheel'_v%version%
name = 'Volume_By_Wheel'

SetWorkingDir %A_ScriptDir%  ; To correctly find the icon.

Menu, TRAY, Tip, Master_VOLUME:  'ALT'+MouseWheel`nWave_VOLUME:    'WIN'+'ALT'+ MouseWheel`nVOLUME aus/ein:   'WIN'+'ALT'+'LEERTASTE' 
   IfExist volum.ico
      Menu, TRAY, Icon, volum.ico

; Eigenes Menü erstellen
Menu, TRAY, NoStandard
Menu, TRAY, Add, Hilfe                           , hilfe
Menu, TRAY, Add
Menu, TRAY, Add, Icon ausblenden                  , hide_VolByWheel
Menu, TRAY, Add
Menu, TRAY, Add, Autostart einrichten                     , win_autostart
Menu, TRAY, Add, Autostart entfernen                      , no_autostart
Menu, TRAY, Add
Menu, TRAY, Add, Beenden                                  , Quit_VolByWheel

Menu, TRAY, Default, Hilfe


; Schritte pro "Scroll-Einheit":
vol_Step = 4

; Dauer der OSD Anzeige in Millisekunden:
vol_DisplayTime = 2000

; Master Volume Balken Farbe
vol_CBM = 6666FF

; Wave Volume Balken Farbe
vol_CBW = 9999FF

; Hintergrund Farbe des Balkens
vol_CW = CCCCFF

; Balkenposition am Schirm (x0y0 ist links oben!).
vol_PosX = 18
vol_PosY = 18
vol_Width = 180  ; Balkenbreite
vol_Thick = 18   ; Balkenstärke

HotKey,!WheelUp, vol_MasterUp     
HotKey,!WheelDown, vol_MasterDown
HotKey,#!WheelUp, vol_WaveUp       
HotKey,#!WheelDown, vol_WaveDown
HotKey,#!SPACE, vol_mute

;-----------------------------------------------------------

vol_BarOptionsMaster = 1:B ZH%vol_Thick% ZX0 ZY0 W%vol_Width% CB%vol_CBM% CW%vol_CW%
vol_BarOptionsWave   = 2:B ZH%vol_Thick% ZX0 ZY0 W%vol_Width% CB%vol_CBW% CW%vol_CW%

; Position des OSD
if vol_PosX >= 0
{
   vol_BarOptionsMaster = %vol_BarOptionsMaster% X%vol_PosX%
   vol_BarOptionsWave   = %vol_BarOptionsWave% X%vol_PosX%
}

if vol_PosY >= 0
{
   vol_BarOptionsMaster = %vol_BarOptionsMaster% Y%vol_PosY%
   vol_PosY_wave = %vol_PosY%
   vol_PosY_wave += %vol_Thick%
   vol_BarOptionsWave = %vol_BarOptionsWave% Y%vol_PosY_wave%
}

#SingleInstance
SetBatchLines, 10ms
Return

;---------------------------------------------------------
vol_WaveUp:
SoundSet, +%vol_Step%, Wave
Gosub, vol_ShowBars
return

vol_WaveDown:
SoundSet, -%vol_Step%, Wave
Gosub, vol_ShowBars
return

vol_MasterUp:
SoundSet, +%vol_Step%
Gosub, vol_ShowBars
return

vol_MasterDown:
SoundSet, -%vol_Step%
Gosub, vol_ShowBars
return

vol_mute:
SoundSet, +2,,mute
return

vol_ShowBars:

IfWinNotExist, vol_Wave
   Progress, %vol_BarOptionsWave%, , , vol_Wave
IfWinNotExist, vol_Master
{
   ; Berechnung der Position um Auflösungsveränderung während ausführen des Scripts zu berücksichtigen
   if vol_PosY < 0
   {
      ;Wave-Balke unter Master-Balken erstellen
      WinGetPos, , vol_Wave_Posy, , , vol_Wave
      vol_Wave_Posy -= %vol_Thick%
      Progress, %vol_BarOptionsMaster% Y%vol_Wave_Posy%, , , vol_Master
   }
   else
      Progress, %vol_BarOptionsMaster%, , , vol_Master
}
; Volumes werden ausgelesen:
SoundGet, vol_Master, Master
SoundGet, vol_Wave, Wave
Progress, 1:%vol_Master%
Progress, 2:%vol_Wave%
SetTimer, vol_BarOff, %vol_DisplayTime%
return

vol_BarOff:
SetTimer, vol_BarOff, off
Progress, 1:Off
Progress, 2:Off
return

;---------------------------------
;Menue-Befehle
;---------------------------------
hilfe:
{
   msgbox, ,Hilfe zu %title%,'ALT'-Taste + MausRad vor                   -> Master Volume lauter`n'ALT'-Taste + MausRad zurück              -> Master Volume leiser`n`n'ALT'+'WIN'-Taste + MausRad vor        -> Wave Volume lauter`n'ALT'+'WIN'-Taste + MausRad zurück   -> Wave Volume leiser `n`n'WIN'+'ALT'+'LEERTASTE'                      -> Volume aus/ein`n`n
   
}
return

;---------------------------------
hide_VolByWheel:
   ; Aktion bestätigen lassen
   MsgBox,36,%title%, Soll das %name%- Icon wirklich aus dem SysTray entfernt werden?`n`n
   IfMsgBox, Yes ; Wenn ja
   {
      Menu,TRAY,NoIcon
     
      MsgBox,64,%title%, Das %name% SysTray-Icon wird nicht mehr angezeigt.
   }

return

;---------------------------------
win_autostart:
   ; Aktion bestätigen lassen
   MsgBox,36,%title%, Soll %name% automatisch bei der Benutzeranmeldung gestartet werden?
   IfMsgBox, Yes ; Wenn ja   
   {     
      ; VolByWheel im Autostart des Users eintragen
      RegWrite, REG_SZ, HKEY_CURRENT_USER , SOFTWARE\Microsoft\Windows\CurrentVersion\Run           , VolumeByWheel     , %A_ScriptFullPath%
     
      MsgBox,64,%title%, %name% startet nun automatisch bei der Benutzeranmeldung.
   }
return

;---------------------------------
no_autostart:
   ; Bestätigen lassen, ob VolByWheel wirklich aus Autostart entfernt werden soll
   MsgBox,36,%title%, Soll der automatische Start von %name% bei der Benutzeranmeldung wirklich deaktiviert werden?
   IfMsgBox, Yes ; Wenn ja
   {
     ;VolByWheel aus dem Autostart
     RegDelete, HKEY_CURRENT_USER , SOFTWARE\Microsoft\Windows\CurrentVersion\Run            , VolumeByWheel
     

     MsgBox, 64, %title%, %name% startet nun nicht mehr automatisch bei der Benutzeranmeldung.
   }
return

;---------------------------------
Quit_VolByWheel:
   ExitApp
return




hope you will enjoy this version of OSD-Volume-set using mousewheel - I do
- Very Happy Very Happy
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10474

PostPosted: Tue Feb 08, 2005 12:03 am    Post subject: Reply with quote

The mouse wheel does seem to be a very natural way of changing the volume. Thanks for sharing this variation.
Back to top
View user's profile Send private message Send e-mail
Guest






PostPosted: Tue Feb 08, 2005 12:34 am    Post subject: Reply with quote

here first "bugfix":

somewhere round line10: please add the%A_ScriptDir% path befoe icon...
else icon will not be displayed when start by reg-key (autostart)


Code:

...
   IfExist %A_ScriptDir%\volum.ico
      Menu, TRAY, Icon, volum.ico
...


well, I have not mentioned yet - to use a special icon you have to create an (16x16px) icon(volum.ico) and put it in the directory of the script (I simply took the audio-icon from shell32.dll and change color with irfanview Wink )
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10474

PostPosted: Tue Feb 08, 2005 1:58 pm    Post subject: Reply with quote

I added the following to it, which should fix it:
SetWorkingDir %A_ScriptDir% ; To correctly find the icon.

Note: you can edit your own posts if you login as your existing username, catch17
Back to top
View user's profile Send private message Send e-mail
catch17



Joined: 07 Feb 2005
Posts: 4
Location: Vienna/AUSTRIA

PostPosted: Thu Feb 10, 2005 8:45 am    Post subject: Reply with quote

hello everybody,

here the last version of my "control audio" script:
- provides access to Win Sound Mixer
- show mute status in tray-icon
- show volume-bars on screen while changing volume
- hide tray icon

Code:



; AHK-script by catch17
; Master/Wave Lautstärke, sowie Tonein/aus mittels HotKey und Mauserad bedienen
; 10-02-2005

version = 1.0.1
title = 'Volume_By_Wheel'_v%version%
name = 'Volume_By_Wheel'
author = catch17
Icon = yes

Gosub, Icon_check

SplashImage,, W365 H120, powered by AutoHotKey, %name%___%version%`n———————————————————————————`nEinstellen der Lautstärke `nper Mausrad und Taste...`n———————————————————————————,•••••••••••••••••••••••••••••••••••••••••••••••••••
sleep, 2000
SplashImage, Off

Menu, TRAY, Tip, Master_VOLUME:  'ALT'+MouseWheel`nWave_VOLUME:    'WIN'+'ALT'+ MouseWheel`nVOLUME aus/ein:   'WIN'+'ALT'+'LEERTASTE'

; Eigenes Menü erstellen
Menu, TRAY, NoStandard
Menu, TRAY, Add, Ton aus/ein              , vol_mute
Menu, TRAY, Add
Menu, TRAY, Add, Icon ausblenden                  , hide_VolByWheel
Menu, TRAY, Add
Menu, TRAY, Add, Autostart einrichten                     , win_autostart
Menu, TRAY, Add, Autostart entfernen                      , no_autostart
Menu, TRAY, Add
Menu, TRAY, Add, Lautstärke-Regler           , show_mixer
Menu, TRAY, Add
Menu, TRAY, Add, Hilfe                           , hilfe
Menu, TRAY, Add
Menu, TRAY, Add, Beenden                                  , Quit_VolByWheel

Menu, TRAY, Default, Ton aus/ein


; Schritte pro "Scroll-Einheit":
vol_Step = 4

; Dauer der OSD Anzeige in Millisekunden:
vol_DisplayTime = 2000

; Master Volume Balken Farbe
vol_CBM = 6666FF

; Wave Volume Balken Farbe
vol_CBW = 9999FF

; Hintergrund Farbe des Balkens
vol_CW = CCCCFF

; Balkenposition am Schirm (x0y0 ist links oben!).
vol_PosX = 18
vol_PosY = 18
vol_Width = 180  ; Balkenbreite
vol_Thick = 18   ; Balkenstärke

HotKey,!WheelUp, vol_MasterUp     
HotKey,!WheelDown, vol_MasterDown
HotKey,#!WheelUp, vol_WaveUp       
HotKey,#!WheelDown, vol_WaveDown
HotKey,#!SPACE, vol_mute
HotKey,#!m, show_mixer

;-----------------------------------------------------------

vol_BarOptionsMaster = 1:B ZH%vol_Thick% ZX0 ZY0 W%vol_Width% CB%vol_CBM% CW%vol_CW%
vol_BarOptionsWave   = 2:B ZH%vol_Thick% ZX0 ZY0 W%vol_Width% CB%vol_CBW% CW%vol_CW%

; Position des OSD
if vol_PosX >= 0
{
   vol_BarOptionsMaster = %vol_BarOptionsMaster% X%vol_PosX%
   vol_BarOptionsWave   = %vol_BarOptionsWave% X%vol_PosX%
}

if vol_PosY >= 0
{
   vol_BarOptionsMaster = %vol_BarOptionsMaster% Y%vol_PosY%
   vol_PosY_wave = %vol_PosY%
   vol_PosY_wave += %vol_Thick%
   vol_BarOptionsWave = %vol_BarOptionsWave% Y%vol_PosY_wave%
}

#SingleInstance
SetBatchLines, 10ms
Return

;---------------------------------------------------------
vol_WaveUp:
SoundSet, +%vol_Step%, Wave
Gosub, vol_ShowBars
return

vol_WaveDown:
SoundSet, -%vol_Step%, Wave
Gosub, vol_ShowBars
return

vol_MasterUp:
SoundSet, +%vol_Step%
Gosub, vol_ShowBars
return

vol_MasterDown:
SoundSet, -%vol_Step%
Gosub, vol_ShowBars
return

vol_mute:
SoundSet, +1,, mute
Gosub, vol_ShowMute
return

;----------------------------
vol_ShowBars:

IfWinNotExist, vol_Wave
   Progress, %vol_BarOptionsWave%, , , vol_Wave
IfWinNotExist, vol_Master
{
   ; Berechnung der Position um Auflösungsveränderung während ausführen des Scripts zu berücksichtigen
   if vol_PosY < 0
   {
      ;Wave-Balken unter Master-Balken erstellen
      WinGetPos, , vol_Wave_Posy, , , vol_Wave
      vol_Wave_Posy -= %vol_Thick%
      Progress, %vol_BarOptionsMaster% Y%vol_Wave_Posy%, , , vol_Master
   }
   else
      Progress, %vol_BarOptionsMaster%, , , vol_Master
}
; Volumes werden ausgelesen:
SoundGet, vol_Master, Master
SoundGet, vol_Wave, Wave
Progress, 1:%vol_Master%
Progress, 2:%vol_Wave%
SetTimer, vol_BarOff, %vol_DisplayTime%
return

vol_BarOff:
SetTimer, vol_BarOff, off
Progress, 1:Off
Progress, 2:Off
return

;----------------------------
vol_ShowMute:

SoundGet, Master_mute,, mute
SetTimer, GuiDestroy, off ; This avoids a rare split-second timing issue.
Gui, Destroy ; Make sure it's destroyed when starting out in case timer hasn't fired yet.
Gui, Color, 000080
Gui, font, s20 bold cYellow, Tahoma
Gui, Add, text,x0 y0 vGuiText, [TON AUS] » %Master_mute%
Gosub, icon_check

DetectHiddenWindows on
WinWait, %A_ScriptName%
WinSet, TransColor, 000080 240
WinSet, AlwaysOnTop, On
Gui, -Caption
Gui, Show, w240 h50 x12 y12
SetTimer, GuiDestroy, 2000
return

;---------------------------------
;Menue-Befehle
;---------------------------------
show_mixer:
   run %SystemRoot%\System32\sndvol32.exe
return

;---------------------------------
hilfe:
{
   msgbox, ,Hilfe zu %title%,'ALT'-Taste + MausRad vor                   -> Master Volume lauter`n'ALT'-Taste + MausRad zurück              -> Master Volume leiser`n`n'ALT'+'WIN'-Taste + MausRad vor        -> Wave Volume lauter`n'ALT'+'WIN'-Taste + MausRad zurück   -> Wave Volume leiser `n`n'WIN'+'ALT'+'LEERTASTE'                      -> Volume aus/ein`n`n'WIN'+'ALT'+ 'm'                                     -> Lautstärke-Regler `n`n
   
}
return

;---------------------------------
hide_VolByWheel:
   ; Aktion bestätigen lassen
   MsgBox,36,%title%, Soll das %name%- Icon wirklich aus dem SysTray entfernt werden?`n`n
   IfMsgBox, Yes ; Wenn ja
   {
      Menu,TRAY,NoIcon
   Icon = no
     
      MsgBox,64,%title%, Das %name% SysTray-Icon wird nicht mehr angezeigt.
   }

return

;---------------------------------
win_autostart:
   ; Aktion bestätigen lassen
   MsgBox,36,%title%, Soll %name% automatisch bei der Benutzeranmeldung gestartet werden?
   IfMsgBox, Yes ; Wenn ja   
   {     
      ; VolByWheel im Autostart des Users eintragen
      RegWrite, REG_SZ, HKEY_CURRENT_USER , SOFTWARE\Microsoft\Windows\CurrentVersion\Run           , VolumeByWheel     , %A_ScriptFullPath%
     
      MsgBox,64,%title%, %name% startet nun automatisch bei der Benutzeranmeldung.
   }
return

;---------------------------------
no_autostart:
   ; Bestätigen lassen, ob VolByWheel wirklich aus Autostart entfernt werden soll
   MsgBox,36,%title%, Soll der automatische Start von %name% bei der Benutzeranmeldung wirklich deaktiviert werden?
   IfMsgBox, Yes ; Wenn ja
   {
     ;VolByWheel aus dem Autostart
     RegDelete, HKEY_CURRENT_USER , SOFTWARE\Microsoft\Windows\CurrentVersion\Run            , VolumeByWheel
     

     MsgBox, 64, %title%, %name% startet nun nicht mehr automatisch bei der Benutzeranmeldung.
   }
return

;----------------------------------
GuiDestroy:
SetTimer, GuiDestroy, off
Gui, Destroy
return

;----------------------------------
Icon_check:
   IfExist %A_ScriptDir%\volum.ico
   Gosub, icon_on_check
return


;----------------------------------
icon_on_check:
   If  Icon = no
   return
else
   Gosub, tray_icon
return

;----------------------------------
tray_icon:
Menu, TRAY, Icon, %A_ScriptDir%\volum.ico
SoundGet, Master_mute,, mute
   if Master_mute=On
   Menu, TRAY, Icon, %A_ScriptDir%\volum_off.ico
return

;---------------------------------
Quit_VolByWheel:
   ExitApp
return




--you just need 2 icons (volum.ico and volum_off, 16x16) in same directory as the script

hope you will enjoy this script Smile Smile
Back to top
View user's profile Send private message
breyed



Joined: 15 Apr 2006
Posts: 4

PostPosted: Sat Apr 15, 2006 9:38 pm    Post subject: Baloontip feedback and predefined levels Reply with quote

Before I ran into this forum, I had put together my own volume level shortcut. After a couple iterations, I found a good UI was to provide predefined, graduated levels for coarse adjustment by default, allowing a modifying key for fine grain control (rather like many drawing packages work when moving objects).

For feedback, I used balloon tips because it was easy and provides nice feedback.

Here's the code:

Code:
;;; Adjust volume level

; To increase/decrease the main volume, use the Windows key combined with
; the plus or minus key on the numeric keypad. For fine grained increments,
; add the Alt key. Windows plus the asterisk key toggles mute.

#NumpadAdd::
volume_direction = 1
Gosub, SetVolumeLevel
return

#NumpadSub::
volume_direction = -1
Gosub, SetVolumeLevel
return

#!NumpadAdd::
SoundGet, old_volume
if (old_volume > .95)
   SoundSet, +1
else
   SoundSet, +.1
Gosub, DisplayVolumeLevel
return

#!NumpadSub::
SoundGet, old_volume
if (old_volume < 1.05)
   SoundSet, -.1
else
   SoundSet, -1
Gosub, DisplayVolumeLevel
return

#NumpadMult::SoundSet,+1,,mute


;;; Subroutines

SetVolumeLevel:
volume_choices = .1 .2 .5 .7 1 2 5 10 15 30 50 75 100
StringSplit, volumes, volume_choices, %A_Space%
SoundGet, old_volume
old_index = 0
Loop, %volumes0%
{
   if (A_Index > 0 and old_volume <= volumes%A_Index%)
   {
      old_index := A_Index
      break
   }
}

new_index := old_index + volume_direction
if (new_index <= 0)
   new_index = 1
if (new_index > volumes0)
   new_index := volumes0
new_volume := volumes%new_index%
SoundSet, new_volume
Gosub, DisplayVolumeLevel
return

DisplayVolumeLevel:
SetFormat, float, 0.1
SoundGet, volume
TrayTip, Volume level, %volume%, 3, 1
return
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group