Need Help Understanding A Script I Found

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Mulsiphix
Posts: 148
Joined: 20 Nov 2015, 17:56

Need Help Understanding A Script I Found

20 Apr 2016, 14:51

I came across a script today and am trying to understand one small part. How does it understand what constitutes a single day's time? I assume it is this line, but I can't find "days" anywhere in the AHK docs and I don't see anywhere in the script where it is given a value.

The Line I Think Defines A "Day"

Code: Select all

DaysSinceLastRun -= %LastRun%, days
Entire Script

Code: Select all

IniRead, LastRun, Settings.INI, %A_ScriptName%, LastRun, 0
If !LastRun
 {
  LastRun := A_Now
  IniWrite, %LastRun%, Settings.INI, %A_ScriptName%, LastRun
 }

DaysSinceLastRun := A_Now
DaysSinceLastRun -= %LastRun%, days

If ( DaysSinceLastRun = 0 )
   ExitApp
Else
  IniWrite, %A_Now%, Settings.INI, %A_ScriptName%, LastRun
Leli196
Posts: 216
Joined: 29 Aug 2015, 05:47
Location: Germany

Re: Need Help Understanding A Script I Found

20 Apr 2016, 15:10

It is a built in command. Look here: https://autohotkey.com/docs/commands/EnvAdd.htm
I use this to calculate with time. If you have e.g. the current date in YYYYMMDDHH24MISS format in the var current_date you can simply use += to add or subtract seconds, minutes, hours or days. In this context it is worth mentioning that -= does not support this. You need to write e.g. += -5, hours.


Greetings Leli196
Mulsiphix
Posts: 148
Joined: 20 Nov 2015, 17:56

Re: Need Help Understanding A Script I Found

20 Apr 2016, 16:52

Leli196 wrote:It is a built in command. Look here: https://autohotkey.com/docs/commands/EnvAdd.htm
I saw a link to that in the Variables section. Oooh I was so darn close :crazy:. Thank you very much Leli196!
Leli196 wrote:I use this to calculate with time. If you have e.g. the current date in YYYYMMDDHH24MISS format in the var current_date you can simply use += to add or subtract seconds, minutes, hours or days. In this context it is worth mentioning that -= does not support this. You need to write e.g. += -5, hours.
Awesome. I played around with the setting in seconds and my script is working perfectly now. Thank you so much!! :dance:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Lamron750, mikeyww, nacken012 and 235 guests