Setting multiple timers(/reminders)? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Flowgun
Posts: 75
Joined: 25 Aug 2022, 09:42

Setting multiple timers(/reminders)?

Post by Flowgun » 27 Jan 2023, 02:38

Hello everyone,

I'm trying to write a function that displays multiple reminders.

It's easy to create a script that shows a tooltip or a msgbox after a certain time using "SetTimer" command, but the problem arises when I want to create multiple reminders.
Since all the reminders created with the function would call the same "SetTimer" label, they would interfere with each other. The first reminder that runs would delete the timer and subsequently, all upcoming reminders.

I thought of creating a dynamic name for each reminder like this:

Code: Select all

ReminderLabel:= "Reminder_" A_Now
SetTimer, %ReminderLabel%,  %Remindertime%
so then I can call and delete that specific timer:

Code: Select all

%Reminderlabel%:
{
msgbox, this is the reminder's text
SetTimer, %ReminderLabel%, Delete
}
But it turns out that I can't use dynamic names for labels.

Any help would be much appreciated.

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Setting multiple timers(/reminders)?  Topic is solved

Post by swagfag » 27 Jan 2023, 03:09

Code: Select all

ReminderFunction1 := Func("ReminderFunction").Bind("") ; Known limitation: SetTimer requires a plain variable reference.
SetTimer, %ReminderFunction1%,  % -Remindertime

ReminderFunction2 := Func("ReminderFunction").Bind("") ; Known limitation: SetTimer requires a plain variable reference.
SetTimer, %ReminderFunction2%,  % -Remindertime

ReminderFunction() {
	msgbox, this is the reminder's text
}

Flowgun
Posts: 75
Joined: 25 Aug 2022, 09:42

Re: Setting multiple timers(/reminders)?

Post by Flowgun » 27 Jan 2023, 08:04

swagfag wrote:

Code: Select all

ReminderFunction1 := Func("ReminderFunction").Bind("") ; Known limitation: SetTimer requires a plain variable reference.
SetTimer, %ReminderFunction1%,  % -Remindertime

ReminderFunction2 := Func("ReminderFunction").Bind("") ; Known limitation: SetTimer requires a plain variable reference.
SetTimer, %ReminderFunction2%,  % -Remindertime

ReminderFunction() {
	msgbox, this is the reminder's text
}
Thank you. this works. Without the limitation actually.

Code: Select all

Reminder%A_Now% := Func("ReminderFunction").Bind(ReminderText,Remindertime%A_Now%)
SetTimer, % Reminder%A_Now%,  % Remindertime

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Setting multiple timers(/reminders)?

Post by swagfag » 27 Jan 2023, 08:19

u dont understand what the limitation is. read SetTimer docs

Flowgun
Posts: 75
Joined: 25 Aug 2022, 09:42

Re: Setting multiple timers(/reminders)?

Post by Flowgun » 27 Jan 2023, 08:33

swagfag wrote: u dont understand what the limitation is. read SetTimer docs

fair enough.

Post Reply

Return to “Ask for Help (v1)”