Jump to content

Recommended Posts

Posted (edited)

Note: I have problems with edit original post from my Opera (second autoit script in autoit tags gets corrupted)

so I will add it here:

Some descriptions:

#compiler_run_after=ResHacker.exe -add resource_test.exe, resource_test.exe, test_1.txt , 10, TEST_1, 0

in the above directive

test_1.txt means file with data (may be TXT or binary) to be included as resource

10 means RT_RCDATA type of resource

TEST_1 is choosen resource name

0 at the end is LangId - lang_neutral = 0

#compiler_run_after=ResHacker.exe -add resource_test.exe, resource_test.exe, test_1.txt , 10, TEST_1, 0

can be also replaced by adding precompiled RES file:

Test_1.rc

TEST_1 RCDATA "test_1.txt"

compile RC file to RES file:

rc.exe Test_1.rc

changed directive for adding precompiled RES resource instead of source data file (Test_1.txt)

#compiler_run_after=ResHacker.exe -add resource_test.exe, resource_test.exe, test_1.res ,,,

Maybe some AutoIt3Wrapper resource directive could be added for simplicify adding such resources,

something similar to #AutoIt3Wrapper_Res_Icon_Add=

for example:

1) precompiled resources

#AutoIt3Wrapper_Res_Add=filename1.res
#AutoIt3Wrapper_Res_Add=filename2.res

and/or

2) data from source files

#AutoIt3Wrapper_Res_Data_Add=filename1.txt,RT_RCDATA,res_name1
#AutoIt3Wrapper_Res_Data_Add=filename2.dat,RT_RCDATA,res_name2
#AutoIt3Wrapper_Res_Data_Add=filename3.jpg,RT_RCDATA,res_name3
#AutoIt3Wrapper_Res_Data_Add=filename4.bmp,RT_BITMAP,res_name4

so it's: #AutoIt3Wrapper_Res_Data_Add=filename,datatype,resource name

EDIT:

but the best solution will be direct Autoit directive (similar to #include)

#resource=filename1.res
#resource=filename2.res

Note: bitmap resources can be used by using LoadLibrary, LoadImage API calls, see Larry's LoadImage examples from this and this - SetBitmapResourceToPicCtrl()

Edited by Zedna
Posted (edited)

This looks like what a lot of people have been asking for, and although you only created this thread yesterday, I'm surpised there aren't a lot of replies already. I haven't tried it yet but it looks like your usual excellent work Zedna. Thanks for this script.

Edited by martin
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.
Posted

This looks like what a lot of people have been asking for, and although you only created this thread yesterday, I'm surpised there aren't a lot of replies already. I haven't tried it yet but it looks like your usual excellent work Zedna. Thanks for this script.

Thanks for positive feedback martin.

JdeB said that he can add some Autoi3Wrapper directive if we can simplify all that resource process/examples.

Posted

Zedna this is great

how do I use for internal bitmap?

I've run the text demo above O.K.

I'm already using Larry's UDF in one of my scripts to use internal bitmaps without using fileinstall or a resource dll

is it the _ResourceGetAsPointer function?

if so what data / format is used for $ResSize?

$pic = _ResourceGetAsBytes("WINNT_BMP", $RT_BITMAP)

$pic = _ResourceGetAsPointer("WINNT_BMP", $RT_BITMAP) obviously needs third parameter

i know to use directive:

#AutoIt3Wrapper_Run_After=ResHacker.exe -add resource_test.exe, resource_test.exe, winnt.bmp , 2, WINNT_BMP, 0oÝ÷ Û­Ç+ZÖæ¦)ìjg¢W^­«+zÈZrG«­ë!iÉ®»§¶èºp­ªiz¸Z²ènW¦Â+a²zȧ¥«a© J®¢Óë¢
Úø¥zÊ®¢Ø­r©W¬¶¢¨{h¶Å觶٦Ƕ*'¡úÞ²«qëºÜ!jج¶ºw-Ú×è®f­¶h¶¬jg²Øb±«­¢+ØÀÌØíÕ¥Á¥ÄôU%
Ñɱ
ÉÑA¥ ÅÕ½ÐìÅÕ½Ðì°À°À°ÈÜÔ°ÄÜа´Ä°ÀÌØí]M}a}1eI¤((íÌÕÍÝ¥Ñ 1ÉÉäÌäíÌUMÑ  ¥ÑµÁIͽÕÉQ½A¥
ÑÉ°()MÑ ¥ÑµÁIͽÕÉQ½A¥
ÑÉ° ÀÌØíÕ¤°ÀÌØíÕ¥Á¥Ä±MÉ¥ÁÑÕ±±AÑ °ÅÕ½Ðí]%99Q}  5@ÅÕ½Ðì

Thanks!

I see fascists...

Posted (edited)

Zedna this is great

how do I use for internal bitmap?

I've run the text demo above O.K.

I'm already using Larry's UDF in one of my scripts to use internal bitmaps without using fileinstall or a resource dll

Thanks!

I will accomodate Larry's SetBitmapResourceToPicCtrl() function to make it more compatible/usable with my UDF

and will make also example for bitmaps.

Stay tuned ...

Edited by Zedna
Posted (edited)

Here is promised first working bitmap from resource example with changed (simplified) Larry's SetBitmapResourceToPicCtrl() function:

Unfortunatelly

#compiler_run_after=upx.exe --compress-resources=0 resource_test_bmp.exe
will cause not adding bitmap resource so it must be compiled without UPX :)

I discovered that problem is in second #compiler_run_after= which will not wait for the first #compiler_run_after= to be finished - with my big testing bitmap)

note: image1.bmp is in my case 800x600 and 1.5MB size and is located in script directory

resource_test_bmp.au3

#compiler_useupx=n
  #compiler_run_after=ResHacker.exe -add resource_test_bmp.exe, resource_test_bmp.exe, image1.bmp, 2, TEST_BMP_1, 0
;#compiler_run_after=upx.exe --compress-resources=0 resource_test_bmp.exe
   
  $gui = GUICreate("Bitmap from resources test",900,700)
  $pic = GUICtrlCreatePic("",0,0,800,600)
  GUISetState()
  
  SetBitmapResourceToPicCtrl($gui,$pic,"TEST_BMP_1")
  
  While 1
      If GUIGetMsg() = -3 Then Exit
  WEnd
  
  Func SetBitmapResourceToPicCtrl($hwnd,$ctrl,$resource)
      Local Const $STM_SETIMAGE = 0x0172
      Local Const $IMAGE_BITMAP = 0
      Local Const $LR_CREATEDIBSECTION = 0x2000
      Local Const $LR_COPYDELETEORG = 8
  
      $hwnd = ControlGetHandle($hwnd,"",$ctrl)
     
      Local $hInstance = DllCall("kernel32.dll","int","GetModuleHandleA", "int",0)
      $hInstance = $hInstance[0]
   
      Local $hBitmap = DLLCall("user32.dll","hwnd","LoadImage","hwnd",$hInstance,"str",$resource, _
              "int",$IMAGE_BITMAP,"int",0,"int",0,"int",0)
      $hBitmap = $hBitmap[0]
     
      DeleteObject(_SendMessage($hwnd,$STM_SETIMAGE,$IMAGE_BITMAP,$hBitmap,0,"int","int","hwnd"))
  EndFunc
  
  Func _SendMessage($hWnd, $msg, $wParam = 0, $lParam = 0, $r = 0, $t1 = "int", $t2 = "int", $t3 = "long")
     Local $ret = DllCall("user32.dll", $t3, "SendMessage", "hwnd", $hWnd, "int", $msg, $t1, $wParam, $t2, $lParam)
      If @error Then Return SetError(@error, @extended, "")
      If $r >= 0 And $r <= 4 Then Return $ret[$r]
      Return $ret
  EndFunc ; _SendMessage()
  
  Func DeleteObject($hObj)
      Local $bResult = DllCall('gdi32.dll', 'int', 'DeleteObject', 'hwnd', $hObj)
      Return $bResult[0]
  EndFunc   ;==>DeleteObject

I will make some change in my resources.au3 UDF to be more general.

Idea is to to have one general function

_ResourceGet($ResName, $ResType, $ResLang = 0)

which will return result based on the given type

also ResSize will be returned in @extended macro

I have not too much time now, so stay tuned ...

Edited by Zedna
Posted (edited)

Some notes about directives for adding resources:

- 10=RT_RCDATA, 2=RT_BITMAP

- instead of EXE name can be used %out% parameter

- in new Scite4Autoit3 is #AutoIt3Wrapper_Run_After= directive instead of old #compiler_run_after= directive

RT_RCDATA example old way

#compiler_run_after=ResHacker.exe -add resource_test.exe, resource_test.exe, test_1.txt, 10, TEST_1, 0
  #compiler_run_after=upx.exe --compress-resources=0 resource_test.exe

RT_RCDATA example better way with %out%

#compiler_run_after=ResHacker.exe -add %out%, %out%, test_1.txt, 10, TEST_1, 0
  #compiler_run_after=upx.exe --compress-resources=0 %out%

***

RT_BITMAP example old way

#compiler_run_after=ResHacker.exe -add resource_test_bmp.exe, resource_test_bmp.exe, image1.bmp, 2, TEST_BMP_1, 0
  #compiler_run_after=upx.exe --compress-resources=0 resource_test_bmp.exe

RT_BITMAP example better way with %out%

#compiler_run_after=ResHacker.exe -add %out%, %out%, image1.bmp, 2, TEST_BMP_1, 0
  #compiler_run_after=upx.exe --compress-resources=0 %out%
Edited by Zedna
Posted (edited)

I had to make sure reshacker was in same dir as files (didn't use upx), but it works well. I hope it becomes easier to use. :)

Edited by RazerM
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Posted (edited)

this fails

#AutoIt3Wrapper_Run_After="%scitedir%\AutoIt3Wrapper\ResHacker.exe" -script C:\Program Files\AutoIt3\Examples\reshack.txt

this fails

#AutoIt3Wrapper_Run_After="%scitedir%\AutoIt3Wrapper\ResHacker.exe" -script "C:\Program Files\AutoIt3\Examples\reshack.txt"

this works

#AutoIt3Wrapper_Run_After="%scitedir%\AutoIt3Wrapper\ResHacker.exe" -script C:\Compile\reshack.txt

reshacker script method (same method as used in autoit3wrapper.au3, that's whats used for extra icon add)

try this:

#AutoIt3Wrapper_Run_After="%scitedir%\AutoIt3Wrapper\ResHacker.exe" -script "C:\Progra~1\AutoIt3\Examples\reshack.txt"

Zedna, I noticed when first trying Larry's UDF that it used a variation on _SendMessage() (and same name) in Misc.au3 include

which your example above has, they being essentially the same if you remove this "hwnd" from the DeleteObject line.

otherwise if you use Misc.au3 in your script you will get a conflict with having two same named functions

or wrong number of arguments message if you don't use the modified function

from
DeleteObject(_SendMessage($hwnd,$STM_SETIMAGE,$IMAGE_BITMAP,$hBitmap,0,"int","int","hwnd"))

to
DeleteObject(_SendMessage($hwnd,$STM_SETIMAGE,$IMAGE_BITMAP,$hBitmap,0,"int","int"))
You are right.

I know about that _SendMessage variation from Larry. He made it due to differrent output type (hwnd instead of long.

I tried it also with standard output type (long) from Misc.au3 and it works fine.

So in final UDF version will be used _SendMessage from Misc.au3.

also, I guess/assume that ResSize has to do with resizing image?

ResSize is output parameter for get resource size. This ResSize is used later for DllSctructCreate().

I said that this will be changed - resource size will be returned in @extended macro.

one thing about compiling bitmaps as resources is you can't resize the image, you have to

adjust your image size to what you want before compiling into exe.

Thanks for your above bitmap example and the work your doing on this UDF,

not much comment here yet, but obvious interest in other threads on this in the forum, especially Larry's UDF

OK.

Edit:

upx compression works if run manually after compiling exe

i noticed in my case that when using icon add and compiling in bitmaps for my toolbar

that upx compressing after exe compiled would break the link to the internal icon resources but not the default program icon

or bitmaps (blank toolbar)

Read my above post. I discovered this too. It's probably error in Autoit3Wrapper:

I discovered that problem is in second #compiler_run_after= which will not wait for the first #compiler_run_after= to be finished - with my big testing bitmap)

As I said: I will make some changes and cleanup later. Stay tuned... Edited by Zedna
Posted (edited)

Good news folks!! :)

Here is new version of my resource UDF and new simple/clean example for using:

resource_test.au3 - example for TXT and BMP data in resources

#compiler_useupx=n
#compiler_run_after=ResHacker.exe -add %out%, %out%, test_1.txt, 10, TEST_TXT_1, 0
#compiler_run_after=ResHacker.exe -add %out%, %out%, image1.bmp, 2, TEST_BMP_1, 0
#compiler_run_after="c:\program files\Autoit3\Aut2Exe\upx.exe" --compress-resources=0 "%out%"

#include "resources.au3"
 
$gui = GUICreate("Data from resources test",900,700)
$pic = GUICtrlCreatePic("",0,0,800,600)
$label = GUICtrlCreateLabel("",20,620,800,100)
GUISetState(@SW_SHOW)

; string from resource
$string = _ResourceGetAsString("TEST_TXT_1", $RT_RCDATA)
GUICtrlSetData($label, $string)

; bitmap from resource
$hBmp = _ResourceGet("TEST_BMP_1", $RT_BITMAP)
_SetBitmapToCtrl($gui, $pic, $hBmp)

While 1
    If GUIGetMsg() = -3 Then Exit
WEnd

Func _SetBitmapToCtrl($hWnd, $CtrlId, $hBitmap)
    Local Const $STM_SETIMAGE = 0x0172
    Local Const $IMAGE_BITMAP = 0

    $hWnd = ControlGetHandle($hWnd, "", $CtrlId)
   
    DllCall("user32.dll", "hwnd", "SendMessage", "hwnd", $hWnd, "int", $STM_SETIMAGE, "int", $IMAGE_BITMAP, "int", $hBitmap)
    DllCall('gdi32.dll', 'int', 'DeleteObject', 'hwnd', $hBitmap)
EndFuncoÝ÷ ÙºÞ²«që»uöÚºÚ"µÍÚ[ÛYK[ÛÙQÛØ[ÛÛÝ  ÌÍÔÐÕTÓÔHBÛØ[ÛÛÝ    ÌÍÔÐUPTHÛØ[ÛÛÝ ÌÍÔÒPÓÓHÂÛØ[ÛÛÝ ÌÍÔÓQSHH
ÛØ[ÛÛÝ ÌÍÔÑPSÑÈH
BÛØ[ÛÛÝ    ÌÍÔÔÕSÈH
ÛØ[ÛÛÝ ÌÍÔÑÓTH
ÂÛØ[ÛÛÝ   ÌÍÔÑÓHÛØ[ÛÛÝ  ÌÍÔÐPÐÑSTUÔÈHBÛØ[ÛÛÝ   ÌÍÔÔÑUHHLÛØ[ÛÛÝ   ÌÍÔÓQTÔÐQÑUPHHLBÛØ[ÛÛÝ  ÌÍÔÑÔÕTÐÕTÓÔHLÛØ[ÛÛÝ ÌÍÔÑÔÕTÒPÓÓHMÛØ[ÛÛÝ   ÌÍÔÕTÒSÓHMÛØ[ÛÛÝ ÌÍÔÐSPÕTÓÔHBÛØ[ÛÛÝ  ÌÍÔÐSRPÓÓHÛØ[ÛÛÝ ÌÍÔÒSHÂÛØ[ÛÛÝ ÌÍÔÓPSQTÕH[ÈÔÛÝÙQÙ]
    ÌÍÔÓ[YK ÌÍÔÕK   ÌÍÔÓ[ÈH
BØØ[ÛÛÝ    ÌÍÒSPQÑWÐUPTHØØ[ ÌÍÚ[Ý[ÙK   ÌÍÚ]X    ÌÍÒ[ÐØÚË ÌÍÑÛØ[Y[[ÜPØÚË ÌÍÓY[[ÜTÚ[ ÌÍÔÔÚ^B    ÌÍÚ[Ý[ÙHHØ[
    ][ÝÚÙ[Ì ][ÝË  ][ÝÚ[ ][ÝË  ][ÝÑÙ][Ù[R[PI][ÝË ][ÝÚ[ ][ÝË
B   ÌÍÚ[Ý[ÙHH  ÌÍÚ[Ý[ÙVÌHY   ÌÍÔÕHH  ÌÍÔÐUPT[    ÌÍÚ]XHØ[
    ][ÝÝÙÌ  ][ÝË  ][ÝÚÛ    ][ÝË  ][ÝÓØY[XYÙI][ÝË   ][ÝÚÛ    ][ÝË  ÌÍÚ[Ý[ÙK   ][ÝÜÝ][ÝË  ÌÍÔÓ[YKÂ   ][ÝÚ[ ][ÝË  ÌÍÒSPQÑWÐUPT   ][ÝÚ[ ][ÝË  ][ÝÚ[ ][ÝË  ][ÝÚ[ ][ÝË
B   ÌÍÚ]XH   ÌÍÚ]XÌB]    ÌÍÚ]XÈ]È[HÈ]X[YY  ÌÍÔÓ[È ÉÝÈ[ ÌÍÒ[ÐØÚÈHØ[
    ][ÝÚÙ[Ì ][ÝË  ][ÝÚ[ ][ÝË  ][ÝÑ[ÛÝÙQ^I][ÝË  ][ÝÚ[ ][ÝË  ÌÍÚ[Ý[ÙK   ][ÝÜÝ][ÝË  ÌÍÔÓ[YK ][ÝÛÛÉ][ÝË    ÌÍÔÕK   ][ÝÜÚÜ  ][ÝË  ÌÍÔÓ[ÊB[ÙB    ÌÍÒ[ÐØÚÈHØ[
    ][ÝÚÙ[Ì ][ÝË  ][ÝÚ[ ][ÝË  ][ÝÑ[ÛÝÙPI][ÝË   ][ÝÚ[ ][ÝË  ÌÍÚ[Ý[ÙK   ][ÝÜÝ][ÝË  ÌÍÔÓ[YK ][ÝÛÛÉ][ÝË    ÌÍÔÕJB[YYÜ[]Ù]ÜK
B   ÌÍÒ[ÐØÚÈH    ÌÍÒ[ÐØÚÖÌBY ÌÍÒ[ÐØÚÈH[]Ù]ÜK
B   ÌÍÔÔÚ^HHØ[
    ][ÝÚÙ[Ì ][ÝË  ][ÝÙÛÜ  ][ÝË  ][ÝÔÚ^[ÙÛÝÙI][ÝË   ][ÝÚ[ ][ÝË  ÌÍÚ[Ý[ÙK   ][ÝÚ[ ][ÝË  ÌÍÒ[ÐØÚÊBYÜ[]Ù]ÜK
B   ÌÍÔÔÚ^HH   ÌÍÔÔÚ^VÌBY    ÌÍÔÔÚ^HH[]Ù]ÜK
B   ÌÍÑÛØ[Y[[ÜPØÚÈHØ[
    ][ÝÚÙ[Ì ][ÝË  ][ÝÚ[ ][ÝË  ][ÝÓØYÛÝÙI][ÝË  ][ÝÚ[ ][ÝË  ÌÍÚ[Ý[ÙK   ][ÝÚ[ ][ÝË  ÌÍÒ[ÐØÚÊBYÜ[]Ù]ÜK
B   ÌÍÑÛØ[Y[[ÜPØÚÈH    ÌÍÑÛØ[Y[[ÜPØÚÖÌBY ÌÍÑÛØ[Y[[ÜPØÚÈH[]Ù]ÜK
B   ÌÍÓY[[ÜTÚ[HØ[
    ][ÝÚÙ[Ì ][ÝË  ][ÝÚ[ ][ÝË  ][ÝÓØÚÔÛÝÙI][ÝË   ][ÝÚ[ ][ÝË  ÌÍÑÛØ[Y[[ÜPØÚÊBYÜ[]Ù]ÜK
B   ÌÍÓY[[ÜTÚ[H    ÌÍÓY[[ÜTÚ[ÌBY ÌÍÓY[[ÜTÚ[H[]Ù]ÜK
BÙ]^[Y
    ÌÍÔÔÚ^JB]  ÌÍÓY[[ÜTÚ[[[Ñ[ÈÔÛÝÙQÙ]ÔÝ[Ê   ÌÍÔÓ[YK ÌÍÔÕK   ÌÍÔÓ[ÈH
BØØ[  ÌÍÔÔÚ[ ÌÍÔÔÚ^H    ÌÍÔÔÚ[HÔÛÝÙQÙ]
    ÌÍÔÓ[YK ÌÍÔÕK   ÌÍÔÓ[ÊBYÜ[Ù]ÜK
B]  ÌÎNÉÌÎNÂ[Y    ÌÍÔÔÚ^HH^[Y    ÌÍÜÝXÝHÝXÝÜX]J  ][ÝØÚÉ][ÝÈ    [È ÌÍÔÔÚ^H    [È ][Ý×I][ÝË   ÌÍÔÔÚ[B]ÝXÝÙ]]J ÌÍÜÝXÝJHÈ]ÈÝ[Â[[Ñ[ÈÔÛÝÙQÙ]Ð]Ê ÌÍÔÓ[YK ÌÍÔÕK   ÌÍÔÓ[ÈH
BØØ[  ÌÍÔÔÚ[ ÌÍÔÔÚ^H    ÌÍÔÔÚ[HÔÛÝÙQÙ]
    ÌÍÔÓ[YK ÌÍÔÕK   ÌÍÔÓ[ÊBYÜ[]Ù]ÜK
B   ÌÍÔÔÚ^HH^[Y]ÝXÝÜX]J ][ÝØ]VÉ][ÝÈ    [È ÌÍÔÔÚ^H    [È ][Ý×I][ÝË   ÌÍÔÔÚ[HÈ]ÈÚ[È]Â[[

Notes:

- ResHacker.exe must be in script directory at compile time

- Image1.bmp, Test_1.txt must be in script directory at compile time

- ;#compiler_run_after=upx.exe --compress-resources=0 %out% can't be used directly due to Autoit3Wrapper bug (see above posts)

so for now you can run command upx.exe --compress-resources=0 resource_test.exe after compilation

EDIT: solved: sorry JdeB for my mistake

- _ResourceGet() always returns pointer, returning other types can be done by additional wrapper functions like _ResourceGetAsString() or _ResourceGetAsBytes() - see resource.au3 UDF

- LoadImage can be used also for icons and cursors. For icons it's not neccessary because icons (from resources) are supported by GUICtrlSetImage already

- _ResourceGet() returns resource size (in bytes) in @extended macro but not for resource type RT_BITMAP

- _SetBitmapToCtrl() is changed Larry's SetBitmapResourceToPicCtrl() which is used in my example as separate function not included in my resource UDF because it's not resource related function

Post your comments to this stuff ...

EDIT: UPX directive solved: sorry JdeB for my mistake

Edited by Zedna
  • Developers
Posted

Notes:

- ResHacker.exe must be in script directory at compile time

- Image1.bmp, Test_1.txt must be in script directory at compile time

- ;#compiler_run_after=upx.exe --compress-resources=0 %out% can't be used directly due to Autoit3Wrapper bug (see above posts)

so for now you can run command upx.exe --compress-resources=0 resource_test.exe after compilation

- _ResourceGet() always returns pointer, returning other types can be done by additional wrapper functions like _ResourceGetAsString() or _ResourceGetAsBytes() - see resource.au3 UDF

- LoadImage can be used also for icons and cursors. For icons it's not neccessary because icons (from resources) are supported by GUICtrlSetImage already

- _ResourceGet() returns resource size (in bytes) in @extended macro but not for resource type RT_BITMAP

- _SetBitmapToCtrl() is changed Larry's SetBitmapResourceToPicCtrl() which is used in my example as separate function not included in my resource UDF because it's not resource related function

Post your comments to this stuff ...

Give this a try for RUN_After:

#AutoIt3Wrapper_run_after=""c:\program files\Autoit3\Aut2Exe\upx.exe" --compress-resources=0 "%out%""

:)

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

  • Developers
Posted

Sorry JdeB for my mistake and thanks for working solution.

No problem .... its all a bit goofy depending on the OS used....

Its something you need to know how to code it ...

:)

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

Posted (edited)

Bad news.

Edit post with autoit code tags on this forum is absolutely amazing!!

Therefore I will post my au3 code here as attachments:

Fantastic Zedna. I've tested with a 5Mb bitmap and it works just as the manufacturer said it would! :)

And amazingly, if I compress it with upx it reduces the size from 5.61Mb to 4.88Mb and it still works.

If I compile it a second time then it produces a file which is 4.9Mb which runs ok, and if I use upx again it reduces to 4.3Mb and still runs. :P

If I delete the reshacker.ini and the reshacker.log files then if I compile again it is back to 5.61Mb :)

So I don't understand (among other things) the line

#compiler_run_after="c:\program files\Autoit3\Aut2Exe\upx.exe" --compress-resources=0 "%out%"

Edited by martin
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.
Posted

Fantastic Zedna. I've tested with a 5Mb bitmap and it works just as the manufacturer said it would! :)

And amazingly, if I compress it with upx it reduces the size from 5.61Mb to 4.88Mb and it still works.

If I compile it a second time then it produces a file which is 4.9Mb which runs ok, and if I use upx again it reduces to 4.3Mb and still runs. :P

If I delete the reshacker.ini and the reshacker.log files then if I compile again it is back to 5.61Mb :)

So I don't understand (among other things) the line

#compiler_run_after="c:\program files\Autoit3\Aut2Exe\upx.exe" --compress-resources=0 "%out%"

Good to hear that it's working fine :)

If you want the best compression you can add another parametres to upx.exe, for example:

#compiler_run_after="c:\program files\Autoit3\Aut2Exe\upx.exe" -9 --compress-resources=0 "%out%"

or

#compiler_run_after="c:\program files\Autoit3\Aut2Exe\upx.exe" --best --compress-resources=0 "%out%"

Note:

--compress-resources=0 means: Don't compress any resources at all.

So bitmap stored as resource must stay uncompressed by UPX to be usable by resource API functions.

Maybe sometimes in the future somebody will observe how to use also GIF,JPG,PNG directly from resources through some API functions (maybe GDI+) ...

Posted

Good to hear that it's working fine :)

If you want the best compression you can add another parametres to upx.exe, for example:

#compiler_run_after="c:\program files\Autoit3\Aut2Exe\upx.exe" -9 --compress-resources=0 "%out%"

or

#compiler_run_after="c:\program files\Autoit3\Aut2Exe\upx.exe" --best --compress-resources=0 "%out%"

Note:

--compress-resources=0 means: Don't compress any resources at all.

So bitmap stored as resource must stay uncompressed by UPX to be usable by resource API functions.

Maybe sometimes in the future somebody will observe how to use also GIF,JPG,PNG directly from resources through some API functions (maybe GDI+) ...

The point is that the -resources=0 doesn't seem to make any significant difference, which is to say if I remove it the exe still works. If I omit the whole line and manually compress the exe with upx the exe is smaller and still works.

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

The point is that the -resources=0 doesn't seem to make any significant difference, which is to say if I remove it the exe still works. If I omit the whole line and manually compress the exe with upx the exe is smaller and still works.

Really - you are right!

I'm surprised by this behaviour.

In my little test was best result with this UPX directive:

#compiler_run_after="c:\program files\Autoit3\Aut2Exe\upx.exe" --best "%out%"

With this directive it works with smallest size but ResHacker couldn't show included resources (it recognize them but not show it's content) and say: "File has non-standard resource layout. It's probably been compressed with an EXE compressor"

But sometimes it makes corrupted EXE (non worling without resources at all).

I tried recompile it several times and only sometimes it makes a crap.

Posted

I did search for some GDI plus reference about loading images (BMP,GIF,JPG,PNG,TIFF,WMF,...) and found only this MSDN link

about Image Functions. There are functions GdipLoadImageFromFile() and GdipLoadImageFromStream() but there is no detailed description.

Can somebody tell me where is detailed reference of these GDI plus functions.

Note:

GdipLoadImageFromFile() is in Auto3Lib

GdipLoadImageFromStream() is not in Auto3Lib and maybe could be used to load compressed images (GIF,JPG,PNG) from resources

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