Best way to check if a script is ran today? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
william_ahk
Posts: 501
Joined: 03 Dec 2018, 20:02

Best way to check if a script is ran today?

27 Oct 2022, 02:39

I want a script to run only once per day. Right now I'm checking it by saving today's date into a text file. But I wonder if there's any low-level way, like is there a record in the system logging the last accessed date of a file or something like that? :think:

Code: Select all

WasIRan() {
	static save_filepath := A_ScriptDir "\" A_ScriptName ".last_run"
	FileRead last_run, % save_filepath
	FormatTime this_run, , yyyyMMdd
	if (last_run != this_run) {
		FileDelete % save_filepath
		FileAppend % this_run, % save_filepath
		return true
	}
}
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Best way to check if a script is ran today?

27 Oct 2022, 03:29

boiler wrote:
27 Oct 2022, 02:50
Use FileSetTime and FileGetTime.
was looking for this too, thank you
william_ahk
Posts: 501
Joined: 03 Dec 2018, 20:02

Re: Best way to check if a script is ran today?

27 Oct 2022, 07:39

@boiler Thanks! :thumbup: Haven't thought of this way.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot] and 205 guests