0
votes

I have started to create a script for WhatsApp web, it is to change a group name and the number of days left till something. However, I want to be able to run the script each day so it takes away one day.

I'm unsure how to do subtraction or how to go about to do this, does AutoHotKey have a return function so I can return the variable at the end.

let's say the number of days is 90

so when I run the script next it will be 89

then the next day after when I run, it will be 87

I'm very new to AutoHotKey and still learning about it but loving it so far.

2

2 Answers

1
votes
; FormatTime transforms a YYYYMMDDHH24MISS timestamp into the specified date/time format.
FormatTime, Date, CurrentDate, YYYYMMDD

Expires := 20170611  ; 06/12/2017

; Subtract Date timestamp from Expires timestamp
EnvSub, Expires, CurrentDate, days

; The result is stored in Expires
Msgbox % Expires " days left till  ..."

https://autohotkey.com/docs/commands/FormatTime.htm

To run the script each day, create a shortcut of it in your startup folder, or use SetTimer.

0
votes

Time in days, hours and minutes left till a specific time:

FormatTime, Date, CurrentDateTime, YYYYMMDDHHMI
expires := 201706111537  ; 06/11/2017 15:37 

; time left in minutes:
expires_minutes := expires
EnvSub, expires_minutes, CurrentDateTime, minutes

; time left in hours:
expires_hours := expires_minutes
EnvDiv, expires_hours, 60

; time left in days:
expires_days := expires_minutes
EnvDiv, expires_days, (24 * 60)

; rest of the division in hours:
rest_hours := expires_hours - (expires_days * 24)

; rest of the division in minutes:
rest_minutes := expires_minutes - (expires_hours * 60)

Msgbox %expires_days% days, %rest_hours% hours and %rest_minutes% minutes left till ...