Jump to content

Transparent GIFs not working properly within AutoIt


BoonPek
 Share

Recommended Posts

Hi there.

I've been fiddling with this for hours straight, playing around with settings and such on Photoshop and GIMP but to no avail. PNGs wont work, I've tried. Also, my attempts into converting this PNG smoothly into a GIF have proven fruitless; can anyone help me with this? Included are the program files: the test.au3 is the script, and everything else are the images.

logo.png is the image file I actually want to place over the GIF, but since AutoIt does not support PNGs...

EDIT:

When we insert a button via "GuiCtrlCreateButton", is it possible to make it so that the background of the button remains invisible? Currently, the button's background is of the same colour as the "GUISetBkColor()" :/

Posted Image

test.zip

Thank you for your help!

Edited by BoonPek
Link to comment
Share on other sites

Try this:

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>

GUICreate("Minecraft Launcher", 856, 99, -1, -1)
_GUICreateBanner()
GUISetState()


GUICtrlCreateButton("Sign up", 555, 34, 70, 22)

Do
    Sleep(10)
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _GUICreateBanner()
    _GDIPlus_Startup()
    Local Const $STM_SETIMAGE = 0x0172
    GUICtrlCreatePic("cloudsandsky.jpg", -480, 0, 1920, 87)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlSetResizing(-1, 840)

    $hImage_Logo = _GDIPlus_ImageLoadFromFile("logo.gif")
    $hBmp_Logo = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage_Logo)
    $idPic_Logo = GUICtrlCreatePic("", 50, 18, 188, 47)
    _WinAPI_DeleteObject(GUICtrlSendMsg($idPic_Logo, $STM_SETIMAGE, 0, $hBmp_Logo))
    _WinAPI_DeleteObject($hBmp_Logo)
     _GDIPlus_ImageDispose($hImage_Logo)
    GUICtrlSetResizing(-1, 834)
    GUICtrlSetState(-1, $GUI_DISABLE)
    _GDIPlus_Shutdown()
    $bM = 0
    Do
        GUICtrlCreatePic("grass.gif", $bM, 75, 128, 25)
        GUICtrlSetBkColor(-1 , -2)
        GUICtrlSetState(-1, $GUI_DISABLE)
        GUICtrlSetResizing(-1, 834)
        $bM += 128
    Until $bM > 856
EndFunc

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Try this:

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>

GUICreate("Minecraft Launcher", 856, 99, -1, -1)
_GUICreateBanner()
GUISetState()


GUICtrlCreateButton("Sign up", 555, 34, 70, 22)

Do
    Sleep(10)
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _GUICreateBanner()
    _GDIPlus_Startup()
    Local Const $STM_SETIMAGE = 0x0172
    GUICtrlCreatePic("cloudsandsky.jpg", -480, 0, 1920, 87)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlSetResizing(-1, 840)

    $hImage_Logo = _GDIPlus_ImageLoadFromFile("logo.gif")
    $hBmp_Logo = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage_Logo)
    $idPic_Logo = GUICtrlCreatePic("", 50, 18, 188, 47)
    _WinAPI_DeleteObject(GUICtrlSendMsg($idPic_Logo, $STM_SETIMAGE, 0, $hBmp_Logo))
    _WinAPI_DeleteObject($hBmp_Logo)
     _GDIPlus_ImageDispose($hImage_Logo)
    GUICtrlSetResizing(-1, 834)
    GUICtrlSetState(-1, $GUI_DISABLE)
    _GDIPlus_Shutdown()
    $bM = 0
    Do
        GUICtrlCreatePic("grass.gif", $bM, 75, 128, 25)
        GUICtrlSetBkColor(-1 , -2)
        GUICtrlSetState(-1, $GUI_DISABLE)
        GUICtrlSetResizing(-1, 834)
        $bM += 128
    Until $bM > 856
EndFunc

Br,

UEZ

Works fine, thank you! Also, any comments on the button background issue? :mellow:
Link to comment
Share on other sites

Works fine, thank you! Also, any comments on the button background issue? :mellow:

This is not the best solution but is a temporal fix until i get how to do it for real.

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <winapiex.au3>



$hGUI = GUICreate("Minecraft Launcher", 856, 99, -1, -1)

_GUICreateBanner()
GUISetState()
GuiCreate("",68,20,556,35,$WS_POPUP,$WS_EX_MDICHILD,$hGUI)
GUISetState()
$iButton = GUICtrlCreateButton("Sign up", -1, -1, 70, 22)
GuiSwitch($hGUI) ; You can continue adding controls to the main GUI



Do
    Sleep(10)
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Func _GUICreateBanner()
    _GDIPlus_Startup()
    Local Const $STM_SETIMAGE = 0x0172
    GUICtrlCreatePic("cloudsandsky.jpg", -480, 0, 1920, 87)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlSetResizing(-1, 840)

    $hImage_Logo = _GDIPlus_ImageLoadFromFile("logo.gif")
    $hBmp_Logo = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage_Logo)
    $idPic_Logo = GUICtrlCreatePic("", 50, 18, 188, 47)
    _WinAPI_DeleteObject(GUICtrlSendMsg($idPic_Logo, $STM_SETIMAGE, 0, $hBmp_Logo))
    _WinAPI_DeleteObject($hBmp_Logo)
    _GDIPlus_ImageDispose($hImage_Logo)
    GUICtrlSetResizing(-1, 834)
    GUICtrlSetState(-1, $GUI_DISABLE)
    _GDIPlus_Shutdown()
    $bM = 0
    Do
        GUICtrlCreatePic("grass.gif", $bM, 75, 128, 25)
        GUICtrlSetBkColor(-1, -2)
        GUICtrlSetState(-1, $GUI_DISABLE)
        GUICtrlSetResizing(-1, 834)
        $bM += 128
    Until $bM > 856
EndFunc   ;==>_GUICreateBanner
Link to comment
Share on other sites

You mean something like this?

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <StaticConstants.au3>

GUICreate("Minecraft Launcher", 856, 99, -1, -1)

_GUICreateBanner()

GUICtrlCreateGroup("", 555, 28, 70, 28)
$btn = GUICtrlCreateLabel("Sign up", 555, 34, 70, 22, $SS_CENTER + $SS_CENTERIMAGE)
GUICtrlSetBkColor(-1, -2)
GUICtrlCreateGroup("", -99, -99, 1, 1)  ;close group
GUISetState()

Do
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btn
            MsgBox(0, "Information", "Button Sign up pressed")
    EndSwitch
Until False

Func _GUICreateBanner()
    _GDIPlus_Startup()
    Local Const $STM_SETIMAGE = 0x0172
    GUICtrlCreatePic("cloudsandsky.jpg", -480, 0, 1920, 87)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlSetResizing(-1, 840)

    $hImage_Logo = _GDIPlus_ImageLoadFromFile("logo.gif")
    $hBmp_Logo = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage_Logo)
    $idPic_Logo = GUICtrlCreatePic("", 50, 18, 188, 47)
    GUICtrlSetResizing(-1, 834)
    GUICtrlSetState(-1, $GUI_DISABLE)
    _WinAPI_DeleteObject(GUICtrlSendMsg($idPic_Logo, $STM_SETIMAGE, 0, $hBmp_Logo))
    _WinAPI_DeleteObject($hBmp_Logo)
     _GDIPlus_ImageDispose($hImage_Logo)
    _GDIPlus_Shutdown()

    $bM = 0
    Do
        GUICtrlCreatePic("grass.gif", $bM, 75, 128, 25)
        GUICtrlSetBkColor(-1 , -2)
        GUICtrlSetState(-1, $GUI_DISABLE)
        GUICtrlSetResizing(-1, 834)
        $bM += 128
    Until $bM > 856
EndFunc

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

This is not the best solution but is a temporal fix until i get how to do it for real.

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <winapiex.au3>



$hGUI = GUICreate("Minecraft Launcher", 856, 99, -1, -1)

_GUICreateBanner()
GUISetState()
GuiCreate("",68,20,556,35,$WS_POPUP,$WS_EX_MDICHILD,$hGUI)
GUISetState()
$iButton = GUICtrlCreateButton("Sign up", -1, -1, 70, 22)
GuiSwitch($hGUI) ; You can continue adding controls to the main GUI



Do
    Sleep(10)
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Func _GUICreateBanner()
    _GDIPlus_Startup()
    Local Const $STM_SETIMAGE = 0x0172
    GUICtrlCreatePic("cloudsandsky.jpg", -480, 0, 1920, 87)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlSetResizing(-1, 840)

    $hImage_Logo = _GDIPlus_ImageLoadFromFile("logo.gif")
    $hBmp_Logo = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage_Logo)
    $idPic_Logo = GUICtrlCreatePic("", 50, 18, 188, 47)
    _WinAPI_DeleteObject(GUICtrlSendMsg($idPic_Logo, $STM_SETIMAGE, 0, $hBmp_Logo))
    _WinAPI_DeleteObject($hBmp_Logo)
    _GDIPlus_ImageDispose($hImage_Logo)
    GUICtrlSetResizing(-1, 834)
    GUICtrlSetState(-1, $GUI_DISABLE)
    _GDIPlus_Shutdown()
    $bM = 0
    Do
        GUICtrlCreatePic("grass.gif", $bM, 75, 128, 25)
        GUICtrlSetBkColor(-1, -2)
        GUICtrlSetState(-1, $GUI_DISABLE)
        GUICtrlSetResizing(-1, 834)
        $bM += 128
    Until $bM > 856
EndFunc   ;==>_GUICreateBanner

This doesn't really seem to work for me. It still gives out the same problem. What I'm trying to fix is that TINY border that gets created around the button, outside the button :)

You mean something like this?

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <StaticConstants.au3>

GUICreate("Minecraft Launcher", 856, 99, -1, -1)

_GUICreateBanner()

GUICtrlCreateGroup("", 555, 28, 70, 28)
$btn = GUICtrlCreateLabel("Sign up", 555, 34, 70, 22, $SS_CENTER + $SS_CENTERIMAGE)
GUICtrlSetBkColor(-1, -2)
GUICtrlCreateGroup("", -99, -99, 1, 1)  ;close group
GUISetState()

Do
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btn
            MsgBox(0, "Information", "Button Sign up pressed")
    EndSwitch
Until False

Func _GUICreateBanner()
    _GDIPlus_Startup()
    Local Const $STM_SETIMAGE = 0x0172
    GUICtrlCreatePic("cloudsandsky.jpg", -480, 0, 1920, 87)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlSetResizing(-1, 840)

    $hImage_Logo = _GDIPlus_ImageLoadFromFile("logo.gif")
    $hBmp_Logo = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage_Logo)
    $idPic_Logo = GUICtrlCreatePic("", 50, 18, 188, 47)
    GUICtrlSetResizing(-1, 834)
    GUICtrlSetState(-1, $GUI_DISABLE)
    _WinAPI_DeleteObject(GUICtrlSendMsg($idPic_Logo, $STM_SETIMAGE, 0, $hBmp_Logo))
    _WinAPI_DeleteObject($hBmp_Logo)
    _GDIPlus_ImageDispose($hImage_Logo)
    _GDIPlus_Shutdown()

    $bM = 0
    Do
        GUICtrlCreatePic("grass.gif", $bM, 75, 128, 25)
        GUICtrlSetBkColor(-1 , -2)
        GUICtrlSetState(-1, $GUI_DISABLE)
        GUICtrlSetResizing(-1, 834)
        $bM += 128
    Until $bM > 856
EndFunc

Br,

UEZ

Eh, thanks for trying though, but I prefer the default windows button without that extra bit :3 I'm not sure if it's possible in AutoIt, though :/ I'd like to retain the animation effects that buttons give :)

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <StaticConstants.au3>

GUICreate("Minecraft Launcher", 856, 99, -1, -1)
GUISetBkColor(0x000000)

_GUICreateBanner()

$btn = GUICtrlCreateButton("Sign up", 555, 34, 70, 22)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUISetState()

Do
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btn
            MsgBox(0, "Information", "Button Sign up pressed")
    EndSwitch
Until False

Func _GUICreateBanner()
    _GDIPlus_Startup()
    Local Const $STM_SETIMAGE = 0x0172
    GUICtrlCreatePic("cloudsandsky.jpg", -480, 0, 1920, 87)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlSetResizing(-1, 840)

    $hImage_Logo = _GDIPlus_ImageLoadFromFile("logo.gif")
    $hBmp_Logo = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage_Logo)
    $idPic_Logo = GUICtrlCreatePic("", 50, 18, 188, 47)
    GUICtrlSetResizing(-1, 834)
    GUICtrlSetState(-1, $GUI_DISABLE)
    _WinAPI_DeleteObject(GUICtrlSendMsg($idPic_Logo, $STM_SETIMAGE, 0, $hBmp_Logo))
    _WinAPI_DeleteObject($hBmp_Logo)
    _GDIPlus_ImageDispose($hImage_Logo)
    _GDIPlus_Shutdown()

    $bM = 0
    Do
        GUICtrlCreatePic("grass.gif", $bM, 75, 128, 25)
        GUICtrlSetBkColor(-1 , -2)
        GUICtrlSetState(-1, $GUI_DISABLE)
        GUICtrlSetResizing(-1, 834)
        $bM += 128
    Until $bM > 856
EndFunc

With the code above, you can easily see that the black background of the GUI is visible through the picture. I'm trying to eliminate that whilst retaining the use of a button. Any ideas? :mellow:

EDIT: Managed to get it "sortof" fixed by setting the control to using no theme instead:

DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($hCtrl), "wstr", 0, "wstr", 0)

This makes the button lose its shinyness, though :) any other way? :party:

Edited by BoonPek
Link to comment
Share on other sites

This remove the border, if you want to remove more border then do the button bigger, the Child GUI will hide anything that exced from his edge,

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <winapiex.au3>



$hGUI = GUICreate("Minecraft Launcher", 856, 99, -1, -1)

_GUICreateBanner()
GUISetState()
GuiCreate("",68,20,556,35,$WS_POPUP,$WS_EX_MDICHILD,$hGUI)
GUISetState()
$iButton = GUICtrlCreateButton("Sign up", -2, -2, 72, 24)
GuiSwitch($hGUI) ; You can continue adding controls to the main GUI



Do
    Sleep(10)
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Func _GUICreateBanner()
    _GDIPlus_Startup()
    Local Const $STM_SETIMAGE = 0x0172
    GUICtrlCreatePic("cloudsandsky.jpg", -480, 0, 1920, 87)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlSetResizing(-1, 840)

    $hImage_Logo = _GDIPlus_ImageLoadFromFile("logo.gif")
    $hBmp_Logo = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage_Logo)
    $idPic_Logo = GUICtrlCreatePic("", 50, 18, 188, 47)
    _WinAPI_DeleteObject(GUICtrlSendMsg($idPic_Logo, $STM_SETIMAGE, 0, $hBmp_Logo))
    _WinAPI_DeleteObject($hBmp_Logo)
    _GDIPlus_ImageDispose($hImage_Logo)
    GUICtrlSetResizing(-1, 834)
    GUICtrlSetState(-1, $GUI_DISABLE)
    _GDIPlus_Shutdown()
    $bM = 0
    Do
        GUICtrlCreatePic("grass.gif", $bM, 75, 128, 25)
        GUICtrlSetBkColor(-1, -2)
        GUICtrlSetState(-1, $GUI_DISABLE)
        GUICtrlSetResizing(-1, 834)
        $bM += 128
    Until $bM > 856
EndFunc   ;==>_GUICreateBanner
Link to comment
Share on other sites

This remove the border, if you want to remove more border then do the button bigger, the Child GUI will hide anything that exced from his edge,

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <winapiex.au3>



$hGUI = GUICreate("Minecraft Launcher", 856, 99, -1, -1)

_GUICreateBanner()
GUISetState()
GuiCreate("",68,20,556,35,$WS_POPUP,$WS_EX_MDICHILD,$hGUI)
GUISetState()
$iButton = GUICtrlCreateButton("Sign up", -2, -2, 72, 24)
GuiSwitch($hGUI) ; You can continue adding controls to the main GUI



Do
    Sleep(10)
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Func _GUICreateBanner()
    _GDIPlus_Startup()
    Local Const $STM_SETIMAGE = 0x0172
    GUICtrlCreatePic("cloudsandsky.jpg", -480, 0, 1920, 87)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlSetResizing(-1, 840)

    $hImage_Logo = _GDIPlus_ImageLoadFromFile("logo.gif")
    $hBmp_Logo = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage_Logo)
    $idPic_Logo = GUICtrlCreatePic("", 50, 18, 188, 47)
    _WinAPI_DeleteObject(GUICtrlSendMsg($idPic_Logo, $STM_SETIMAGE, 0, $hBmp_Logo))
    _WinAPI_DeleteObject($hBmp_Logo)
    _GDIPlus_ImageDispose($hImage_Logo)
    GUICtrlSetResizing(-1, 834)
    GUICtrlSetState(-1, $GUI_DISABLE)
    _GDIPlus_Shutdown()
    $bM = 0
    Do
        GUICtrlCreatePic("grass.gif", $bM, 75, 128, 25)
        GUICtrlSetBkColor(-1, -2)
        GUICtrlSetState(-1, $GUI_DISABLE)
        GUICtrlSetResizing(-1, 834)
        $bM += 128
    Until $bM > 856
EndFunc   ;==>_GUICreateBanner

Genius, thanks! This would suffice, though I think that a native solution would be best :mellow:
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...