Author Topic: Trigger something at time of day  (Read 807 times)

Malic

  • Full Member
  • ***
  • Posts: 102
Trigger something at time of day
« on: October 17, 2022, 04:22:04 PM »
Short story, trying to build a command that will open a specific Twitch Page at a specific time, for someone so their account can get Twitch Drops when they are at work.

Looking for something that you can activate, and it just trigger at the specific time of day

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Trigger something at time of day
« Reply #1 on: October 17, 2022, 04:32:46 PM »
The actual triggering of the command may be more suited to Windows Task Scheduler, where you can have it run VoiceAttack with the -command option to trigger a specific command (optionally with the -profile option as well, if the command you're triggering may not be available in the active profile).
If VoiceAttack is already running the command will be executed by that instance, otherwise VoiceAttack will be launched first and then the command should execute.


If you really want to do it entirely within VoiceAttack, you could use something like
Code: [Select]
Set date [~triggerTime] value to 2022-10-20 12:00:00
Start Loop While : [~triggerTime] Is Before Current Date/Time
End Loop
Write [Blue] 'Trigger time has been reached' to log

You'd start that command and let it run in the background, and when the trigger time is reached, the command will execute any actions after the loop.

That'd be a one-shot command, so you'd need to adjust the trigger time manually to have it function correctly again.


If you want something that executes every day at a given time (and, again, you don't want to use Task Scheduler, which is specifically designed for that type of thing), something like this could work:
Code: [Select]
Start Loop While : [{TIME}] Does Not Equal '12:00'
End Loop
Write [Blue] 'Trigger time has been reached' to log
Start Loop While : [{TIME}] Equals '12:00'
End Loop

With the "Repeating" option set to "Repeat continuously until stopped", that should trigger the actions between the two loops as long as the command is running in the background, at the given time.

The second loop could be replaced with a pause action of 61 seconds or more, if you prefer (maximum normal pause time is 9999.999 seconds, so ~2.8 hours; a variable pause can be longer, if you want to pause slightly less than 24 hours for the second go-around).


For the sake of not needlessly wasting CPU time, you could add a pause within the loop actions (so they're not constantly checking the time every few ms), keeping in mind that when the target trigger time is reached it may take as long as that pause time before the desired actions are executed.