Jump to content



Photo

Resources UDF


585 replies to this topic

#541 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,322 posts

Posted 30 March 2012 - 11:15 AM

... Let me know how it goes and I'll get the changes to Jos.

Thanks!!
Now I tested this new AutoIt3Wrapper and it works fine with standard cursors (.cur) and also with animated cursors (.ani)
It works fine also with cursors (also animated) from my Windows7.

Here is testing script:
AutoIt         
; cursors from Win7 #AutoIt3Wrapper_Res_File_Add=aero_link.cur, rt_cursor, CUR_1 #AutoIt3Wrapper_Res_File_Add=aero_busy.ani, rt_anicursor, ANI_CUR_1 ; cursors from Win XP #AutoIt3Wrapper_Res_File_Add=3dsmove.cur, 1, CUR_2 #AutoIt3Wrapper_Res_File_Add=banana.ani, rt_anicursor, ANI_CUR_2 #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_UseX64=n #include <GuiConstants.au3> #include <WinAPI.au3> $gui = GUICreate("Cursor from resources example",820,400) $label1 = GUICtrlCreateLabel("abc def",20,320,380,100) ; controls in GUI with standard cursor GUISetState(@SW_SHOW) GUIRegisterMsg($WM_SETCURSOR, 'WM_SETCURSOR') $hInstance = _WinAPI_GetModuleHandle("") $hCursor = _WinAPI_LoadCursor($hInstance, 'CUR_2') _WinAPI_SetCursor($hCursor) Sleep(5000) $hCursor = _WinAPI_LoadCursor($hInstance, 'ANI_CUR_2') _WinAPI_SetCursor($hCursor) While 1     If GUIGetMsg() = -3 Then Exit WEnd Func WM_SETCURSOR($hWnd, $iMsg, $iWParam, $iLParam)     If $hWnd = $gui Then         _WinAPI_SetCursor($hCursor)         Return 0     EndIf     Return $GUI_RUNDEFMSG EndFunc Func _WinAPI_LoadCursor($hInstance, $sCursor)     Local $aResult, $sType = "int"     If IsString($sCursor) Then $sType = "str"     $aResult = DllCall("User32.dll", "hwnd", "LoadCursor", "hwnd", $hInstance, $sType, $sCursor)     _WinAPI_Check("_WinAPI_LoadCursor", ($aResult[0] = 0), 0, True)     Return $aResult[0] EndFunc   ;==>_WinAPI_LoadCursor

Attached Files


Edited by Zedna, 30 March 2012 - 11:16 AM.








#542 wraithdu

wraithdu

    I am less fun than a twisted ankle.

  • MVPs
  • 2,137 posts

Posted 30 March 2012 - 01:25 PM

Heh, that's awesome :oops: I had no idea you could load an animated cursor from a resource. All the research I did last night made it seem like you had to save it out to a file first. I'm curious if you found somewhere that was documented, or if you just tried it out.

#543 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,322 posts

Posted 30 March 2012 - 01:47 PM

Heh, that's awesome :oops: I had no idea you could load an animated cursor from a resource. All the research I did last night made it seem like you had to save it out to a file first. I'm curious if you found somewhere that was documented, or if you just tried it out.


I just tried what I had in my first test script from yesterday and it worked perfectly despite what you said/expected :-)
Great.
Later I will add this example for cursors from resources also to my first post in this topic and to next version of my Resources UDF (despite it don't need my Resources UDF)
EDIT: I hope I will release new version soon ...

Edited by Zedna, 30 March 2012 - 01:50 PM.


#544 Morgyone

Morgyone

    Seeker

  • New Members
  • 2 posts

Posted 30 March 2012 - 02:03 PM

Thanks a lot guys, you're really awesome :oops:
you saved me from using SaveToFile - not that it would be all that bad, but this is better for me =)

Edited by Morgyone, 30 March 2012 - 02:04 PM.


#545 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,322 posts

Posted 02 April 2012 - 02:09 PM

Now I tested this new AutoIt3Wrapper and it works fine with standard cursors (.cur) and also with animated cursors (.ani)
It works fine also with cursors (also animated) from my Windows7.

Here is testing script:


Just one note: Cursors are loaded/showed correctly also when UPX is used (now sucessfully tested).
So you can comment/remove this line:
#AutoIt3Wrapper_UseUpx=n
to get smaller compiled EXE without any loss of functionality :-)

Edited by Zedna, 02 April 2012 - 02:10 PM.


#546 Emiel Wieldraaijer

Emiel Wieldraaijer

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 651 posts

Posted 04 April 2012 - 08:52 PM

Why not use the Keep Resource option of UPX ?

#AutoIt3Wrapper_Run_After=upx.exe --brute --force --compress-icons=0 --keep-resource=ANI "%out%"
Best regards,Emiel WieldraaijerPosted Image

#547 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,322 posts

Posted 04 April 2012 - 10:32 PM

Why not use the Keep Resource option of UPX ?

#AutoIt3Wrapper_Run_After=upx.exe --brute --force --compress-icons=0 --keep-resource=ANI "%out%"


Because it's not needed. CUR and ANI resources work fine even when they are compressed by UPX.
In that case you can't see them directly by reshacker.exe but at runtime it works fine.

Edited by Zedna, 04 April 2012 - 10:33 PM.


#548 WhiteStar

WhiteStar

    Wayfarer

  • Active Members
  • Pip
  • 50 posts

Posted 09 April 2012 - 01:38 PM

Zedna,

Will this be incorporated into the next release of AutoIT ? The current Beta is moving right along and seems fairly close to becoming a release and I was just wondering.

Thanks
WhiteStar
~ WhiteStar Magic

#549 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,322 posts

Posted 10 April 2012 - 11:40 PM

Zedna,

Will this be incorporated into the next release of AutoIT ? The current Beta is moving right along and seems fairly close to becoming a release and I was just wondering.

Thanks
WhiteStar


No. I have no current plans about adding it into standard includes
because I'm not satisfied with it (there are some ineficiencies/hacks) and there are many things where I'm not sure about solving problems etc. and I haven't got so many time/will to finish all to the best state.

At current state this UDF is usable (at least for me) with some limitations and I want to release new version with some proposed fixes/changes posted here in this topic - hopefully soon but no ETA.

#550 robinsiebler

robinsiebler

    Adventurer

  • Active Members
  • PipPip
  • 102 posts

Posted 14 June 2012 - 02:19 AM

What am I doing wrong? The pictures do not show up


Edited by robinsiebler, 14 June 2012 - 02:19 AM.


#551 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,322 posts

Posted 14 June 2012 - 07:18 AM

What am I doing wrong? The pictures do not show up


Try this:
- use image file names without space (with underscore)
- copy images to script directory and in ResFileAdd use just filename without path
- copy resources.au3 into script directory (to exclude problems with bad user defined path)
- do you compile your script with FULL Scite4AutoIt3?
- check by reshacker if images are in compiled output EXE
- your AU3 scipt looks OK

#552 robinsiebler

robinsiebler

    Adventurer

  • Active Members
  • PipPip
  • 102 posts

Posted 14 June 2012 - 05:38 PM

Ok, II figured out the problem: I have a 2nd form and I placed the #AutoIt3Wrapper_Res_File_Add statement there, but they had to go into the 1st form. Now for the 2nd problem. The images are showing up but they are way larger than the sizes I specified for the controls.


I manually resized the images, but I would like to know if there is an alternate solution.

Edited by robinsiebler, 14 June 2012 - 06:08 PM.


#553 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,322 posts

Posted 14 June 2012 - 07:03 PM

The images are showing up but they are way larger than the sizes I specified for the controls.

I manually resized the images, but I would like to know if there is an alternate solution.


Search this forum and also this topic. This was asked/answered many times.
As far as I can remember the simple solution should be to use static control's style SS_REALSIZECONTROL (for your picture control) - but I'm not sure because I haven't needed/used this yet.
http://msdn.microsoft.com/en-us/library/windows/desktop/bb760773%28v=vs.85%29.aspx

#554 robinsiebler

robinsiebler

    Adventurer

  • Active Members
  • PipPip
  • 102 posts

Posted 14 June 2012 - 07:33 PM

I did a search, but didn't really get any hits. I'm not exactly sure what to search for.

Edited by robinsiebler, 14 June 2012 - 09:17 PM.


#555 JBond

JBond

    Seeker

  • Active Members
  • 12 posts

Posted 22 June 2012 - 04:40 PM

Hey Zedna!

Resources UDF is awesome. Thank you very much for that ;)

I've a problem including a .jpg to my script for a GUI.
I want to add the file from an SMB-Share like this:


but it's not working?

Adding the same file by

works fine.

Comparing the size of the compiled .exe - it's definitively not included in the exe.

#556 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,322 posts

Posted 22 June 2012 - 09:30 PM

I want to add the file from an SMB-Share like this:


but it's not working?

This has nothing to do with my Resources UDF.
Just add resources normal way from local directory and don't do such unusefull complications.
I can't imagine why you need such nonstandard functionality.

You may look at sources of AutoIt3Wrapper and look how it's implemented #AutoIt3Wrapper_Res_File_Add there and
of course you may make any modifications for your special needs.

AutoIt3Wrapper is part of Scite4AutoIt3:
http://www.autoitscript.com/site/autoit-script-editor/downloads/

EDIT:
Maybe you can use #AutoIt3Wrapper_Run_Before= to copy your icons from net to local before compilation
but I'm not sure if it would work

Edited by Zedna, 23 June 2012 - 10:15 PM.


#557 Pino

Pino

    Seeker

  • Active Members
  • 10 posts

Posted 27 June 2012 - 09:46 AM

Hi to all
and many thanks to Zedna for the UDF resources.

... but I have trouble with your new UDF resources.

Here my problem:

------------------------------------------------------------------------
32Bit program with the new version of UDF resources:

If I use the new version of UDF resources and
I compile a 32Bit program with the parameter
#AutoIt3Wrapper_UseX64=N


only some of the pictures are visible
when I start the program on a Windows 7 32Bit system


only some of the pictures are visible
when I start the program on a Windows 7 64Bit system


The problem with the invisible pictures is on all types of grafics.


------------------------------------------------------------------------
64Bit program with the new version of UDF resources:


If I use the new version of UDF resources and
I compile a 64Bit program with the parameter
#AutoIt3Wrapper_UseX64=Y


all pictures are visible, everthing is ok
when I start the program on a Windows 7 64Bit system


#include-once #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <resources.au3> #region #AutoIt3Wrapper_UseX64=N ; the grafic is a 32x32 pixel BMP-File #AutoIt3Wrapper_Res_File_Add=rot.bmp, rt_bitmap, rot #endregion $Form1 = GUICreate("", 800, 600, 0, 0, BitOR($WS_POPUP, $WS_BORDER)) GUISetState(@SW_SHOW) $j = 1 For $j = 1 to 16   For $i = 1 to 22     GUICtrlCreatePic("", (32*$i)-32+($i*3), (32*$j)-32+($j*3), 32, 32)     _ResourceSetImageToCtrl(-1, "rot", $RT_BITMAP) ; set BMP image to picture control from resource   Next Next MsgBox(0,"","Wait for close")


I'm using AutoIT version 3.3.0.0.

I would be very glad if you could check my example.
If you could find a solution for me I would be very grateful.

Many thanks
Pino

#558 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,322 posts

Posted 27 June 2012 - 12:09 PM

I tested your example with my bitmap and I could see similar behaviour on my Win7 64bit OS only with old AutoIt 3.2.12.1 (the same for#AutoIt3Wrapper_UseX64=Y/N).
With AutoIt beta 3.3.7.23 which I use as "latest" there is no problem no matter of #AutoIt3Wrapper_UseX64 directive.
Try to use newer (latest) version of AutoIt and Scite4AutoIt3 (and AutoIt3Wrapper which is part of it).

Edited by Zedna, 27 June 2012 - 12:10 PM.


#559 Pino

Pino

    Seeker

  • Active Members
  • 10 posts

Posted 27 June 2012 - 12:36 PM

Hi Zedna,

thanks for help.

It's running well with current version 3.3.8.1.
Pino

#560 kor

kor

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 487 posts

Posted 16 July 2012 - 03:56 AM

So am I doing something wrong?
I downloaded resources, added the include to the right place and tried to run any of the examples and none of the pictures load in the gui's.

I'm running Win 7 enterprise x32 with AutoitIt 3.3.8.1




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users