Jump to content

Recommended Posts

Posted (edited)

Yas, I was doing something badly ;-)

Now it works.

The problem is I cannot add an icon to the exe. Using ResHack I can put the icon, but then the executable fails to run...

Which file are you using from the sample pack that fails to execute after creating a resource table?

And with AutoIt3.exe in the PATH or same folder it should run, isn't it?

I get an error: Missing separator character after keyword.

I'm probably doing something the wrong way...

Some of those crap examples Need to be in the directory of the main interpreter and some will find it if Au3 exists in one of the directories defined under the path environment variable.

perhaps I should have commented which is which better.

Edited by Mobius

wtfpl-badge-1.png

  • 3 weeks later...
  • Replies 46
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted

I'm sorry for the delay in replying, I was on holidays ;-)

I used the C version: A3XPE_C.exe (should I use another one?)

Yes, it needs the interpreter in the same directory, and when I put it there it executes perfectly, the problem is that I cannot add the resources without spoiling it... well, maybe I'm using a rather old version of Reshack: v3.4

How did you build your Example.exe with all the icons?

Posted (edited)

I'm sorry for the delay in replying, I was on holidays ;-)

I used the C version: A3XPE_C.exe (should I use another one?)

Yes, it needs the interpreter in the same directory, and when I put it there it executes perfectly, the problem is that I cannot add the resources without spoiling it... well, maybe I'm using a rather old version of Reshack: v3.4

How did you build your Example.exe with all the icons?

Yo Ximorro,

Hope you enjoyed your holiday. ;-)

The reason for your problems is my fault alone, I had not accounted for paths with spaces in that particular example.

I have fixed this and added it to this new download, thanks for pointing this out.

Undocumented info

All samples can pass additional commandline parameters to AutoIt3.exe.

Example:

A3XPE_C arg1 arg2 arg3 ...etc

Would Call AutoIt3 like so.

AutoIt3.exe "C:\example\AX3PE_C.exe" arg1 arg2 arg3 ...etc

This sample searches only its own directory for AutoIt3

A3XPE_FB

These Samples can also find Au3 via the path environment variable

A3XPE_C

A3XPE_BCX

A3XPE_PB

Adding a resource table to any of the samples with a pe editor will not cause any of them to fail.

(although I recommend adding the resources before concatenating the A3x)

The Example.exe

Which is packed with upx Was created using the A3XPE_PB sample, the pre generated A3x file and all resources were added to it with Resource Hacker, this way you do not need to concatenate the a3x. :idea:

Respect

Edited by Mobius

wtfpl-badge-1.png

Posted

Thank you VERY MUCH! I'll try it this week end!

I didn't think about adding the resources before concatenating, and adding the a3x as a resource is probably even safer. Thanks for pointing it out!

One more question (I hope you've got a great deal of patience... ;-) )

How do you reference resources in the autoit program? I mean the resources you will add to the final exe, of course. For instance I can use:

GUICtrlSetImage(-1, "C:\myicon.ico")

so the a3x (or au3) work properly when developing, but in production I want to use the icon (or other type of resource) from the exe.

With AutoIt3Wrapper I can use (only for icons I think) a Res_Icon_Add directive:

#AutoIt3Wrapper_Res_Icon_Add=C:\myicon.ico

and then use it in the au3 with an index, so the au3 and exe work without changing the code.

But how can I simulate this when adding resources on my own? Besides, AutoIt3Wrapper offers this funcionality just with icons, I think it should be more general (sound, xml files, whatever...)

Best regards,

Ximo

Posted

Zedna has a great resources UDF with examples

http://www.autoitscript.com/forum/index.php?showtopic=51103

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Posted (edited)

Thank you VERY MUCH! I'll try it this week end!

I didn't think about adding the resources before concatenating, and adding the a3x as a resource is probably even safer. Thanks for pointing it out!

Semi related but did you know that the Au3 interpreter for standalone exe's (AutoItSC.bin) can find A3x data from its own resource table, the A3x data does not have to be concatenated.

Example:

  • Take a copy of AutoItSC.bin and add a simple test A3x file to it with a pe editor and save as whatever.exe
  • Execute this file and the interpreter should locate and execute the resource embedded test data.
Perhaps I should mention that if you pack the executable you must remember that the resource item that holds the A3x cannot be packed for the exe to work, so you should use a tool (upx) that allows you to specify what parts to pack and more importantly what not to pack.


One more question (I hope you've got a great deal of patience... ;-) )

How do you reference resources in the autoit program? I mean the resources you will add to the final exe, of course. For instance I can use:

GUICtrlSetImage(-1, "C:\myicon.ico")

so the a3x (or au3) work properly when developing, but in production I want to use the icon (or other type of resource) from the exe.

With AutoIt3Wrapper I can use (only for icons I think) a Res_Icon_Add directive:

#AutoIt3Wrapper_Res_Icon_Add=C:\myicon.ico

and then use it in the au3 with an index, so the au3 and exe work without changing the code.

But how can I simulate this when adding resources on my own? Besides, AutoIt3Wrapper offers this funcionality just with icons, I think it should be more general (sound, xml files, whatever...)

Best regards,

Ximo

I am not sure AutoIt3Wrapper can be used in this way, not even if you specify one of the A3xpe's as the alternate /Bin file, Use a resource hacker script if this is the case.

And so we come to the primary limitation of purpose for these samples/methods.

Icons and version info can be used because Au3 has native functions that supports these resource types from a file, so you could reference them from the pe using the scriptfullpath macro like so::

#cs
 Taken from Example.au3 in the archive, code assumes 4 icons and version info exists in the sample exe.
 Obviously this must be made into an A3x and added to an executable sample to work.
#ce
GUICREATE("",550,165,305,219)
IF @COMPILED
 TRAYSETICON(@SCRIPTFULLPATH,1)
 GUISETICON(@SCRIPTFULLPATH,1)
 GUICTRLCREATEICON(@SCRIPTFULLPATH,2,5,5,32,32)
 GUICTRLCREATEICON(@SCRIPTFULLPATH,3,45,5,32,32)
 GUICTRLCREATEICON(@SCRIPTFULLPATH,4,85,5,32,32)
 GUICTRLCREATEINPUT(FILEGETVERSION(@SCRIPTFULLPATH,"ProductName"),125,10,121,21)
 GUICTRLCREATEINPUT(FILEGETVERSION(@SCRIPTFULLPATH,"LegalCopyright"),255,10,121,21)
 GUICTRLCREATEINPUT(FILEGETVERSION(@SCRIPTFULLPATH,"CompanyName"),380,10,121,21)
ELSE
 ; above instructions but using the resource filename instead of @SCRIPTFULLPATH
ENDIF
GUISETSTATE(@SW_SHOW)
WHILE 1
 $MSG=GUIGETMSG()
 SWITCH $MSG
 CASE -3
    EXIT
 ENDSWITCH
WEND

And that's about it as far as the exe's go. (without alot of Au3 code or creating your own a3xpe to suit your needs)


If you are determined to use all types of resources you could add your A3x to a dll that contains the resources and reference them with internal functions and Zedna's excellent UDF (recommended by GEOSoft above).

However with a dll instead of an exe you will lose the shell icon (~) and the ability to execute your script without first calling the interpreter on it.

Example:

AutoIt3.exe "x:\Lib Dir\Hybrid.dll" arg1 arg2 arg3 ...etc

But with a dll your extensibility and resource interaction options expand greatly. :idea:


Another idea would be to have the Au3 interpreter (or one of your scripts built as a standalone) that contains all major and shared resources related to your product(s), and just have minor things like icons and versioninfo in the A3xPE(s).

Anything major would need to be done with the previously mentioned resource api udf, but icons can be done internally.

Respect

Vlad

Edited by Mobius

wtfpl-badge-1.png

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...