Jump to content
Sign in to follow this  

Z-index image overlay, how to with Autoit? [SOLVED]

Recommended Posts


Hi.. In html 5 4example I use Z-index on div object to overlay the images, how could I do this for example with the object pic and another object in the gui?

How can I use the transparency of a PNG file?

someone has already tried?


Edited by rootx

Share this post

Link to post
Share on other sites

The Z-Order is in the order of creating. When PNG-File has transparency it is used.  I use GUICtrlPic.au3 for creating Controls with PNG-image.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUICtrlPic.au3>

Global $aHoverBtn[5][5]
$aHoverBtn[0][1] = @ScriptDir & "\Pictures\Up.png"
$aHoverBtn[0][2] = @ScriptDir & "\Pictures\UpHovered.png"
$aHoverBtn[0][3] = @ScriptDir & "\Pictures\UpPressed.png"
$aHoverBtn[0][4] = False

$aHoverBtn[1][1] = @ScriptDir & "\Pictures\Down.png"
$aHoverBtn[1][2] = @ScriptDir & "\Pictures\DownHovered.png"
$aHoverBtn[1][3] = @ScriptDir & "\Pictures\DownPressed.png"
$aHoverBtn[1][4] = False

$aHoverBtn[2][1] = @ScriptDir & "\Pictures\Left.png"
$aHoverBtn[2][2] = @ScriptDir & "\Pictures\LeftHovered.png"
$aHoverBtn[2][3] = @ScriptDir & "\Pictures\LeftPressed.png"
$aHoverBtn[2][4] = False

$aHoverBtn[3][1] = @ScriptDir & "\Pictures\Right.png"
$aHoverBtn[3][2] = @ScriptDir & "\Pictures\RightHovered.png"
$aHoverBtn[3][3] = @ScriptDir & "\Pictures\RightPressed.png"
$aHoverBtn[3][4] = False

$aHoverBtn[4][1] = @ScriptDir & "\Pictures\Exit.png"
$aHoverBtn[4][2] = @ScriptDir & "\Pictures\ExitHovered.png"
$aHoverBtn[4][3] = @ScriptDir & "\Pictures\ExitPressed.png"
$aHoverBtn[4][4] = False

Global $hGui = GUICreate("Hovered Ping-Buttons", 612, 369, 271, 235)
Local $sAutoItPath = StringReplace(@AutoItExe, "autoit3.exe", "")
ConsoleWrite($sAutoItPath & "Examples\GUI\msoobe.jpg" & @CRLF)
Local $Background = _GUICtrlPic_Create($sAutoItPath & "Examples\GUI\msoobe.jpg", 0, 0, 612, 369, $SS_CENTERIMAGE, Default)
GUICtrlSetState(-1, $Gui_DISABLE)
Local $idTorus = _GUICtrlPic_Create($sAutoItPath & "Examples\GUI\Torus.png", 8, 8, 68, 71, $SS_CENTERIMAGE, Default)
GUICtrlSetState(-1, $Gui_DISABLE)

$aHoverBtn[0][0] = _GUICtrlPic_Create($aHoverBtn[0][1], 460, 8, 48, 48, BitOR($SS_CENTERIMAGE, $SS_NOTIFY), Default) ;Up
$aHoverBtn[1][0] = _GUICtrlPic_Create($aHoverBtn[1][1], 460, 138, 48, 48, BitOR($SS_CENTERIMAGE, $SS_NOTIFY), Default) ;Down
$aHoverBtn[2][0] = _GUICtrlPic_Create($aHoverBtn[2][1], 400, 73, 48, 48, BitOR($SS_CENTERIMAGE, $SS_NOTIFY), Default) ;Left
$aHoverBtn[3][0] = _GUICtrlPic_Create($aHoverBtn[3][1], 520, 73, 48, 48, BitOR($SS_CENTERIMAGE, $SS_NOTIFY), Default) ;Right
$aHoverBtn[4][0] = _GUICtrlPic_Create($aHoverBtn[4][1], 540, 266, 48, 48, BitOR($SS_CENTERIMAGE, $SS_NOTIFY), Default) ;Exit

While 1
    #Region ;Hover Or Not?
    $Info = GUIGetCursorInfo($hGui)
    For $i = 0 To UBound($aHoverBtn) - 1
        If $Info[4] = $aHoverBtn[$i][0] Then
            If $aHoverBtn[$i][4] Then _GUICtrlPic_SetImage($aHoverBtn[$i][0], $aHoverBtn[$i][2], True)
            $aHoverBtn[$i][4] = False
            If Not $aHoverBtn[$i][4] Then _GUICtrlPic_SetImage($aHoverBtn[$i][0], $aHoverBtn[$i][1], True)
            $aHoverBtn[$i][4] = True
    #EndRegion ;Hover Or Not?
    $nMsg = GUIGetMsg()
    $aPos = ControlGetPos($hGui, "", $idTorus)
    Switch $nMsg
        Case $Gui_EVENT_CLOSE
        Case $aHoverBtn[0][0]
            If _GuiCtrlPic_AnimButton($hGui, $aHoverBtn[0][0], $aHoverBtn[0][1], $aHoverBtn[0][3]) Then $aPos[1] -= 5 ;nach oben
        Case $aHoverBtn[1][0]
            If _GuiCtrlPic_AnimButton($hGui, $aHoverBtn[1][0], $aHoverBtn[1][1], $aHoverBtn[1][3]) Then $aPos[1] += 5 ;nach unten
        Case $aHoverBtn[2][0]
            If _GuiCtrlPic_AnimButton($hGui, $aHoverBtn[2][0], $aHoverBtn[2][1], $aHoverBtn[2][3]) Then $aPos[0] -= 5 ;nach links
        Case $aHoverBtn[3][0]
            If _GuiCtrlPic_AnimButton($hGui, $aHoverBtn[3][0], $aHoverBtn[3][1], $aHoverBtn[3][3]) Then $aPos[0] += 5 ;nach rechts
        Case $aHoverBtn[4][0]
            If _GuiCtrlPic_AnimButton($hGui, $aHoverBtn[4][0], $aHoverBtn[4][1], $aHoverBtn[4][3]) Then Exit
    ControlMove($hGui, "", $idTorus, $aPos[0], $aPos[1])


What have you tried?

  • Like 1

Share this post

Link to post
Share on other sites
#include <GDIPlus.au3>
#include <GUIConstants.au3>
#include <WinAPI.au3>

Global $hMain = GUICreate("Example", 1024, 768)
Global $picImage = GUICtrlCreatePic("", 0, 0, 1024, 768)
Global $hHBitmapImages = CreateImage()

_WinAPI_DeleteObject(GUICtrlSendMsg($picImage, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmapImages))

GUISetState(@SW_SHOW, $hMain)

While (True)
    Switch (GUIGetMsg())
        Case $GUI_EVENT_CLOSE


Func CreateImage()
    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0(1024, 768)
    Local $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    Local $sRegPath = "HKLM\SOFTWARE\Wow6432Node\AutoIt v3\AutoIt"
    Local $sAutoitPath = RegRead($sRegPath, "InstallDir")
    Local $hImageMsoobe = _GDIPlus_ImageLoadFromFile($sAutoitPath & "\Examples\GUI\msoobe.jpg")
    Local $hImageMsLogo = _GDIPlus_ImageLoadFromFile($sAutoitPath & "\Examples\GUI\mslogo.jpg")
    Local $hImageTorus = _GDIPlus_ImageLoadFromFile($sAutoitPath & "\Examples\GUI\torus.png")
    Local $hHReturn = Null


    _GDIPlus_GraphicsDrawImage($hGraphics, $hImageMsoobe, 0, 0)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hImageMsLogo, 0, 768 - _GDIPlus_ImageGetHeight($hImageMsLogo))
    _GDIPlus_GraphicsDrawImage($hGraphics, $hImageTorus, (1024 / 2) - (_GDIPlus_ImageGetWidth($hImageTorus) / 2), 0)

    $hHReturn = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)

    Return $hHReturn
EndFunc   ;==>DrawImages


  • Like 1

Share this post

Link to post
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
Sign in to follow this  

  • Similar Content

    • Xandy
      By Xandy
      MapIt is a tile world editor.  MapIt was built around the concept of reversing Dragon Warrior map images.  MapIt can take image input and produce a tile and world array.
      MapIt features Unity style dragable labels that adjust property values.

      MapParser is a C++ project that scans images for unique tiles.  MapParser is very fast.  Due to hard drive failure, many bugs were restored b/c I had to rewind many years.  Frustrated with the design, I wrote a new version from the ground up.  This New Version:  AutoIt Front-end, command line controls, and shared with the world; so that I can't lose it again.
      You can toggle the C++ MapParser off to see the difference in speeds between the MapParser CPP verse AutoIt function.  Function is named Scan_Tiles() in AutoIt.  You can also chose to download without MapParser.exe.
      At the moment Scanning a image resets the arrays, but you can add tiles after scanning.
      Images can be added as tiles without scan image at all.  Then configure settings to give your world parameters and manually fill the world data with tile indexes.
      Using the settings you can change tile size after a scan.  Example: you wanted to replace a map with different sized tiles.
      Changing and replacing tile / world data is easy.  B/c tile world editor.

      Hotkeys, I use CTRL+R in image above to signal replace tile action and I use "G" to Get the tile under mouse.
      Hotkeys are not saved to disk and thus are set to default between sessions.
      I might draw the world to pre-rendered surfaces and use them as multi-layer someday.  I do that in my AutoIt, DragonWarrior Remake but I could spend forever unsure what features are important for this.  The DW_Remake has a method of replacing a tile with a tile on two layers.  So you could replace a tree on the first layer with a grass, and a tree in the second layer.  This is all getting very confusing.
      I attempted to write the good code.  If something could be better, please advise.
      Forth release.  Enjoy.
      For download, videos, and example of created world file data; please visit the MapIt webpage: http://songersoft.com/programming/mapit/mapit_about.phtml
      Special thanks: @AdmiralAlkex, @Melba23, @MrCreatoR
      Main AutoIt source file: Will not run without other Includes and SDL DLLs.
      Last Update: 5/23/2018 7:55 PM EST
      Next Version  
    • lenclstr746
      By lenclstr746
      I'm a work on a background see and click bot project 
      I can complete it if your help me
      (using imagesearch , gdi+ and  fastfind)
    • dadalt95
      By dadalt95
      I would like to know if it's possible to pass an image recognition (captcha) system.
      What are the ways to achieve this?
      Just the references or links is enough for me by now.
      Thanks by now!
    • fatpig
      By fatpig
      Dear AutoIT Community.
      I am currently working on a program that will display lots of images in a scroll down GUI.
      I create the GUI based on the number of images, which works fine.
      But all images I place using GuiCtrlCreatePic above a threshold of around 32000 pixels (cant say exactly) are placed at negative locations and finally will reach 0 again
      and will then populate on top of the images placed there before.
      For $i = 1 To $Images[0] ; Get picture dimensions $hImage = _GDIPlus_ImageLoadFromFile($ImgRep & $Images[$i]) $iX = _GDIPlus_ImageGetWidth($hImage) $iY = _GDIPlus_ImageGetHeight($hImage) _GDIPlus_ImageDispose($hImage) ; Resize & place images in GUI $Pic[$i] = GUICtrlCreatePic($ImgRep & $Images[$i], $Spacer, Round($yPos, 0), $MaxImgWidth, $MaxImgWidth * ($iY / $iX)) $yPos = $yPos + $MaxImgWidth * ($iY / $iX) + $Spacer $log = $log & "|" & $yPos $currentlut = $Images[1] Next I have found a limit at 32767 pixels for some GUI elements when googling around.
      Can someone tell me how to circumvent that?
    • DeathChicken
      By DeathChicken
      If possible please add or edit the comments to explain how this works.
      ;includes functions from other things
      #include <GDIPlus.au3>
      #include <ScreenCapture.au3>
      HotKeySet("{ESC}", _exit)
      HotKeySet("{F1}", _scan)
      ;global variables
      Global $win_title                    ;name of the window
      Global $area_x                        ;
      Global $area_y                        ;
      Global $area_w                       ;
      Global $area_h                        ;
      Global $cursor                         ;
      Global $rect_file                      ;
      Global $hbmpscreen              ;
      Global $i=  1043                      ;moves the rect
      Global $ii=    378                      ;moves the rect
      Global $x=1044                        ;inner rect offset
      Global $y=501                          ;inner rect offset
      Global $hbmprect                    ;image inside rect
      Global $hscreen                        ;image whole screen
      _GDIPlus_Startup()                    ;?
      ;display hotkeys on screen
      ToolTip("Press F1 to scan | Press ESC to Exit",0,0)
                                          ;infinite loop to keep prog running
      While 1
      Func _scan()
      ;~ reads your screen area:
      ;~ converts screen captured into bmp
      ;~ .  Loads converted bmp to be read
      ;~ compares the bmp of your scanned screen to the actual screen that is being displayed
                                          ;reads screen
      Func _read()
          $hscreen = _ScreenCapture_CaptureWnd("", WinGetHandle($win_title), $area_x, $area_y, $area_x + $area_w, $area_y + $area_h, $cursor)
                                          ;converts screen into bmp
      Func _convert()
                                          ;loads converted screen
      Func _loadBMP()
                                          ;compares savedBMP to current screen
      Func _compare()
      ;If(                              below code                                     ) = (                   below code           ) Then
      If _GDIPlus_BitmapGetPixel($hbmpscreen, ($i + $x) - $area_x, ($ii + $y) - $area_y) = _GDIPlus_BitmapGetPixel($hbmprect, $x, $y) Then
      ;display message box titled found with a message of found
      ;if above is not correct then
                                          ;exit func
      Func _exit()

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.