Adding a day

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jbearnolimits
Posts: 58
Joined: 09 Jul 2017, 23:44

Adding a day

15 Sep 2021, 00:19

So here is what I want to do... I need to find a way to get today's date, send it to notepad, get the next day's date and send it to notepad, and continue to do this until I pause the script.

Basically I am making a script to schedule posts to a website which asks for the date I want to schedule it for. I know how to use the Send command, and I know how to copy and paste with autohotkey (which I plan to copy the date from notepad and paste it into the form). The only thing I can't seem to figure out is how to have autohotkey get today's date and then after I copy and paste it have it add a day.
jbearnolimits
Posts: 58
Joined: 09 Jul 2017, 23:44

Re: Adding a day

15 Sep 2021, 22:28

boiler wrote:
15 Sep 2021, 00:45
See this thread.
Thanks, I took a look and I see how to get the current date and add a set number of days to it. That was helpful. If today is 9/15/2021 and I add 2 days and send it I get 9/17/2021...but now I need to know how to add another 2 days to 9/17/2021 and send it next.
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: Adding a day

15 Sep 2021, 23:24

Add another two days to the new date like you did to the current date. Why would it be any different?
jbearnolimits
Posts: 58
Joined: 09 Jul 2017, 23:44

Re: Adding a day

16 Sep 2021, 19:58

boiler wrote:
15 Sep 2021, 23:24
Add another two days to the new date like you did to the current date. Why would it be any different?
I was thinking there was a way to somehow store the last date and add to the last one rather than having to change the script each time. As it is I run the script and it sends two days after today. Then I run it again and it just gives me the same results. What I need is to have it add 2 days to the last one it sends.
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: Adding a day

16 Sep 2021, 20:07

You wouldn’t change the script each time. You would make it so it stores the latest in a variable so that you would just add two days to whatever it contains. If you need it to remember the date between sessions, store it in a .ini file or some other text file.
jbearnolimits
Posts: 58
Joined: 09 Jul 2017, 23:44

Re: Adding a day

16 Sep 2021, 22:46

boiler wrote:
16 Sep 2021, 20:07
You wouldn’t change the script each time. You would make it so it stores the latest in a variable so that you would just add two days to whatever it contains. If you need it to remember the date between sessions, store it in a .ini file or some other text file.
Getting closer to figuring it out. I have found out how to create a file with AHK. But I'm not sure yet how to store the date as a variable in the file. The codes I have are below. The x:: one makes the file on my desktop. The F12 one sends today's date plus 2 days. How do I combine this making the send date the variable?

Code: Select all

x::
FileAppend, % MyArray[i], My File.txt
Return

F12::
  Date += 2, Days
  FormatTime, nDate, %Date%, MM/dd/yyyy
  Send, %nDate%
  reload
Return
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: Adding a day

16 Sep 2021, 23:26

Just use your variable name in place of the array element you have in what you posted:

Code: Select all

FileAppend, % nDate, My File.txt

Now you would need to implement reading that value from the file and making it so you don’t just keep adding to the file as you continue to use FileAppend, which you can do by using FileDelete prior to FileAppend.
jbearnolimits
Posts: 58
Joined: 09 Jul 2017, 23:44

Re: Adding a day

17 Sep 2021, 00:39

boiler wrote:
16 Sep 2021, 23:26
Just use your variable name in place of the array element you have in what you posted:

Code: Select all

FileAppend, % nDate, My File.txt

Now you would need to implement reading that value from the file and making it so you don’t just keep adding to the file as you continue to use FileAppend, which you can do by using FileDelete prior to FileAppend.
Thank you very much. I've done a little work to it and it looks like I can get the file deleted then created with today's date plus 2 days. It also looks like I am able to read the information and send it. But it doesn't continually add to the date when I hit F12 again. Instead it just sends the same thing over and over. Of course the txt file only has one entry since it is deleted and remade each time. But it never adds to the date.

For example, it shows 9/18/2021 then I hit the F12 key again and it again sends 9/18/2021. What I want is it to do 9/18/2021 and then when I hit F12 again get 9/20/2021.

Code: Select all

F12::
  Date += 2, Days
  FormatTime, nDate, %Date%, MM/dd/yyyy
  FileDelete, My File.txt
  FileAppend, % nDate, My File.txt
  FileRead, OutputVar, My File.txt
  Send, %OutputVar%
  reload
Return
User avatar
Xeo786
Posts: 759
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Adding a day

17 Sep 2021, 01:23

reload reset the whole script and that Date Variable just remove reload

Code: Select all

F12::
  Date += 2, Days
  FormatTime, nDate, %Date%, MM/dd/yyyy
  msgbox, % nDat
;  reload  ; here I just disabled reload 
Return
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
jbearnolimits
Posts: 58
Joined: 09 Jul 2017, 23:44

Re: Adding a day

17 Sep 2021, 22:43

Xeo786 wrote:
17 Sep 2021, 01:23
reload reset the whole script and that Date Variable just remove reload

Code: Select all

F12::
  Date += 2, Days
  FormatTime, nDate, %Date%, MM/dd/yyyy
  msgbox, % nDat
;  reload  ; here I just disabled reload 
Return
Well....simple huh. That worked just fine. But at least I learned a few things while trying to figure it out. Thanks.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, Giresharu, Google [Bot], inseption86, jomaweb, Rohwedder and 255 guests