Sign in to follow this  
Followers 0
WhiteAvenger

Hotkeys & Functions w/ parameters

3 posts in this topic

Hi,

I'm writing a program for a theater play, and I'm using my 0-9 keys to set the volume of my laptop. This is how I'm currently doing it:

#Include <Audio.au3>

HotKeySet("^`","_SoundSet_Mute")
HotKeySet("^1","_SoundSet_10")
HotKeySet("^2","_SoundSet_20")
HotKeySet("^3","_SoundSet_30")
HotKeySet("^4","_SoundSet_40")
HotKeySet("^5","_SoundSet_50")
HotKeySet("^6","_SoundSet_60")
HotKeySet("^7","_SoundSet_70")
HotKeySet("^8","_SoundSet_80")
HotKeySet("^9","_SoundSet_90")
HotKeySet("^0","_SoundSet_100")

[...]

Func _SoundSet_Mute()
    $lastVol = _SoundGetMasterVolume()
    _SoundSetMasterVolume(0)
    ToolTip("Volume: " & 0 & "%",0,0)
    Sleep(1000)
    ToolTip("")
EndFunc

Func _SoundSet_10()
    $lastVol = _SoundGetMasterVolume()
    _SoundSetMasterVolume(10)
    ToolTip("Volume: " & 10 & "%",0,0)
    Sleep(1000)
    ToolTip("")
EndFunc

Func _SoundSet_20()
    $lastVol = _SoundGetMasterVolume()
    _SoundSetMasterVolume(20)
    ToolTip("Volume: " & 20 & "%",0,0)
    Sleep(1000)
    ToolTip("")
EndFunc

[...]

etc., you get the idea.

Is there possibly a workaround for not being able to pass parameters in the HotKeySet? I'd much rather have one function which can then evaluate which button combination was pressed, and set the volume accordingly.

Any help would be much appreciated!

--WhiteAvenger

Share this post


Link to post
Share on other sites



This is why I love autoit:

#Include <Audio.au3>
HotKeySet("^`","_SoundSet")
HotKeySet("^1","_SoundSet")
HotKeySet("^2","_SoundSet")
HotKeySet("^3","_SoundSet")
HotKeySet("^4","_SoundSet")
HotKeySet("^5","_SoundSet")
HotKeySet("^6","_SoundSet")
HotKeySet("^7","_SoundSet")
HotKeySet("^8","_SoundSet")
HotKeySet("^9","_SoundSet")
HotKeySet("^0","_SoundSet")

while 1
    Sleep(10)
WEnd

Func _SoundSet()
    Local $volume=StringRight(@HotKeyPressed,1)*10
     _SoundSetMasterVolume($volume)
EndFunc

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

This is why I love autoit:

#Include <Audio.au3>
HotKeySet("^`","_SoundSet")
HotKeySet("^1","_SoundSet")
HotKeySet("^2","_SoundSet")
HotKeySet("^3","_SoundSet")
HotKeySet("^4","_SoundSet")
HotKeySet("^5","_SoundSet")
HotKeySet("^6","_SoundSet")
HotKeySet("^7","_SoundSet")
HotKeySet("^8","_SoundSet")
HotKeySet("^9","_SoundSet")
HotKeySet("^0","_SoundSet")

while 1
    Sleep(10)
WEnd

Func _SoundSet()
    Local $volume=StringRight(@HotKeyPressed,1)*10
     _SoundSetMasterVolume($volume)
EndFunc

Exactly what I needed, thanks!!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0