Request: A_AhkBuildDate

Propose new features and changes
User avatar
Raccoon
Posts: 53
Joined: 26 Jul 2014, 16:15

Request: A_AhkBuildDate

13 Mar 2020, 19:14

Request for the variable A_AhkBuildDate to compliment A_AhkVersion
Returns a human readable date when Autohotkey was built.

Also include this date in the Main Window titlebar, next to the version number.
User avatar
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Re: Request: A_AhkBuildDate

14 Mar 2020, 16:13

I don't quite see a use for this, mind elaborating what this could benefit?

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat

HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: Request: A_AhkBuildDate

14 Mar 2020, 17:00

You can modify Ahk2Exe to add a line on top of any compiled script: global A_AhkBuildDate="20200314"
User avatar
Raccoon
Posts: 53
Joined: 26 Jul 2014, 16:15

Re: Request: A_AhkBuildDate

15 Mar 2020, 19:28

I should have elaborated. I want to know the date that A_AhkVersion was compiled (and uploaded to the Autohotkey website), from within my scripts. That is, I want to know old AutoHotkey v1.1.32.00 is. The Build Date of the AutoHotkey Software.
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: Request: A_AhkBuildDate

16 Mar 2020, 02:36

Probably:

Code: Select all

MsgBox % A_AhkBuildDate("1.1.32.00")
A_AhkBuildDate(build){
  whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
  whr.Open("GET", "https://github.com/Lexikos/AutoHotkey_L/releases/tag/v" build, true)
  whr.Send()
  whr.WaitForResponse()
  if RegExMatch(whr.ResponseText,"m)relative-time datetime=""([^""]+)""",builddate)
    Return SubStr(builddate1,1,10)
  else return 0
}
User avatar
Raccoon
Posts: 53
Joined: 26 Jul 2014, 16:15

Re: Request: A_AhkBuildDate

18 Mar 2020, 05:14

Does that work without an internet connection?
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Request: A_AhkBuildDate

18 Mar 2020, 05:18

it does not
User avatar
SKAN
Posts: 1551
Joined: 29 Sep 2013, 16:58

Re: Request: A_AhkBuildDate

22 Apr 2020, 11:42

Code: Select all

MsgBox % PEDT(A_AhkPath)

PEDT(PEfile) { ; returns build date for Exe/Dll files                                  
Local File, DT:=1970 
  File := FileOpen(PEfile,"r")
  If ! IsObject(File)
      Return
  If ( File.ReadUSHORT()<>0x5A4D )                 ; Is IMAGE_DOS_HEADER.e_magic = 'MZ'?
      Return File.Close() + ""
  File.Seek(60,0)                                  ; Seek IMAGE_DOS_HEADER.e_lfanew 
  File.Seek(File.ReadUINT(),0)                     ; Seek IMAGE_NT_HEADERS
  If ( File.ReadUINT()<>0x00004550 )               ; Is IMAGE_NT_HEADERS.Signature = 'PE'?
      Return File.Close() + ""
  File.Seek(4,1)                                   ; Seek IMAGE_FILE_HEADER.TimeDateStamp
  DT += File.ReadUINT(), S                         ; 
  File.Close()
Return DT
}
My Scripts and Functions: V1  V2
User avatar
Raccoon
Posts: 53
Joined: 26 Jul 2014, 16:15

Re: Request: A_AhkBuildDate

07 Sep 2020, 04:01

@SKAN thanks! :o
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: Request: A_AhkBuildDate

07 Sep 2020, 13:31

Alternatively, or in conjunction with SKAN's solution above there may be another one that reads LastWrite time for the selected file. It may be of use, say to check if the file has been tampered with. As long as the file is in its original pristine state the LastWrite timestamp should be the same as the linker timestamp in the PE header.

The following is an AHK adaptation of the example code found here. Note that the original example uses the safe API StringCchPrintf() but for the life of me I couldn't get it to work here so I used the older "unsafe" version.

The date/time format of the output string can be changed by modifying the format string (second parameter of sprintf) and/or the order of the arguments following it (and the size of the r buffer if necessary). Currently it is in European format: day.month.year-full hour:minutes:seconds .

Disclaimer: I only tested it with AHK 32bit executable, in WINE under Linux Mint. There may be structure misalignment with 64bit AHK.

Code: Select all

MsgBox % GLMT(A_AhkPath)

GLMT(p)
{
VarSetCapacity(r, 40, 32)		; 19 Unicode chars + NULL
VarSetCapacity(buf, 36, 0)		; WIN32_FILE_ATTRIBUTE_DATA struct
VarSetCapacity(tu, 16, 0)		; SYSTEMTIME struct
if !DllCall("GetFileAttributesEx", "Str", p, "UInt", 0, "Ptr", &buf)
	return "Error 1"
if !DllCall("FileTimeToSystemTime", "Ptr", &buf+20, "Ptr", &tu)
	return "Error 2"
if !DllCall("msvcrt\sprintf"
	, "AStr", r
	, "AStr", "%02d.%02d.%04d %02d:%02d:%02d"
	, "UShort", NumGet(tu, 6, "UShort")	; day
	, "UShort", NumGet(tu, 2, "UShort")	; month
	, "UShort", NumGet(tu, 0, "UShort")	; year
	, "UShort", NumGet(tu, 8, "UShort")	; hour
	, "UShort", NumGet(tu, 10, "UShort")	; minutes
	, "UShort", NumGet(tu, 12, "UShort")	; seconds
	, "CDecl")
	return "Error 3"
return r
}
Part of my AHK work can be found here.

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 33 guests