Sign in to follow this  
Followers 0
Fossil Rock

Simple script layering graphic, label and png.

17 posts in this topic

#1 ·  Posted (edited)

I had to manipulate the png 'window' graphic to get the desired effect. I would like to get the grey.gif trick implemented to be able to use any png with transparency.

This example demonstrates the ability to have changing backgrounds and labels behind a transparent png graphic.

Feel free to improve it.

;;; Original found @ 'http://www.autoitscript.com/forum/index.php?s=&showtopic=53726&view=findpost&p=406753'

#include <A3LGDIPlus.au3>

Global  $hImage, $hGraphic

_GDIP_StartUp()
$hImage  = _GDIP_ImageLoadFromFile(@ScriptDir & "\Window1.png")
$iWidth  = _GDIP_ImageGetWidth ($hImage)
$iHeight = _GDIP_ImageGetHeight($hImage)

$hGUI = GUICreate("Mod-It", $iWidth + 100, $iHeight + 100)
GUISetBkColor(0xFFFFFF)
$back = GUICtrlCreateGraphic(20,20,$iWidth + 8,$iHeight + 8)
$hGraphic = _GDIP_GraphicsCreateFromHWND($hGUI)
$label = GUICtrlCreateLabel("", 28, 40, 39, 17, $SS_CENTER)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 8, "", "", "Lucida Console")

GUISetState()
_GDIP_GraphicsDrawImage($hGraphic, $hImage, 20, 20)

While 1
    $nMsg = GUIGetMsg()
    $Pos1 = MouseGetPos()
    Select 
        Case $nMsg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
            Sleep(1)
            $Pos2 = MouseGetPos()
    Select
        Case $Pos1[0] <> $Pos2[0] Or $Pos1[1] <> $Pos2[1]
            move()
    EndSelect
WEnd

_GDIP_GraphicsDispose($hGraphic)
_GDIP_ImageDispose($hImage)
_GDIP_ShutDown()

Func move()
    $pos = MouseGetPos()
    $color = PixelGetColor($pos[0], $pos[1])
    Sleep(30)
    GUICtrlSetBkColor($back, $color)
    GUICtrlSetData($label, StringRight((Hex(PixelGetColor($Pos[0], $Pos[1]))), 6))
    _GDIP_GraphicsDrawImage($hGraphic, $hImage, 20, 20)
    Sleep(30)
EndFunc

Save this graphic as "Window1.png" in the script dir.

post-9237-1190423483_thumb.png

Edited by Fossil Rock

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites



pretty cool, a bit jittery...

Share this post


Link to post
Share on other sites
Updated... check it out.

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites

Cool, it pulls the color under the mouse and shows the color and the hex code for it. Nice...

Share this post


Link to post
Share on other sites

C:\Users\Tyler\Desktop\New AutoIt v3 Script.au3(1,10) : ERROR: can't open include file <A3LGDIPlus.au3>
#include <A3LGDIPlus.au3>
~~~~~~~~~^
C:\Users\Tyler\Desktop\New AutoIt v3 Script.au3(6,15) : ERROR: _GDIP_StartUp(): undefined function.
_GDIP_StartUp()
~~~~~~~~~~~~~~^
C:\Users\Tyler\Desktop\New AutoIt v3 Script.au3(7,63) : ERROR: _GDIP_ImageLoadFromFile(): undefined function.
$hImage  = _GDIP_ImageLoadFromFile(@ScriptDir & "\Window1.png")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Tyler\Desktop\New AutoIt v3 Script.au3(8,40) : ERROR: _GDIP_ImageGetWidth(): undefined function.
$iWidth  = _GDIP_ImageGetWidth ($hImage)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Tyler\Desktop\New AutoIt v3 Script.au3(9,40) : ERROR: _GDIP_ImageGetHeight(): undefined function.
$iHeight = _GDIP_ImageGetHeight($hImage)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Tyler\Desktop\New AutoIt v3 Script.au3(14,47) : ERROR: _GDIP_GraphicsCreateFromHWND(): undefined function.
$hGraphic = _GDIP_GraphicsCreateFromHWND($hGUI)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Tyler\Desktop\New AutoIt v3 Script.au3(20,51) : ERROR: _GDIP_GraphicsDrawImage(): undefined function.
_GDIP_GraphicsDrawImage($hGraphic, $hImage, 20, 20)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Tyler\Desktop\New AutoIt v3 Script.au3(37,32) : ERROR: _GDIP_GraphicsDispose(): undefined function.
_GDIP_GraphicsDispose($hGraphic)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Tyler\Desktop\New AutoIt v3 Script.au3(38,27) : ERROR: _GDIP_ImageDispose(): undefined function.
_GDIP_ImageDispose($hImage)
~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Tyler\Desktop\New AutoIt v3 Script.au3(39,16) : ERROR: _GDIP_ShutDown(): undefined function.
_GDIP_ShutDown()
~~~~~~~~~~~~~~~^
C:\Users\Tyler\Desktop\New AutoIt v3 Script.au3 - 10 error(s), 0 warning(s)

Not everyone downloads UDF's or libraries, just a tip, add the UDF you use from the library in your script, or state that it needs that specific one downloaded.

~TK

Share this post


Link to post
Share on other sites

C:\Users\Tyler\Desktop\New AutoIt v3 Script.au3(1,10) : ERROR: can't open include file <A3LGDIPlus.au3>
#include <A3LGDIPlus.au3>
~~~~~~~~~^
C:\Users\Tyler\Desktop\New AutoIt v3 Script.au3(6,15) : ERROR: _GDIP_StartUp(): undefined function.
_GDIP_StartUp()
~~~~~~~~~~~~~~^
C:\Users\Tyler\Desktop\New AutoIt v3 Script.au3(7,63) : ERROR: _GDIP_ImageLoadFromFile(): undefined function.
$hImage  = _GDIP_ImageLoadFromFile(@ScriptDir & "\Window1.png")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Tyler\Desktop\New AutoIt v3 Script.au3(8,40) : ERROR: _GDIP_ImageGetWidth(): undefined function.
$iWidth  = _GDIP_ImageGetWidth ($hImage)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Tyler\Desktop\New AutoIt v3 Script.au3(9,40) : ERROR: _GDIP_ImageGetHeight(): undefined function.
$iHeight = _GDIP_ImageGetHeight($hImage)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Tyler\Desktop\New AutoIt v3 Script.au3(14,47) : ERROR: _GDIP_GraphicsCreateFromHWND(): undefined function.
$hGraphic = _GDIP_GraphicsCreateFromHWND($hGUI)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Tyler\Desktop\New AutoIt v3 Script.au3(20,51) : ERROR: _GDIP_GraphicsDrawImage(): undefined function.
_GDIP_GraphicsDrawImage($hGraphic, $hImage, 20, 20)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Tyler\Desktop\New AutoIt v3 Script.au3(37,32) : ERROR: _GDIP_GraphicsDispose(): undefined function.
_GDIP_GraphicsDispose($hGraphic)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Tyler\Desktop\New AutoIt v3 Script.au3(38,27) : ERROR: _GDIP_ImageDispose(): undefined function.
_GDIP_ImageDispose($hImage)
~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Tyler\Desktop\New AutoIt v3 Script.au3(39,16) : ERROR: _GDIP_ShutDown(): undefined function.
_GDIP_ShutDown()
~~~~~~~~~~~~~~~^
C:\Users\Tyler\Desktop\New AutoIt v3 Script.au3 - 10 error(s), 0 warning(s)

Not everyone downloads UDF's or libraries, just a tip, add the UDF you use from the library in your script, or state that it needs that specific one downloaded.

~TK

It was the wish of PaulIA to keep only the full library to be downloaded. That is so there isn't 100 different versions of 1 UDF. Just download the full one :) It's great!

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Not everyone downloads UDF's or libraries, just a tip, add the UDF you use from the library in your script, or state that it needs that specific one downloaded.

~TK

You must have Auto3Library installed. Search for it in examples forum.

EDIT:

everytime you will see #include <A3L....au3> it's part of Auto3Library

Edited by Zedna

Share this post


Link to post
Share on other sites

You must have Auto3Library installed. Search for it in examples forum.

EDIT:

everytime you will see #include <A3L....au3> it's part of Auto3Library

Don't you mean Auto3Lib

Share this post


Link to post
Share on other sites

Nice work! I like how it works... It does flicker a bit though :)

Thanks... yeah, flicker is really hard to control in this example, but the example is to demonstrate layering controls under a transparent PNG. It should create a 3D effect. And if you don't update the data very often, the flicker will be minimal.

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites

You must have Auto3Library installed. Search for it in examples forum.

EDIT:

everytime you will see #include <A3L....au3> it's part of Auto3Library

Nawww.... I only test example scripts to see how peoples code work, give them feedback. I do not use other people's functions I try to always make my own, so it is more "original" you know? That's the only reason I haven't downloaded the functions library.

~TK

Share this post


Link to post
Share on other sites

This serves as a good example!

Thanks for the share.


Share this post


Link to post
Share on other sites

Nawww.... I only test example scripts to see how peoples code work, give them feedback. I do not use other people's functions I try to always make my own, so it is more "original" you know? That's the only reason I haven't downloaded the functions library.

~TK

Oh, right. So you have deleted all the include files that came with AutoIt and replaced them with your own then. That's pretty cool.


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.

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  
Followers 0