Sunblood Posted May 3, 2021 Share Posted May 3, 2021 Is there any way for the script itself to reference the #AutoIt3Wrapper_Res_Fileversion as defined by AutoIt3Wrapper? To show the version number in a popup or tooltip, for example. I realize I can just define and update my own $version variable but this is about automation, isn't it Link to comment Share on other sites More sharing options...
Nine Posted May 3, 2021 Share Posted May 3, 2021 #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_Fileversion=2.2.2.2 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Constants.au3> Const $VERSION = @Compiled ? FileGetVersion(@ScriptName) : StringRegExp(FileRead(@ScriptName),"#AutoIt3Wrapper_Res_Fileversion=(.*)", 1)[0] MsgBox ($MB_SYSTEMMODAL, "", $VERSION) This ? Zedna 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Sunblood Posted May 3, 2021 Author Share Posted May 3, 2021 That's perfect, thank you Link to comment Share on other sites More sharing options...
argumentum Posted May 3, 2021 Share Posted May 3, 2021 Const $VERSION = @Compiled ? FileGetVersion(@ScriptFullPath) : StringSplit(StringRegExp(FileRead(@ScriptFullPath, 4096),"#AutoIt3Wrapper_Res_Fileversion=(.*)", 1)[0], " ;(", 2)[0] perfecter Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
seadoggie01 Posted May 3, 2021 Share Posted May 3, 2021 (edited) 8 minutes ago, argumentum said: 4096 perfecter What is this magic number madness you call perfecter? Edit: Btw, yours both fail if the user capitalizes Version in #AutoIt3Wrapper_Res_FileVersion. But I like this! Edited May 3, 2021 by seadoggie01 argumentum 1 All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
seadoggie01 Posted May 3, 2021 Share Posted May 3, 2021 Do you have a solution for using a3x files? It returns 0.0.0.0 since it is @Compiled and there is no version identifier All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
Nine Posted May 3, 2021 Share Posted May 3, 2021 (edited) Perfecterer #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_FileVersion=2.3.4.5 ; test #AutoIt3Wrapper_Outfile_type=a3x #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #pragma compile(Out, Temp1.a3x) #pragma compile(Fileversion, 2.3.4.5) #include <Constants.au3> Const $VERSION = @Compiled ? FileGetVersion(@ScriptName) : StringRegExp(FileRead(@ScriptName),"(?i)#AutoIt3Wrapper_Res_Fileversion=(.*?)\h*[;|\v]", 1)[0] MsgBox ($MB_SYSTEMMODAL, "", $VERSION) Edited May 3, 2021 by Nine added support to case insensitive seadoggie01 and argumentum 1 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
argumentum Posted May 4, 2021 Share Posted May 4, 2021 (edited) ok, gloves off expandcollapse popupGlobal Const $VERSION = GetScriptFileVersion() ConsoleWrite('+++ $VERSION = ' & $VERSION & @TAB & ' - Type:' & @extended & ' - @ERROR: ' & @error & @CRLF) Func GetScriptFileVersion($sFullPath = @ScriptFullPath, $UsePRODUCTVERSION = 0) ; https://www.autoitscript.com/forum/index.php?showtopic=205775&view=findpost&p=1481216 Local $StrVersionType = $UsePRODUCTVERSION ? "PRODUCTVERSION" : "FILEVERSION" If Not FileGetSize($sFullPath) Then Return SetError(1, 0, "") If StringRight($sFullPath, 4) = ".exe" Then Return ValidFileVersionString(FileGetVersion($sFullPath, $StrVersionType)) If StringRight($sFullPath, 4) = ".au3" Then Local $sPragma = "", $sWrapper = "", $aTemp, $n, $aArray = StringSplit(FileRead($sFullPath, 8192), @CRLF) For $n = 1 To UBound($aArray) - 1 ; reading 8k header should be enough, I hope $aArray[$n] = StringStripWS($aArray[$n], 8) If StringInStr($aArray[$n], "#AutoIt3Wrapper_Res_" & $StrVersionType & "=") = 1 Then ; last "Fileversion" found is used $aTemp = StringSplit($aArray[$n], "=;") If UBound($aTemp) < 3 Then ContinueLoop ; if commented out ";#AutoIt3Wrapper..." or ";#pragma ...", skip $sWrapper = ValidFileVersionString($aTemp[2], Int(Not $UsePRODUCTVERSION)) EndIf If $sPragma = "" And StringInStr($aArray[$n], "#pragmacompile(" & $StrVersionType & ",") = 1 Then ; first "Fileversion" found is used $aTemp = StringSplit($aArray[$n], ",)") If UBound($aTemp) < 3 Then ContinueLoop $sPragma = ValidFileVersionString($aTemp[2], Int(Not $UsePRODUCTVERSION)) EndIf Next If $sPragma <> "" Then Return SetError(0, 1, $sPragma) ; pragma supersedes wrapper (as in "rock paper scissors") If $sWrapper <> "" Then Return SetError(0, 2, $sWrapper) Return SetError(2, 0, "") EndIf Return SetError(3, 0, "") EndFunc ;==>GetScriptFileVersion Func ValidFileVersionString($sStr, $iRedim = 1) Local $n, $sReturn = "", $aArray = StringSplit(StringReplace($sStr, ",", "."), ".", 2) If $iRedim Then ReDim $aArray[4] ; Not the wrapper, nor Aut2exe, will accept comma separated. For $n = 0 To UBound($aArray) -1 ; but could be used to get expected results. Ref.: https://www.autoitscript.com/forum/index.php?showtopic=205520 If $n Then $sReturn &= "." $sReturn &= Int($aArray[$n]) Next Return $sReturn EndFunc ;==>ValidFileVersionString ...what if, what if... . Modified to get FileVersion as default, and optionally ProductVersion. Edited May 4, 2021 by argumentum better code Nine 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
VAN0 Posted April 29, 2023 Share Posted April 29, 2023 Or just have Global Const $VERSION = "1.0.0.0" It will be automatically updated/syncronized during compile. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now