Limiting frequency of script execution

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Boborino
Posts: 2
Joined: 22 May 2018, 01:53

Limiting frequency of script execution

22 May 2018, 02:21

I am trying to limit how frequently a script can execute. It is a very simple script, just rebinding the mouse wheel to a keyboard key. This is the only script I have running.

Here is what I have:

^+`::Suspend,Toggle
#HotkeyInterval 1
Wheeldown::SendInput {F12 down}{F12 up}
Suspend, On
Pause, On
Sleep, 3000
Suspend, Off
Pause, Off
return

The first line is so I can toggle it on and off and regain the normal functionality of the mouse wheel. In this example I am trying to get it to send a maximum of every 3 seconds regardless of how frequently I scroll down.

It is still sending F12 every time I scroll down and I want it to send F12 a maximum of let's say every 100ms. How can I do this?

Thank you
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Limiting frequency of script execution

22 May 2018, 02:28

When you have a multi line hotkey subroutine it has to be on its own line.

Code: Select all

^+`::Suspend,Toggle
#HotkeyInterval 1 
Wheeldown::
    SendInput {F12 down}{F12 up}
    Suspend, On
    Pause, On
    Sleep, 3000
    Suspend, Off
    Pause, Off
return
Boborino
Posts: 2
Joined: 22 May 2018, 01:53

Re: Limiting frequency of script execution

22 May 2018, 04:00

Got it to work, thanks!

^+`::Suspend,Toggle
#HotkeyInterval 1
Wheeldown::
SendInput {F12 down}{F12 up}
Suspend, On
Sleep, 100
Suspend, Off

return



Is there a way to make the script keep the hotkey "locked" while it is suspended? What I mean is, while it is on sleep aka not sending the F12 key, the mouse wheel returns to its normal functionality. I'd like for it to continue capturing the wheel down (preventing the wheel down command from being sent) but just not do anything for 100ms. If it's not possible or overly complex don't worry about it. Thanks.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Lamron750 and 234 guests