Send a combination at a specified time every day

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Andy162
Posts: 4
Joined: 27 Apr 2017, 08:54

Send a combination at a specified time every day

21 Sep 2018, 21:33

Hi,

How do I send a key combination, for example, Alt+Q, at a specified time, for example, 9:45 AM, every day?
What script should I use?
Spark
Posts: 80
Joined: 04 Jan 2017, 02:22

Re: Send a combination at a specified time every day

21 Sep 2018, 23:13

Hello,
Try

Code: Select all

target_time = 0945 ; 09:45 am

; Get target time in a format we can:
;  - compare (with "<"), and
;  - use to calculate "time delta" (with EnvSub.)
target = %A_YYYY%%A_MM%%A_DD%%target_time%00

; < comparison should be safe as long as both are in the *exact* same format.
if (target < A_Now)
{   ; time(today) has passed already, so use time(tomorrow)
    EnvAdd, target, 1, d
}

; Calculate how many seconds until the target time is reached.
EnvSub, target, %A_Now%, Seconds

; Sleep until the target is reached.
Sleep, % target * 1000 ; (milliseconds)
; Send key Alt+q
SendInput,{Alt Down}q{Alt Up}
reference:
https://autohotkey.com/board/topic/1996 ... ime/page-2

HTH

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: aitaixy, Anput, Nerafius and 188 guests