Jump to content
Sign in to follow this  
dieterhatn

[Hotkey] Stop multiple execution

Recommended Posts

dieterhatn

Hi there. I've written a Volume Control Script, which lowers the Volume of the Foreground window on hotkey. I've combined this with a Splash Popup to always see my current volume of the Window. So usually I keep holding down the Button until I reach my desired volume. But when it comes to fullscreen apps, it sometimes does not work. It lowers the volume to the desired degree, but then gets executed again and again (depending on how long I've pressed the Hotkey before). So for example when I lower the volume from 50% to 10% it still gets executed after i released the key again and repeats 40 times. Is there a way to block this behaviour? Thanks in advance

Share this post


Link to post
Share on other sites
dieterhatn

I simplified the Popup Splash, the original one is a bit more confusing because of lots of text formatting.

HotKeySet("{VOLUME_DOWN}", "ADown")

Func ADown()
Local $Proc = Process(WinGetHandle("[ACTIVE]")), $p = GetProc($Proc), $Title = WinGetTitle("[ACTIVE]")
;Lower Volume
If $Vol[$p][1] > 0 AND $Vol[$p][1] <= 50 then $Vol[$p][1] += -1 ; Change Volume in Array (Max Volume is 50%)
SplashTextOn("Volume", $Title & @LF & "Volume: " & $Vol[$p][1] & "%", 250, 75, 2154, 750, 33, "Calibri", 24, 400)
Off()
EndFunc

Func Off()
Sleep(2000)
SplashOff()
EndFunc
Edited by dieterhatn

Share this post


Link to post
Share on other sites
dieterhatn

&amp;amp;nbsp;

Unset hot key when enter function and re set it before exit function.

&amp;amp;nbsp;

That won't fix the issue, cause its just a delayed execution I guess, so the key was pressed just the execution is delayed.

Edit:

I could just check if the key is pressed before entering the function, unfortunately I cant find the code of the VolumeUp and VolumeDown keys.

Maybe anyone can help me here?

Edit 2:

Found it on the MSDN.

"AF" is Volume Up and "AE" is Volume Down.

That seems to fix the issue.

Edited by dieterhatn

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  

×