How to call a funtion without waiting first with SetTimer?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Wiceramond

How to call a funtion without waiting first with SetTimer?

23 Jul 2018, 03:49

I searched and couldn't find anything about it.

Code: Select all

PgUp::
SetTimer, LittleTimer, 4000
Return

PgDn::
SetTimer, LittleTimer, Off
Return

SetTimer:
MsgBox,,,Woo
Return
If I run this code, when I press the hotkey timer waits for 4 seconds and then runs the function. But I want it to run immediately when I press the hotkey and wait 4 seconds for next run.

Thank You.
gregster
Posts: 9068
Joined: 30 Sep 2013, 06:48

Re: How to call a funtion without waiting first with SetTimer?

23 Jul 2018, 08:41

add a gosub, LittleTimer:

Code: Select all

PgUp::
gosub, LittleTimer
SetTimer, LittleTimer, 4000
Return
If I run this code, when I press the hotkey timer waits for 4 seconds and then runs the function.
I doubt it. If you have a timer named LittleTimer in your hotkeys - then the label should also be LittleTimer, not SetTimer:

Code: Select all

LittleTimer:
MsgBox,,,Woo
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Rohwedder and 119 guests