Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Volume-set + OSD script mod


  • Please log in to reply
5 replies to this topic
catch17
  • Members
  • 4 posts
  • Last active: Feb 10 2005 01:28 AM
  • Joined: 07 Feb 2005
hello everybody,

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

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 :
; 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
- :D :D

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
The mouse wheel does seem to be a very natural way of changing the volume. Thanks for sharing this variation.

  • Guests
  • Last active:
  • Joined: --
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)


...
   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 ;) )

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
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

catch17
  • Members
  • 4 posts
  • Last active: Feb 10 2005 01:28 AM
  • Joined: 07 Feb 2005
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



; 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 :) :)

breyed
  • Members
  • 4 posts
  • Last active: May 02 2007 12:55 AM
  • Joined: 15 Apr 2006
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:

;;; 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