Jump to content

adding other files than .ico to a script on compilation


Recommended Posts

#AutoIt3Wrapper_Res_Icon_Add=C:\Program Files\AutoIt3\Icons\au3.ico
#AutoIt3Wrapper_Res_Icon_Add=C:\Program Files\AutoIt3\Icons\filetype1.ico
#AutoIt3Wrapper_Res_Icon_Add=C:\Program Files\AutoIt3\Icons\filetype2.ico
#AutoIt3Wrapper_Res_Icon_Add=C:\Program Files\AutoIt3\Icons\filetype3.ico
#AutoIt3Wrapper_Res_Icon_Add=C:\Program Files\AutoIt3\Icons\filetype-blank.ico
#include <GUIConstants.au3>
GUICreate("Demo resource ICO's")
$h_Button1 = GUICtrlCreateButton("my picture button", 10, 20, 40, 40, $BS_ICON)
GUISetState()
For $x = 0 To 7
    $rc = TraySetIcon(@ScriptFullPath, $x)
    $rc2 = GUICtrlSetImage($h_Button1, @ScriptFullPath, $x)
    If $x < 3 Then
        TrayTip("Default ico:" & $x, "TraySetIcon rc:" & $rc & @LF & "GUICtrlSetImage rc:" & $rc2, 3)
    Else
        TrayTip("New ico:" & $x, "TraySetIcon rc:" & $rc & @LF & "GUICtrlSetImage rc:" & $rc2, 3)
    EndIf
    Sleep(2000)
Next
GUIDelete()

is it possible to add other resources like .bmp .cur .ani .avi and others to a script in the same way autoit3wrapper does it with .ico (see above?)

j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

i know. but i want to know how to use the autoitwrapper and i would like to know its limitations. it is much more elegant to run an .exe without spreading the files on the client's pc.

.cur, Symbol, .Bmp, .GIF-, .AVI, . JPG, .WAv and -MID Ressources can be added manually with the help of a res hacker. so is this possible from within a script like in the above example ?

j.

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

  • Developers

The issue isn't adding the resources but how would we retrieve them once they are in the program resources ?

I have no issue think about adding this option but somebody needs to test/figure out how this would work ....

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 comment
Share on other sites

maybe you are right. that could be the bigger problem.

but i would like to advance the dll resp. resource reading abilities of autoit and think loud about it.

for bitmaps i could use larry's _SetBitmapResourceToPicCtrl() fuction with a self-made dll and also add icons to it. the same for cursor resources. but how could cursors be read out ?

maybe someone could add this functionality to the _SetCursor($s_file,$i_cursor) function ? up to now you need a single .cur file to use it.

then there is more data to be read out, e.g. JPEG, GIF, RC_Data (with AVI, MID), WAVE files and complete pre-designed dialog boxes. i am not sure why this should be more difficult than BITMAPS. the msdn database could help:

I think you are looking for FindResource API. For sample of its use see the barcmd.cpp ( CCommnadBar::InsertenuBarEx). Ex.

::FindResource(hInstance, pszMenu, RT_RCDATA).

http://msdn.microsoft.com/library/default....indResource.asp

(found in another forum (delphi))

on the other hand, it is very annoying writing resource dlls resp. exes manually with the help of a resource hacker, especially when you have to exchange the resources day by day. so it would be very wishful to add this functionality to autoit, just like the way the autoit3wrapper does it already automatically with icons and version info. so maybe this is the beginning of dll usabilty....

of course we have this wonderul fileinstall already but being honest, who wants to spread his files on other's computers where they can be so easily changed ? :)

i'll try to work on these issues, but i fear i'm lacking the abilities...

so long j. :-)

i would appreciate if someomes leaves helpful links here on this issue.

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

The issue isn't adding the resources but how would we retrieve them once they are in the program resources ?

I have no issue think about adding this option but somebody needs to test/figure out how this would work ....

Jos

:)

If by 'how would we retrieve them' you mean how would the code look in AutoIt then my suggestion is that something is needed to make it as simple as possible and usable with as many of the existing techniques as possible.

For example, at the moment we can load an image from a file just using the reference to the full path of the filename, or we can open a file for reading again with reference to the full path for the file.

My suggetion is that there is a new gloabl variable @Resource. So to load an image we say

GuiCreatePic(@Resource & "\tulip.bmp",10,10)

and so on.

This is quite disconnected from how it would be achieved of course.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • Developers

If by 'how would we retrieve them' you mean how would the code look in AutoIt then ......

I meant once the resources are added how do you retrieve is with the current AutoIt3 release ....

:)

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 comment
Share on other sites

It has been suggested by Zedna as possibly working, but no one else it seems has confirmed it yet, so I will

you can add bitmap BMP resources to your compiled exe and access them using @ScriptFullPath

without the need for a resource DLL

search forum for Larry's UDF "SetBitmapResourceToPicCtrl"

example code snippet

#AutoIt3Wrapper_Run_After=C:\ResHacker\ResHacker.exe  -script C:\Compile\reshack.txt

; I have reshacker installed off C:\ already so I use it, can't remember if space in pathname of AutoIt3 folder path was problem here

$guipic1 = GUICtrlCreatePic("", 300, 47, 270, 270, -1, $WS_EX_LAYERED)
SetBitmapResourceToPicCtrl($gui,$guipic1,@ScriptFullPath,"CRT_1_BMP"); crt_1.bmp

haven't tried this yet with @AutoItExe instead of @ScriptFullPath, they seem the same for a compiled exe

don't know what any limitations are of this, as I have only compiled 7 bitmaps totalling 300k

upx compression seems to break the functionality of linking to the internal bitmap resources

you can upx compress with the add icon resource option of compile

I add 12 icons to the exe for my toolbar

icons are added after upx compression to the exe

but adding the bitmap resource section after upx compression doesn't work

I leave the exe uncompressed.

I don't know about running a script that uses this technique through the obsfucator as the only code i've tried this with so far

uses Martin's Commg.au3 include and DLL for serial communication and Obsfucator doesn't work for the "Execute" function

in the include

contents of reshack.txt

//This script adds 7 bitmaps to compiled exe G2.exe
  // place this line in "After" Tab section of compile options "C:\ResHacker\ResHacker.exe  -script C:\Compile\reshack.txt"

  [FILENAMES]
  Exe=    C:\Program Files\AutoIt3\Projects\G2\G2.exe

  SaveAs=   C:\Program Files\AutoIt3\Projects\G2\G2.exe

  [COMMANDS]
  // Reshacker doesn't seem to like spaces in pathname, so I place bitmaps in folder off root
  -add C:\Compile\crt_1.bmp, BITMAP,CRT_1_BMP,0
  -add C:\Compile\crt_2.bmp, BITMAP,CRT_2_BMP,0
  -add C:\Compile\g2.bmp, BITMAP,G2_BMP,0
  -add C:\Compile\DarkLED.bmp, BITMAP,DarkLED_BMP,0
  -add C:\Compile\GreenLED.bmp, BITMAP,GreenLED_BMP,0
  -add C:\Compile\RedLED.bmp, BITMAP,RedLED_BMP,0
  -add C:\Compile\YellowLED.bmp, BITMAP,YellowLED_BMP,0
Edited by rover

I see fascists...

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...