Incrementing a date

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
momo007
Posts: 12
Joined: 13 Jul 2019, 09:06

Incrementing a date

Post by momo007 » 29 Jan 2023, 07:48

I need a script that works more or less like this

Pressing any combination of keys (say F1)
The script asks from which date I want to start (say 20.01.2024)

A loop starts (until I press another key combination (say F2) )
I mark on the screen where I want the date to be written
The date is written
The date is incremented by 1 day (21.10.2024)
The loop continues until F2 is pressed

remark:
The program does not need to deal with years in advance,leap years, or anything similar.
The primary use is to write down 30 consecutive dates from a specific date.

thanks

User avatar
mikeyww
Posts: 26852
Joined: 09 Sep 2014, 18:38

Re: Incrementing a date

Post by mikeyww » 29 Jan 2023, 08:22

I would go with the last one shown here.

Code: Select all

; This script sends a date, and increments it
#Requires AutoHotkey v1.1.33

F1::
InputBox, ib, Date, Enter a starting date.,, 225, 125
(!ErrorLevel && ib > "") && (part := StrSplit(ib, "."), date := part.3 part.2 part.1)
Return

F4::
FormatTime, txt, %date%, dd.MM.yyyy
SendInput % txt
date += 1, D
Return

Code: Select all

; This script sends a date, and increments it
#Requires AutoHotkey v2.0
date := A_Now

F1:: {
 Global date
 ib := InputBox('Enter a starting date.', 'Date', 'w225 h100')
 (ib.Result = "OK" && ib.Value != "") && (part := StrSplit(ib.Value, "."), date := part[3] part[2] part[1])
}

F4:: {
 Global date
 Send FormatTime(date, 'dd.MM.yyyy')
 date := DateAdd(date, 1, 'D')
}
Or:

Code: Select all

; This script sends a date, and increments it
#Requires AutoHotkey v2.0
date := ""

F1:: {                     ; F1 = Ask for date, and enable sending
 Global date
 If (ib := InputBox('Enter a starting date.', 'Date', 'w225 h100')).Result = "OK" && ib.Value != ""
  part := StrSplit(ib.Value, "."), date := part[3] part[2] part[1], SoundBeep(1500)
}

#HotIf date
~LButton Up:: {            ; LBUTTON UP = Send and increment date
 Global date
 Send(FormatTime(date, 'dd.MM.yyyy')), date := DateAdd(date, 1, 'D')
}

F2:: {                     ; F2 = Disable
 Global date := ""
 SoundBeep 1000
}
#HotIf

momo007
Posts: 12
Joined: 13 Jul 2019, 09:06

Re: Incrementing a date

Post by momo007 » 31 Jan 2023, 04:35

thank you, its working :bravo: :bravo:

Post Reply

Return to “Ask for Help (v1)”