Jump to content

Automatically set #AutoIt3Wrapper_Res_ProductVersion value equal to #AutoIt3Wrapper_Res_Fileversion value?


Go to solution Solved by Jos,

Recommended Posts

Is there a way I can set things so that when the #AutoIt3Wrapper_Res_Fileversion value gets automatically incremented (after compiling), the #AutoIt3Wrapper_Res_ProductVersion value gets automatically updated too?

In other words, some automated way to ensure that #AutoIt3Wrapper_Res_ProductVersion is always set to the same value as #AutoIt3Wrapper_Res_Fileversion so when the script is compiled those resource fields always match?

Link to post
Share on other sites
  • Replies 41
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

May have answered my own question, although if there is an easier or better way to accomplish this I'm all ears. What I did: Edit the AutoIt3Wrapper.au3 file found in the C:\Program Files (x

I choose to set the default for Product version to the version of AutoIt3 it is compiled with as default, so one can see which AutoIt3 version it is running with.

mmm..  well thinking about it a bit longer this should obviously also work: #AutoIt3Wrapper_Res_FileVersion=1.1.1.1 #AutoIt3Wrapper_Res_ProductVersion=%fileversion%  

Posted Images

May have answered my own question, although if there is an easier or better way to accomplish this I'm all ears.

What I did:

Edit the AutoIt3Wrapper.au3 file found in the C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper folder. In the 'Compile_Upd_res' function I changed this line:

If $INP_ProductVersion = "" Then $INP_ProductVersion = FileGetVersion($AutoItBin)

to

If $INP_ProductVersion = "" Then $INP_ProductVersion = $INP_Fileversion

In version 21.316.1639.1 of the AutoIt3Wrapper.au3 file that ships with AutoIt 3.3.16.1, that's line # 2558.

With this change, instead of defaulting to the AutoIt.exe version number if nothing is entered for the Product Version number, it defaults to whatever was entered as the File Version number. But the Product Version can still be specified as something else in the usual way and it works correctly.

Link to post
Share on other sites

it makes sense:

If $INP_Fileversion = "" Then $INP_Fileversion = FileGetVersion($AutoItBin)
If $INP_ProductVersion = "" Then $INP_ProductVersion = $INP_Fileversion

If nothing is declared the use Default, else, FileVersion.

..this does not work as expected but is the idea.

Edited by argumentum
Link to post
Share on other sites
  • Developers

I choose to set the default for Product version to the version of AutoIt3 it is compiled with as default, so one can see which AutoIt3 version it is running with.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
9 hours ago, argumentum said:

it makes sense

...a lot of things make sense, when makes sense to oneself, even if wrong. But there ain't right or wrong in this case, now, after writing many many lines of code and a FileVersion, why leave ProductVersion unattended ?.
The wrapper is clear text and can be personalized by anyone.
I take back my motion to change the defaults. 🔨(didn't find a gavel emoji)

Link to post
Share on other sites
  • Developers

Initially I made it so the Product version was always the version of AutoIt3 and later, on request, allowed that default to be overridden.
So I indeed have no intentions to change that as that way is the way I think is the best approach.  ;) 

Anybody can make their own modifications when desired. 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
  • Developers

mmm..  well thinking about it a bit longer this should obviously also work:

#AutoIt3Wrapper_Res_FileVersion=1.1.1.1
#AutoIt3Wrapper_Res_ProductVersion=%fileversion%

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
7 hours ago, Jos said:

Well that's certainly easier than mucking about in the guts of the system. I was hoping there was a better solution and I think this is it! 😁

Only little issue with it, however, is that if you later modify anything using the AutoIt3Wrapper GUI and thereby trigger all of the #AutoIt3Wrapper... directives to be updated in the script, it converts the %fileversion% variable to its current literal value and writes that into the script. So then you have to manually go back and change it to %fileversion% again. But as long as you leave things alone it keeps the %fileversion% variable in place, even when auto-incrementing the file version after a build (since that doesn't update all of the #AutoIt3Wrapper... directives, only the #AutoIt3Wrapper_Res_Fileversion directive).

I do have a suggestion, though, since it seems a number of users may not want the AutoIt version number showing up in the Product Version field of the compiled exe's details: Already if you don't specify anything for the #AutoIt3Wrapper_Res_Comment directive, it defaults to the comment field from Aut2Exe which is the AutoIt website address. My suggestion is to add the compiler name and version number at the beginning of the comment, so it ends up defaulting to something like "Aut2Exe 3.3.16.1 http://www.autoitscript.com/autoit3/" if nothing is otherwise specified. The AutoIt version used to compile the script is useful information to the builder of the exe, although less useful to the end user. Since the Comment value isn't typically visible on the Details tab of the file properties, it wouldn't be confusing to the end user. The developer though could always see the Comment info using something like Resource Hacker.

Would be as simple as changing line 2554 of AutoIt3Wrapper.au3 from

If $INP_Comment = "" Then $INP_Comment = FileGetVersion($AutoItBin, "Comments")

to

If $INP_Comment = "" Then $INP_Comment = FileGetVersion($AutoItBin, "ProductName") & " " & FileGetVersion($AutoItBin) & " " & FileGetVersion($AutoItBin, "Comments")

Or, even better, just add a new custom field (such as 'AutoIt Version') to the info of every compiled script exe that doesn't show up in Details (so it doesn't confuse end users) but is viewable through Resource Hacker or something similar. Make it always be the AutoIt version that compiled the exe and don't make it an option that can be overridden. Then that bit of useful info is always there regardless.

Link to post
Share on other sites
  • Developers
6 hours ago, TimRude said:

Only little issue with it, however, is that if you later modify anything using the AutoIt3Wrapper GUI and thereby trigger all of the #AutoIt3Wrapper.

This seems to be a general flaw in AutoIt3Wrapper for a long long time. Need to think what the best solution for this is for the GUI to ensure it shows the actual content in stead of its translated value.

I will not make other changes to comments or add extra fields as that is something you could do yourself via a directive. 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
  • Developers

I have moved all the _Convert_Variables() logic together in one block, just after the GUI is shown, so this avoids updating the Directives when using Compile-with-Options.
Please try the current beta v 22.611.2153.9.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

The beta now leaves the variables unconverted in the directives. ✔

However, if you modify any of the compilation settings in the GUI and then click the Compile button in the GUI, it doesn't translate %fileversion% (which I used as ProductVersion) or %scriptfile% (which I used as ProductName) when producing the exe. Instead you get the literals '%fileversion' and '%scriptfile%' showing up in the Details of the compiled exe. However, if you click the 'Save Only' button first to update the directives in the script, and then select Build from the Tools menu (or press F7), it correctly translates the variables in the compiled exe.

Another couple of quirks with this beta version of AutoIt3Wrapper.au3:

1) I created an AutoIt3Wrapper.ini file in my C:\Users\<user>\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper\ folder by copying the AutoIt3Wrapper.ini.example that was there and then setting pre-defined default values for three of the settings so they'd always be set in my compiled exes. 

Language=1033
Field1Name=AutoItVersion
Field1Value=3.3.16.1

What I'm finding is that 'AutoItVersion=3.3.16.1' is getting repeatedly entered into the Extra resource fields box on the GUI. Each time I make a change to any of the compilation settings and save the changes, it adds another copy of it again.

2) I'm also accumulating an extra copy of the '#EndRegion ;;**** Directives created by AutoIt3Wrapper_GUI ****' line in the script each time I make a change to any of the compilation settings and save the changes.

#Region ;;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Description=Test App
#AutoIt3Wrapper_Res_Fileversion=1.0.0.6
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_ProductName=%scriptfile%
#AutoIt3Wrapper_Res_ProductVersion=%fileversion%
#AutoIt3Wrapper_Res_CompanyName=XYZ Widgets
#AutoIt3Wrapper_Res_LegalCopyright=legal copyright
#AutoIt3Wrapper_Res_Language=1033
://////=__=...
://////=__=...
://////=__=...
://////=__=...
://////=__=://///=
#AutoIt3Wrapper_Res_Field=Field With Spaces|will it work?
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Run_Au3Stripper=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;;**** Directives created by AutoIt3Wrapper_GUI ****
MsgBox(0, "Test App", "Hello World!")

 

Link to post
Share on other sites

 After a bit of further testing, I'm noticing that any directives specified using an AutoIt3Wrapper.ini file are being written back to the script as an #AutoIt3Wrapper_Res_... directive. For example, my script didn't originally have an #AutoIt3Wrapper_Res_Language=1033 directive, but one was auto-created by the GUI based on the line in the ini file. The stock AutoIt3Wrapper.au3 doesn't do that.

I also tried and adding to the AutoIt3Wrapper.ini file the following 2 entries in the [Res] section (after deleting the #AutoIt3Wrapper_Res_ProductName and #AutoIt3Wrapper_Res_ProductVersion directives from the script):

ProductName=%scriptfile%
ProductVersion=%fileversion%

I was experimenting to see if that would be another way to alleviate the issue with the stock wrapper converting the variables to their values when updating the directives in the script.

Interesting enough, this worked in the beta because of its current behavior of writing the ini settings as directives into back into the script. In the stock version however, it didn't work. I got a red message in the output window saying '! Invalid FileVersion value 1=%fileversion%. It will be changed to:0' and then the variables didn't get converted when compiling the exe and instead showed up in the exe details as the %variable% names. So clearly the stock wrapper reads the info from the .ini file, but doesn't convert the variables when doing so. I suspect the beta likely does the same thing, but because the directives get written to the script (assuming the Save Only button is pressed), the variables found there  (in the script) are being converted.

Details.png

Link to post
Share on other sites
  • Developers
17 minutes ago, TimRude said:

After a bit of further testing, I'm noticing that any directives specified using an AutoIt3Wrapper.ini file are being written back to the script as an #AutoIt3Wrapper_Res_... directive.

I know and understand the problem in AutoIt3Wrapper. Just give me some time to have a look and see what the best way is to deal with this. :) 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
  • Developers

Made some more changes and hope I got your last reported issues properly covered this time. please give the latest Beta v 22.611.2153.10 version a try. :) 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

...looks good. I did change this line:

If $INP_Description = "" Then $INP_Description = _Convert_Variables("%scriptfile%") ; FileGetVersion($AutoItBin, "FileDescription")

and the reason is that Win10 decides to use the description a lot as if it was descriptive of what's running. To me the .exe is it but, what are we gonna do with modern developers.

The comment entry is no longer shown in "properties" and seemed replaced by "description", and "description" is what's shown in TaskManager(Processes) instead of FileName !?, hence the need for the change.

Link to post
Share on other sites

The new beta nicely solves almost all of the issues I mentioned. However, one remains:

With an AutoIt3Wrapper.ini file containing the lines:

[Res]
Field1Name=AutoItVersion
Field1Value=3.3.16.1

I'm still finding that 'AutoItVersion=3.3.16.1' is getting repeatedly entered into the Extra resource fields box on the GUI (and into the directives in the script). Each time I make a change to any of the compilation settings and save the changes, it adds another copy of it again. And then the exe ends up with multiple extra fields in the resources.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Description=Test app
#AutoIt3Wrapper_Res_Fileversion=1.0.0.18
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_ProductName=%scriptfile%
#AutoIt3Wrapper_Res_ProductVersion=%fileversion%
#AutoIt3Wrapper_Res_CompanyName=XYZ Widgets
#AutoIt3Wrapper_Res_LegalCopyright=legal copyright
#AutoIt3Wrapper_Res_LegalTradeMarks=legal trademark
#AutoIt3Wrapper_Res_Language=1033
://////=__=...
://////=__=...
://////=__=...
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Run_Au3Stripper=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
MsgBox(0, "Test App", "Hello World!")

You'll notice that there are 3 instances of the #AutoIt3Wrapper_Res_Field directive in the script, whereas the compiled exe ends up with 4 instances because one from the .ini is added to what has accumulated in the script.

So it seems that if a field is specified in the AutoIt3Wrapper.ini whose name and contents exactly match one that's already in the script (or in the Extra Resource Fields box in the GUI), it shouldn't be added again.

ResHacker.png

Link to post
Share on other sites
  • Developers
6 hours ago, TimRude said:

The new beta nicely solves almost all of the issues I mentioned. However, one remains:

Thanks for testing and the feedback!  
I have made some more changes for the issue you have and hope that one is now also resolved in the latest beta.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
  • Developers
Posted (edited)
16 hours ago, argumentum said:

...looks good. I did change this line:

Why now simply set this in the AutoIt3Wrappper.ini:

[RES]
Description=%scriptfile%

..in stead of modifying the code?
Result should be the same and this still leaves the flexibility to override that default with:

#AutoIt3Wrapper_Res_Description=test

 

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
5 hours ago, Jos said:

I have made some more changes for the issue you have and hope that one is now also resolved in the latest beta.

Looks like that fixed it! Thanks so much!

One more quick question if I may be so bold: I noticed in looking through the AutoIt3Wrapper.au3 code that there's a line (#2112 in the latest beta) defining a variable named %AutoItVer%.

$I_String = StringReplace($I_String, "%AutoItVer%", $AUT2EXE_PGM_VER)

So I thought I'd try changing the line in my AutoIt3Wrappper.ini file so that instead of hard-coding the AutoIt version number as the literal string '3.3.16.1', I'd instead set it to %AutoItVer%, like this:
 

[Res]
Field1Name=AutoItVersion
Field1Value=%AutoItVer%

That way whenever a later update to a new  AutoIt version comes along, the field would still always show the correct info without having to remember to manually update the ini file. However, that variable doesn't appear to be converted into anything and I end up with this:

ResHacker2.png

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...