Chimp

Interesting effect with transparency

6 posts in this topic




Cool effect, nice example. Thanks for sharing, Reinhard

Share this post


Link to post
Share on other sites

it's funny !


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I knew that I had already seen these little fish somewhere.
I has them on my pc.
If I remember correctly, when we do some clicks on screen, some "food" for fish appears
But with transparency, it's not visible.
The only way to do it here, is to click on fish.  ;)

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

Very nice, thanks for sharing

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

  • Similar Content

    • Chimp
      By Chimp
      just for further fun Here is a Javascript version of the nice 3D sine wave posted from @UEZ
      This version uses this nice javascript library:(http://visjs.org/graph3d_examples.html).  (All the 'dirty' work is done by the javascript library, so the whole credit goes of course to that library and not to me...) I've simply injected all the html/javascript stuff into a BrowserControl embedded into an AutoIt GUI.
      Have fun
      #include <GUIConstantsEx.au3> Example() Exit Func Example() Local $oIE = ObjCreate("Shell.Explorer.2") ; Create a BrowserControl Local $hGUI = GUICreate("3D Sinus wave animation demo", 660, 650, 30, 30) GUICtrlCreateObj($oIE, 0, 0, 660, 650) ; Place BrowserControl on the GUI GUISetState() ;Show GUI $oIE.navigate('about:blank') While Not String($oIE.readyState) = 'complete' ; wait for about:blank Sleep(100) WEnd ; this waits till the document is ready to be used (portion of code from IE.au3) While Not (String($oIE.readyState) = "complete" Or $oIE.readyState = 4) Sleep(100) WEnd While Not (String($oIE.document.readyState) = "complete" Or $oIE.document.readyState = 4) Sleep(100) WEnd $oIE.document.Write(_GetHTML()) ; inject lising directly to the HTML document: $oIE.document.close() ; close the write stream $oIE.document.execCommand("Refresh") ; ----------------------------- ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; the end $oIE = 0 ; Remove IE from memory. GUIDelete($hGUI) ; Remove GUI EndFunc ;==>Example Func _GetHTML() Local $sHTML = _ "<!doctype html>" & @CRLF & _ "<html>" & @CRLF & _ "<head>" & @CRLF & _ " <meta http-equiv=""X-UA-Compatible"" content=""IE=edge"" />" & @CRLF & _ " <title></title>" & @CRLF & _ "" & @CRLF & _ " <style type=""text/css"">" & @CRLF & _ " body {" & @CRLF & _ " font: 10pt arial;" & @CRLF & _ " }" & @CRLF & _ " </style>" & @CRLF & _ "" & @CRLF & _ " <script type=""text/javascript"" src=""https://cdnjs.cloudflare.com/ajax/libs/vis/4.18.0/vis.min.js""></script>" & @CRLF & _ "" & @CRLF & _ " <script type=""text/javascript"">" & @CRLF & _ " var data = null;" & @CRLF & _ " var graph = null;" & @CRLF & _ " var x0, x1, x2" & @CRLF & _ " function custom(x, y, t) {" & @CRLF & _ " // change this function to change the graph" & @CRLF & _ " x0 = 20 - t/180;" & @CRLF & _ " x1 = (x/x0)*(x/x0) + t/10;" & @CRLF & _ " y1 = (y/x0)*(y/x0) + t/10;" & @CRLF & _ " return Math.sin(Math.sqrt(x1+y1));" & @CRLF & _ " }" & @CRLF & _ " // Called when the Visualization API is loaded." & @CRLF & _ " function drawVisualization() {" & @CRLF & _ " // Create and populate a data table." & @CRLF & _ " data = new vis.DataSet();" & @CRLF & _ " // create some nice looking data with sin/cos" & @CRLF & _ " var steps = 25;" & @CRLF & _ " var axisMax = 314;" & @CRLF & _ " var tMax = 800;" & @CRLF & _ " var axisStep = axisMax / steps;" & @CRLF & _ " for (var t = 300; t <= tMax; t = t + 50) {" & @CRLF & _ " for (var x = -axisMax; x < axisMax; x+=axisStep) {" & @CRLF & _ " for (var y = -axisMax; y < axisMax; y+=axisStep) {" & @CRLF & _ " var value = custom(x, y, t);" & @CRLF & _ " data.add([" & @CRLF & _ " {x:x,y:y,z:value,filter:t,style:value}" & @CRLF & _ " ]);" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " // specify options" & @CRLF & _ " var options = {" & @CRLF & _ " width: '600px'," & @CRLF & _ " height: '600px'," & @CRLF & _ " style: 'surface'," & @CRLF & _ " showPerspective: true," & @CRLF & _ " showGrid: false," & @CRLF & _ " showShadow: false," & @CRLF & _ " // showAnimationControls: false," & @CRLF & _ " keepAspectRatio: true," & @CRLF & _ " verticalRatio: 0.085, // 0.5," & @CRLF & _ " animationInterval: 100, // milliseconds" & @CRLF & _ " animationPreload: true," & @CRLF & _ " animationAutoStart: true," & @CRLF & _ " filterValue: 'time'" & @CRLF & _ " };" & @CRLF & _ "" & @CRLF & _ " // create our graph" & @CRLF & _ " var container = document.getElementById('mygraph');" & @CRLF & _ " graph = new vis.Graph3d(container, data, options);" & @CRLF & _ " }" & @CRLF & _ " </script>" & @CRLF & _ "</head>" & @CRLF & _ "" & @CRLF & _ "<body onload=""drawVisualization();"">" & @CRLF & _ "<div id=""mygraph""></div>" & @CRLF & _ "" & @CRLF & _ "<div id=""info""></div>" & @CRLF & _ "</body>" & @CRLF & _ "</html>" Return $sHTML EndFunc ;==>_GetHTML  
    • Chimp
      By Chimp
      This is a little experiment that makes use of a "Browser Control" embedded in a GUI in order to be able to use AutoIt, HTML, JavaScript and CSS all together.
      This little toy will only work on systems with IE11.
      The purpose is to drag all the names of the scientists & drop on the right ones. (among scientists it has also infiltrated an intruder). I hope you find it entertaining.
      I've posted it here in the hope to have some suggestions on how to improve it all (I mean the interaction between Autoit Javascript html and css). Thanks
      ; this works on systems with IE11 ; ------------------------------- #include <GUIConstantsEx.au3> #include <array.au3> Global $oIE, $oDocument, $ohJS, $sDroping Global $iCorrect = 0, $iGoal = 11 Example() Exit Func Example() Local $aScientists[12][2] = _ [["Schrodinger", "Schrodinger"],["Planck", "Planck"],["Pauli", "Pauli"],["Einstein", "Einstein"], _ ["Chimp", "Chimp"],["Dirac", "Dirac"],["Heisenberg", "Heisenberg"],["Born", "Born"], _ ["De Broglie", "De_Broglie"],["Bohr", "Bohr"],["Sommerfeld", "Sommerfeld"],["", "empty"]] Local $oIE = ObjCreate("Shell.Explorer.2") ; Create a BrowserControl Local $hGUI = GUICreate("", 660, 600, 30, 30) GUICtrlCreateObj($oIE, 0, 0, 660, 600) ; Place BrowserControl on the GUI GUISetState() ;Show GUI $oIE.navigate('about:blank') ; file:///' & @ScriptDir & '\WhoIsWho.html') While Not String($oIE.readyState) = 'complete' ; wait for about:blank Sleep(100) WEnd ; this waits till the document is ready to be used (portion of code from IE.au3) While Not (String($oIE.readyState) = "complete" Or $oIE.readyState = 4) Sleep(100) WEnd While Not (String($oIE.document.readyState) = "complete" Or $oIE.document.readyState = 4) Sleep(100) WEnd $oIE.document.Write(_GetHTML()) ; inject lising directly to the HTML document: $oIE.document.close() ; close the write stream $oIE.document.execCommand("Refresh") While Not String($oIE.readyState) = 'complete' ; wait for readyState after a refresh Sleep(100) WEnd ; https://msdn.microsoft.com/en-us/library/52f50e9t(v=vs.94).aspx ; $ohJS is a reference to the javascript Global Obj ; ------------------------------------------------- $ohJS = $oIE.document.parentwindow.JSglobal $oDocument = $oIE.document Local $oTable1 = $ohJS.table1 Local $oTable2 = $ohJS.table2 _Randomize($aScientists, $oTable1) ; --- Setup events ------------ ; https://msdn.microsoft.com/en-us/library/hh801967(v=vs.85).aspx Local $aoEventObject[2] $aoEventObject[0] = ObjEvent($oTable1, "IEEvent_", "HTMLTableEvents2") $aoEventObject[1] = ObjEvent($oTable2, "IEEvent_", "HTMLTableEvents2") ; ----------------------------- ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch If $iCorrect = $iGoal Then _Goal() _Randomize($aScientists, $oTable1) $iCorrect = 0 EndIf WEnd ; the end For $i = 0 To UBound($aoEventObject) - 1 $aoEventObject[$i] .stop Next $aoEventObject = 0 ; Kill the Event Object $oIE = 0 ; Remove IE from memory (not really necessary). GUIDelete($hGUI) ; Remove GUI EndFunc ;==>Example ; --- event management zone --- ; following functions are fired by events occurred in the browser control Volatile Func IEEvent_onDragstart($oEvent) ; we save the ID of the dragged obj into the $sDroping variable ; for a later use in the drop function $sDroping = $oEvent.srcElement.ID EndFunc ;==>IEEvent_onDragstart Volatile Func IEEvent_onDragOver($oEvent) $ohJS.event.preventDefault() EndFunc ;==>IEEvent_onDragOver Volatile Func IEEvent_onDrop($oEvent) $ohJS.event.preventDefault() If $sDroping <> "" Then If $oDocument.getElementById($sDroping).innerText <> $oEvent.srcElement.innerText Then If $oEvent.srcElement.ClassName = $oDocument.getElementById($sDroping).ClassName Then $oEvent.srcElement.innerText = $oDocument.getElementById($sDroping).innerText $oDocument.getElementById($sDroping).innerText = "" $oDocument.getElementById($sDroping).draggable = False $oDocument.getElementById($sDroping).setAttribute("style") = "background-color: #80ff80;" $iCorrect += 1 Else For $i = 1 To 3 $oDocument.getElementById($sDroping).setAttribute("style") = "background-color: #ff0000;" Sleep(125) $oDocument.getElementById($sDroping).setAttribute("style") = "background-color: #ffffff;" Sleep(125) Next EndIf EndIf $sDroping = "" EndIf EndFunc ;==>IEEvent_onDrop Func _Randomize(ByRef $aScientists, ByRef $oTable) Local $iRows = ($oTable.rows.length) - 1 Local $iCols = ($oTable.rows.item(0).cells.length) - 1 Local $index _ArrayShuffle($aScientists) For $y = 0 To $iRows For $x = 0 To $iCols $index = ($y * ($iCols + 1)) + $x $oTable.rows.item($y).cells.item($x).innerText = $aScientists[$index][0] ; text $oTable.rows.item($y).cells.item($x).className = $aScientists[$index][1] ; class $oTable.rows.item($y).cells.item($x).draggable = $aScientists[$index][0] <> "" Next Next EndFunc ;==>_Randomize Func _Goal() Local $oTable1 = $ohJS.table1 ; names Local $oTable2 = $ohJS.table2 ; photos Local $iRows = ($oTable1.rows.length) Sleep(250) Local $iCols = 6 ; ($oTable1.rows.item(0).cells.length) Local $aIndex[$iRows * $iCols], $sTemp For $i = 0 To UBound($aIndex) - 1 $aIndex[$i] = $i ; + 1 Next _ArrayShuffle($aIndex) For $i = 0 To UBound($aIndex) - 1 $oTable2.rows.item(Int($aIndex[$i] / $iCols)).cells.item(Mod($aIndex[$i], $iCols)).innerText = "" $oTemp0 = $oTable2.rows $oTemp1 = $oTemp0.item(Int($aIndex[$i] / $iCols)).cells $oTemp2 = $oTemp1.item(Mod($aIndex[$i], $iCols)).getAttribute("style") $oTable2.rows.item(Int($aIndex[$i] / $iCols)).cells.item(Mod($aIndex[$i], $iCols)).setAttribute("style") = "background-color: " & _rndColor() Sleep(100); MsgBox(0,"Debug",$sTemp) $oTable2.rows.item(Int($aIndex[$i] / $iCols)).cells.item(Mod($aIndex[$i], $iCols)).setAttribute("style") = $oTemp2 Next For $x = 1 To 2 For $i = 0 To UBound($aIndex) - 1 $oTable1.rows.item(Int($aIndex[$i] / $iCols)).cells.item(Mod($aIndex[$i], $iCols)).setAttribute("style") = "background-color: " & _rndColor() Sleep(100) $oTable1.rows.item(Int($aIndex[$i] / $iCols)).cells.item(Mod($aIndex[$i], $iCols)).setAttribute("style") = "background-color: #ffffff;" Next Next EndFunc ;==>_Goal Func _rndColor() Return String("#" & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2) & ";") EndFunc ;==>_rndColor Func _GetHTML() Local $sHTML = _ "<!DOCTYPE HTML>" & @CRLF & _ "<html>" & @CRLF & _ "<head>" & @CRLF & _ "<meta http-equiv=""X-UA-Compatible"" content=""IE=edge"" />" & @CRLF & _ " <script type=""text/javascript"">" & @CRLF & _ " var JSglobal = (1,eval)(""this"");" & @CRLF & _ " </script>" & @CRLF & _ "</head>" & @CRLF & _ "<body>" & @CRLF & _ "<h2>Who is who?</h2>" & @CRLF & _ "<p>Drag&Drop names on the right scientist</p>" & @CRLF & _ "<img src=""https://s29.postimg.org/4g264egmv/Scientists.jpg""" & @CRLF & _ "height=""394"" width=""640""" & @CRLF & _ "style=""position: absolute; left: 10px; top: 100px;"">" & @CRLF & _ "" & @CRLF & _ "<style>" & @CRLF & _ ".target td {width: 100px; height: 160px; text-align: center; color: white; font-weight: bold; vertical-align: bottom; border: 0px solid grey;}" & @CRLF & _ ".source td {width: 100px; height: 30px; text-align: center; border: 1px solid red;}" & @CRLF & _ "</style>" & @CRLF & _ "" & @CRLF & _ "<table class=""target"" style=""position: absolute; left: 25px; top: 100px;"" id=""table2"">" & @CRLF & _ " <tr><td class=""Schrodinger""></td><td class=""Planck""></td><td class=""Pauli""></td><td class=""Einstein""></td><td class=""Chimp""></td><td class=""Dirac""></td></tr>" & @CRLF & _ " <tr><td class=""Heisenberg""></td><td class=""Born""></td><td class=""De_Broglie""></td><td class=""Bohr""></td><td class=""Sommerfeld""></td><td class=""empty""></td></tr>" & @CRLF & _ "</table>" & @CRLF & _ "" & @CRLF & _ "<table class=""source"" style=""position: absolute; left: 10px; top: 504px;"" id=""table1"">" & @CRLF & _ " <tr><td ID=""td1""></td><td ID=""td2""></td><td ID=""td3""></td><td ID=""td4"" ></td><td ID=""td5"" ></td><td ID=""td6"" ></td></tr>" & @CRLF & _ " <tr><td ID=""td7""></td><td ID=""td8""></td><td ID=""td9""></td><td ID=""td10""></td><td ID=""td11""></td><td ID=""td12""></td></tr>" & @CRLF & _ "</table>" & @CRLF & _ "</body>" & @CRLF & _ "</html>" Return $sHTML EndFunc ;==>_GetHTML  
    • Chimp
      By Chimp
      Hello and happy new Year to everybody!
      I'm trying to catch some events occuring within a browser control by simply using the ObjEvent() function.
      I think I'm not using that function in a proper way since some events are captured, while other are not.
      more precisely, events like those listed in this page are working:
      https://msdn.microsoft.com/en-us/library/aa769764(v=vs.85).aspx
      while other events listed in other "interfaces", as in the following links, does not works.
      https://msdn.microsoft.com/en-us/library/hh801967(v=vs.85).aspx
      For exemple, Here I would like to catch events like "DragOver" and/or "Drop" fired while dragging the image on the web control, but I'm not been able to obtain a result.
      Those events are listed in the HTMLDocumentEvents4 interface or also in the HTMLImgEvents interface, but I failed to use them.
      Any hint that can help to see what I'm doing wrong, or even better that can show how to achieve the result by using the ObjEvent() function (if it's possible?) is welcome.
      Thanks a lot.
      Here is the simple script that I'm using for my tests:
      #include <GUIConstantsEx.au3> #include <string.au3> ; read html page from bottom of this script ; and write it to a file on disk for later ; usage by the $oIE.navigate CreateHtmlPage() Example() Exit Func Example() Local $hGUIMain = GUICreate("Event Test", 540, 400) ; We generate the Browser Control... Global $oIE = ObjCreate("Shell.Explorer.2") ; and we embed it into the AutoIt GUI $hIE = GUICtrlCreateObj($oIE, 5, 5, 530, 390) GUISetState() ;Show GUI ; load in the browser our previously created web page $oIE.navigate('file:///' & @ScriptDir & '\Page.html') Do ; wait for document Sleep(250) $oDocument = $oIE.document Until IsObj($oDocument) $oDocument.execCommand("Refresh") ; --- Setup catch of events --- Local $oEventObjects[2] $oImage = $oDocument.getElementById('drag1') ; Object reference to The image on the page ; https://msdn.microsoft.com/en-us/library/aa769764(v=vs.85).aspx ; HTMLDocumentEvents2 interface (catch OnClick, OnMouseOver, .... etc ; ObjEvent() "Handles incoming events from the given Object." ; ObjEvent($oParam1, $sParam2 [,$sParam3]) ; Parameters ; $oParam1 A variable containing an Object from which you want to receive events ; ; $sParam2 The prefix of the functions you define to handle receiving events. ; The prefix is appended by the Objects method name. ; ; $sParam3 "interface name" [optional] name of an Event interface to use. ; Note: It must be a supported as outgoing for the Object AND it must be of type DISPATCH. ; Using third parameter as "HTMLDocumentEvents2" as event interface, or even leaving it blank, ; is the only way by which I've been able to catch some events from the browser control ; OK, events listed here are catched --> https://msdn.microsoft.com/en-us/library/aa769764(v=vs.85).aspx $oEventObjects[0] = ObjEvent($oDocument, "IEEvent2_") ;, "HTMLDocumentEvents2") ; when I try to catch events fired by the Image dragged on the web page ; following attempts do not work (no event is captured and passed to AutoIt) ; $oEventObjects[1] = ObjEvent($oDocument, "IEEvent2_", "HTMLDocumentEvents2") ; $oEventObjects[1] = ObjEvent($oDocument, "IEEvent2_", "HTMLDocumentEvents4") ; $oEventObjects[1] = ObjEvent($oImage, "IEEvent2_", "HTMLDocumentEvents2") ; $oEventObjects[1] = ObjEvent($oImage, "IEEvent2_") $oEventObjects[1] = ObjEvent($oImage, "IEEvent2_", "HTMLImgEvents2") ; ----------------------------- ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; the end For $i = 0 To UBound($oEventObjects) - 1 $oEventObjects[$i].Stop ; Tell IE we don't want to receive events. $oEventObjects[$i] = 0 Next $oEventObject = 0 ; Kill the Event Object $oIE = 0 ; Remove IE from memory (not really necessary). GUIDelete($hGUIMain) ; Remove GUI EndFunc ;==>Example ; below function should be fired by events ; occurred in the browser's objects ; --- events management zone --- Volatile Func IEEvent2_onClick($oEvent) ConsolePrint("mouse click:") EndFunc ;==>IEEvent2_onClick Volatile Func IEEvent2_onDblClick($oEvent) ConsolePrint("mouse DoubleClick:") EndFunc ;==>IEEvent2_onDblClick ; Drag related events Volatile Func IEEvent2_onDragstart($oEvent) ConsolePrint("Drag action started") EndFunc ;==>IEEvent2_onDragstart ; --- following events are not catched --- ??? Volatile Func IEEvent2_onDragOver($oEvent) ConsolePrint("DragOver event") EndFunc ;==>IEEvent2_onDragOver Volatile Func IEEvent2_onDrop($oEvent) ConsolePrint("Drop action performed ") EndFunc ;==>IEEvent2_onDrop ; ------------------------------ Func ConsolePrint($sMsg) ConsoleWrite($sMsg & @CRLF) EndFunc ;==>ConsolePrint Func CreateHtmlPage() Local $sStart = @LF & "#cs;HTML" Local $sEnd = "#ce;HTML" & @CR Local $aArray = _StringBetween(FileRead(@ScriptFullPath), $sStart, $sEnd) Local $sPage = @ScriptDir & '\Page.html' Local $hFile = FileOpen($sPage, 2) ; $FO_OVERWRITE (2) = Write mode (erase previous contents) FileWrite($hFile, $aArray[0]) FileFlush($hFile) FileClose($hFile) EndFunc ;==>CreateHtmlPage ; example got from here: http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_draganddrop2 #cs;HTML <!DOCTYPE HTML> <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <style> #div1, #div2 { float: left; width: 214px; height: 214px; margin: 5px; padding: 10px; border: 1px solid black; } </style> <script> function allowDrop(ev) {ev.preventDefault();} function drag(ev) {ev.dataTransfer.setData("text", ev.target.id);} function drop(ev) { ev.preventDefault(); var data = ev.dataTransfer.getData("text"); ev.target.appendChild(document.getElementById(data));} </script> </head> <body> <h2>Drag and Drop</h2> <p>Drag the image back and forth between the two div elements.</p> <div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)"> <img src="https://www.autoitscript.com/forum/uploads/monthly_2016_01/Chimp.jpg.688f81fa865450e2913b5dc2cb56215f.thumb.jpg.96a6bfa47c0fb8476f39aaf55ad68ed0.jpg" draggable="true" ondragstart="drag(event)" id="drag1" width="214" height="214"> </div> <div id="div2" ondrop="drop(event)" ondragover="allowDrop(event)"></div> </body> </html> #ce;HTML ;  
    • timmy2
      By timmy2
      The following demo script, drawn largely from examples by @UEZ, lets me display colored text over a transparent background using my choice of font, type size, etc.  It is a single function (out of many) in the project I'm scripting, but it is crucial to my goal of displaying messages in an interesting way (IMHO).  
      (For the purpose of this forum post it displays a single string variable; my actual project script reads a number of  possible messages from a text file into an array and then chooses the messages to be displayed based on stuff that happens in the course of someone using my program.)
      Note that I am seeking help only to overcome my inability to figure out how to display this text atop a PNG graphic, and make the result a draggable object.
       
      #cs Display a message one character at a time with the goal of adding a PNG graphic overlay #ce ;~ #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <GUIConstants.au3> Global $sMessage Global $iString = 0 Global $aInfo Global Const $SC_DRAGMOVE = 0xF012 HotKeySet("{Esc}","Close") ; in my actual script I read in a file containing all the text to be displayed Global $sText = _ "Lorem ipsum dolor sit amet, consectetur" & @CRLF & _ "elit, sed do eiusmod tempor incididunt ut" & @CRLF & _ @CRLF & _ "Et dolore magna aliqua. Ut enim ad minim," & @CRLF & _ "quis nostrud exercitation ullamco laboris nisi" & @CRLF & _ "aliquip ex ea commodo consequat." & @CRLF & _ @CRLF & _ "Duis aute irure dolor in reprehenderit in" & @CRLF & _ "voluptate velit esse cillum dolore eu fugiat" & @CRLF & _ "nulla pariatur." & @CRLF ; Create GUI Global $hGUI = GUICreate("", 450, 340, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) GUISetBkColor(0xFF000000) ; will change background color, which UEZ doesn't use in his example, but then he doesn't want a BG GUISetState(@SW_SHOW) ; Draw a string _GDIPlus_Startup() Global $hBrush = _GDIPlus_BrushCreateSolid(0xFF99ff33) Global $hFormat = _GDIPlus_StringFormatCreate() Global $hFamily = _GDIPlus_FontFamilyCreate("VT323") Global $hFont = _GDIPlus_FontCreate($hFamily, 14, 0) Global $tLayout = _GDIPlus_RectFCreate(20, 20, 0, 0) Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global $hBitmap = _GDIPlus_BitmapCreateFromScan0(420, 300) Global $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetTextRenderingHint($hBuffer, 4) _GDIPlus_GraphicsSetSmoothingMode($hBuffer, 4) GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") For $iString = 1 to StringLen($sText) $sMessage = StringLeft($sText,$iString) $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sMessage, $hFont, $tLayout, $hFormat) _GDIPlus_GraphicsClear($hBuffer, 0x000000) _GDIPlus_GraphicsDrawStringEx($hBuffer, $sMessage, $hFont, $aInfo[0], $hFormat, $hBrush) $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _WinAPI_BitmapDisplayTransparentInGUI($hHBitmap, $hGUI) _WinAPI_DeleteObject($hHBitmap) Next Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Close() ; Clean up resources (my best guess at what needs closing/shutting down) Func Close() _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hBitmap) _GDIPlus_Shutdown() Exit EndFunc ;==>Close Func _WinAPI_BitmapDisplayTransparentInGUI(ByRef $hHBitmap, ByRef $hGUI, $iOpacity = 0xFF, $bReleaseGDI = True) If Not BitAND(GUIGetStyle($hGUI)[1], $WS_EX_LAYERED) = $WS_EX_LAYERED Then Return SetError(1, 0, 0) Local $tDim = DllStructCreate($tagBITMAP) If Not _WinAPI_GetObject($hHBitmap, DllStructGetSize($tDim), DllStructGetPtr($tDim)) Then Return SetError(2, 0, 0) Local $tSize = DllStructCreate($tagSIZE), $tSource = DllStructCreate($tagPOINT), $tBlend = DllStructCreate($tagBLENDFUNCTION) Local Const $hScrDC = _WinAPI_GetDC(0), $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC), $hOld = _WinAPI_SelectObject($hMemDC, $hHBitmap) $tSize.X = $tDim.bmWidth $tSize.Y = $tDim.bmHeight $tBlend.Alpha = $iOpacity $tBlend.Format = 1 _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, DllStructGetPtr($tSize), $hMemDC, DllStructGetPtr($tSource), 0, DllStructGetPtr($tBlend), $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteDC($hMemDC) If $bReleaseGDI Then _WinAPI_DeleteObject($hHBitmap) Return True EndFunc Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) Switch $hWnd Case $hGUI _SendMessage($hWnd, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndSwitch EndFunc ;==>_WM_LBUTTONDOWN  
      The above script lets me push the text out to the screen, but I want to display the text atop a PNG graphic, which is an imagined piece of hand-held test equipment that I'll refer to here as the Veeblefetzer.
      Here's a half-size animated gif of the desired result.

       
      Note that initially I used a different script to stream the text out atop a built-in black background rectangle.  I figured I would place the Veeblefetzer graphic above the text -- with the center "display area" of the Veeblefetzer cut out (transparent).  
      Then UEZ's example script came along. The benefit of using text that has a transparent BG, and placing it in a layer above the Veeblefetzer, is this lets me include reflections in the Veeblefetzer's display.
      Now to the challenges I'm ill-equipped to figure out.  
      The function I use to display the Veeblefetzer is below. It, too, is drawn from some of examples by @UEZ.
      There are actually two functions below, one I use to display the PNG graphic, and one that can be used to fade the graphic in or out.  I include it here only because it might be applicable to my ancillary goal of needing to clear the text on the handheld display before streaming the next message onto the Veeblefetzer's display.  I realize that the fade in/out function is for graphic objects, so it may not be applicable to text. 
       
      ; Display the image at center unless otherwise specified. If Fader will not be used then $iAlpha's default of 0xFF is good. ; If Fader will be used then start with $iAlpha equal to zero. Option to make this image "Always on top" is also available. Func DisplayImage($sFile, $iPosX = -1, $iPosY = -1, $iAlpha = 0xFF, $bTopmost = True) Local Const $hBmp_Background = _GDIPlus_BitmapCreateFromFile($sFile) ;load the image If @error Then Return SetError(1, 0, 0) ;image cannot be loaded Local Const $iW = _GDIPlus_ImageGetWidth($hBmp_Background), $iH = _GDIPlus_ImageGetHeight($hBmp_Background) ;get the dimension of the background image Local Const $hGUI = GUICreate("", $iW, $iH, $iPosX, $iPosY, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST * $bTopmost, $WS_EX_TOOLWINDOW)) ;create GUI with appropriate styles and extented style (borderless transparent GUI) GUICtrlCreateLabel("", 0, 0, $iW, $iH, Default, $GUI_WS_EX_PARENTDRAG) ;create a hidden label for GUI dragging GUISetState(@SW_SHOW, $hGUI) ;show GUI Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) ;define an empty bitmap where all the gfx stuff will copied to Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;get the context to the bitmap to be able to copy / draw to the bitmap _GDIPlus_GraphicsDrawImageRect($hGfx, $hBmp_Background, 0, 0, $iW, $iH) ;draw background image to the empty bitmap ;display GDI+ with transparency on desktop Local Const $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) ;convert GDI+ image to GDI to display it on the screen using GDI functions Local Const $hScrDC = _WinAPI_GetDC($hGUI) ;get the device context (dc) handle of the GUI Local Const $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) ;create a compatible dc handle Local Const $hOld = _WinAPI_SelectObject($hMemDC, $hHBitmap) ;selects the GDI bitmap object into the specified device context Local Const $tSize = DllStructCreate($tagSIZE) ;create a $tagSIZE struct (x = width, y = height) DllStructSetData($tSize, "X", $iW) ;set data for width DllStructSetData($tSize, "Y", $iH) ;set data for height Local $tSource = DllStructCreate($tagPOINT) ;create a $tagPOINT struct (x = x position, y = y position) Local $tBlend = DllStructCreate($tagBLENDFUNCTION) ;create $tagBLENDFUNCTION struct -> see help file for more info DllStructSetData($tBlend, "Alpha", $iAlpha) ;set the alpha channel of the GUI -> 255 = opaque, 0 = transparent DllStructSetData($tBlend, "Format", 1) ;set the format to 1 -> bitmap has alpha channels DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $hGUI, "handle", $hScrDC, "ptr", 0, "struct*", $tSize, "handle", $hMemDC, "struct*", $tSource, "dword", 0, "struct*", $tBlend, "dword", $ULW_ALPHA) ;display bitmap on screen ;release resources otherwise memory will filled up (memory leak) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_BitmapDispose($hBitmap) Local $aResource[7] = [$hGUI, _ ;GUI handle $hScrDC, _ ;device context (dc) handle of the GUI (GDI) $hHBitmap, _ ;GDI bitmap handle of the displayed image $hMemDC, _ ;compatible dc handle from $hScrDC $tBlend, _ ;tBlend struct (source blend oper., flags, alpha value, format) -> see help file for description $tSize, _ ;tSize struct (width and height of the window / image) $tSource] ;tSource struct for x / y position of the GUI Return $aResource ;returns the handles to release it later or to use it for fading effects EndFunc ;==>DisplayImage ; This function releases the resources of a specific image and closes it Func ReleaseResources(ByRef $aResource) If Not IsArray($aResource) Then Return SetError(1, 0, 0) If UBound($aResource) <> 7 Then Return SetError(2, 0, 0) _WinAPI_ReleaseDC($aResource[0], $aResource[1]) _WinAPI_DeleteDC($aResource[3]) _WinAPI_DeleteObject($aResource[2]) GUIDelete($aResource[0]) EndFunc ;==>ReleaseResources ; To fade in an image leave $bIn at default (True); to fade out specify False. ; There are also options to set the ending transparency level (0 transparent, 255 opaque), speed and delay. ; If you change the speed or delay be sure to specify $bIn and $iTrans, otherwise you'll wonder why the fade-in or out isn't what you hoped for. ; The default values are specified in the function below. Func _Fader($res1, $bIn = True, $iTrans = 255, $speed = 3, $delay = 10 ) If Not IsArray($res1) Then Return SetError(1, 0, 0) If UBound($res1) <> 7 Then Return SetError(2, 0, 0) Switch $bIn Case True For $a = 0 To $iTrans Step $speed DllStructSetData($res1[4], "Alpha", $a) DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $res1[0], "handle", $res1[1], "ptr", 0, "struct*", $res1[5], "handle", $res1[3], "struct*", $res1[6], "dword", 0, "struct*", $res1[4], "dword", $ULW_ALPHA) ;display bitmap on screen Sleep($delay) Next Case Else For $a = $iTrans To 0 Step -$speed DllStructSetData($res1[4], "Alpha", $a) DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $res1[0], "handle", $res1[1], "ptr", 0, "struct*", $res1[5], "handle", $res1[3], "struct*", $res1[6], "dword", 0, "struct*", $res1[4], "dword", $ULW_ALPHA) ;display bitmap on screen Sleep($delay) Next EndSwitch EndFunc ;==>_FadeIn  
      Is anyone willing to step in and show me how to use the text display function along with the PNG display function, so that the resulting Veeblefetzer will be a single draggable object on screen?
      I'm equally baffled about how to properly clear off one message before displaying the next.
      The reason?   I have only the most rudimentary grasp of the commands within -- or the relationships between -- what seem like three distinct sections common to each of UEZ's scripts:
      Initialization (which defines a number of attributes, some of which are obvious to me, for text in this case)
      _GDIPlus_Startup() Global $hBrush = _GDIPlus_BrushCreateSolid(0xFF99ff33) Global $hFormat = _GDIPlus_StringFormatCreate() Global $hFamily = _GDIPlus_FontFamilyCreate("VT323") Global $hFont = _GDIPlus_FontCreate($hFamily, 14, 0) Global $tLayout = _GDIPlus_RectFCreate(20, 20, 0, 0) Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global $hBitmap = _GDIPlus_BitmapCreateFromScan0(420, 300) Global $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetTextRenderingHint($hBuffer, 4) _GDIPlus_GraphicsSetSmoothingMode($hBuffer, 4)  
      Delivery... (apparently what's needed to display the text)
      $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sMessage, $hFont, $tLayout, $hFormat) _GDIPlus_GraphicsClear($hBuffer, 0x000000) _GDIPlus_GraphicsDrawStringEx($hBuffer, $sMessage, $hFont, $aInfo[0], $hFormat, $hBrush) $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _WinAPI_BitmapDisplayTransparentInGUI($hHBitmap, $hGUI) _WinAPI_DeleteObject($hHBitmap) Even at my primitive level of understanding I have figured out that you can reuse the above "delivery" section to display other strings before proceeding to the next section.
       
      Cleanup... (apparently needed to release resources, which to me is like closing a previously opened file: it's part of the process so I'll do it):
      _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hBitmap) _GDIPlus_Shutdown()  
      (You're getting an inside look at a monkey brain at work here!)
      UEZ's script to display the PNG graphic follows a similar pattern. What I cannot figure out is how to merge the two scripts, while avoiding redundancy and conflicts. To clear the text between messages must I release any resources, and if so: which ones? AND, how do I group the PNG graphic with the text so the resulting "object" can be moved around on the screen?
       
       
    • timmy2
      By timmy2
      After UEZ helped me with the Countdown Timer his techniques seemed perfect for displaying individual images with transparency. One thing led to another and here's the resulting script.
      Download the attached zip file and place the 5 PNG files in the same folder as this script. I did not embed the images in the script, to make the script easier to read and so you can see the actual images used.
      In my opinion the ultimate next step would be to add the ability to play animated GIFs, still with transparency if that's possible.
      Enjoy! (with much gratitude to UEZ for his help)
      ; Functions coded by UEZ 2013-10-29 ; Updated to address issues 2013-10-31 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #NoTrayIcon _GDIPlus_Startup() ;initiate GDI+ #region ; timmy2's simple demonstration of UEZ's code ; ; display blank chalkboard (there will be no fade-in so use default $iAlpha value of 255) $aRes1 = DisplayImage( "Wood-framed-chalkboard.png", -1, -1 ) Sleep (500) ; add first two steps $aRes2 = DisplayImage("step-1.png", -1, -1 ) Sleep(2000) $aRes3 = DisplayImage("step-2.png", -1, -1 ) ; fade in handdrawn circle (therefore start with $iAlpha = 0) $aPos = WinGetPos($aRes1[0]) ;required because the chalkboard is displayed at screen center, which varies based on resolution (doh!) $aRes4 = DisplayImage("circle.png", $aPos[0] + 290, $aPos[1] + 75, 0) sleep (500) _Fader($aRes4) sleep(1000) _Fader($aRes4, False) ReleaseResources($aRes4) sleep(500) ; add third step $aRes5 = DisplayImage("step-3.png", -1, -1 ) Sleep(2000) ; fade the three steps out in reverse order (faster than defaults) _Fader($aRes5, False, 255, 5, 5) ReleaseResources($aRes5) _Fader($aRes3, False, 255, 5, 5) ReleaseResources($aRes3) _Fader($aRes2, False, 255, 5, 5) ReleaseResources($aRes2) Sleep(500) ; fade out chockboard _Fader($aRes1, False, 255, 10, 5) ReleaseResources($aRes1) #endregion _GDIPlus_Shutdown() Exit ; Display the image at center unless otherwise specified. If Fader will not be used then $iAlpha's default of 0xFF is good. ; If Fader will be used then start with $iAlpha equal to zero. Option to make this image "Always on top" is also available. Func DisplayImage($sFile, $iPosX = -1, $iPosY = -1, $iAlpha = 0xFF, $bTopmost = True) Local Const $hBmp_Background = _GDIPlus_BitmapCreateFromFile($sFile) ;load the image If @error Then Return SetError(1, 0, 0) ;image cannot be loaded Local Const $iW = _GDIPlus_ImageGetWidth($hBmp_Background), $iH = _GDIPlus_ImageGetHeight($hBmp_Background) ;get the dimension of the background image Local Const $hGUI = GUICreate("", $iW, $iH, $iPosX, $iPosY, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST * $bTopmost, $WS_EX_TOOLWINDOW)) ;create GUI with appropriate styles and extented style (borderless transparent GUI) GUICtrlCreateLabel("", 0, 0, $iW, $iH, Default, $GUI_WS_EX_PARENTDRAG) ;create a hidden label for GUI dragging GUISetState(@SW_SHOW, $hGUI) ;show GUI Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) ;define an empty bitmap where all the gfx stuff will copied to Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;get the context to the bitmap to be able to copy / draw to the bitmap _GDIPlus_GraphicsDrawImageRect($hGfx, $hBmp_Background, 0, 0, $iW, $iH) ;draw background image to the empty bitmap ;display GDI+ with transparency on desktop Local Const $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) ;convert GDI+ image to GDI to display it on the screen using GDI functions Local Const $hScrDC = _WinAPI_GetDC($hGUI) ;get the device context (dc) handle of the GUI Local Const $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) ;create a compatible dc handle Local Const $hOld = _WinAPI_SelectObject($hMemDC, $hHBitmap) ;selects the GDI bitmap object into the specified device context Local Const $tSize = DllStructCreate($tagSIZE) ;create a $tagSIZE struct (x = width, y = height) DllStructSetData($tSize, "X", $iW) ;set data for width DllStructSetData($tSize, "Y", $iH) ;set data for height Local $tSource = DllStructCreate($tagPOINT) ;create a $tagPOINT struct (x = x position, y = y position) Local $tBlend = DllStructCreate($tagBLENDFUNCTION) ;create $tagBLENDFUNCTION struct -> see help file for more info DllStructSetData($tBlend, "Alpha", $iAlpha) ;set the alpha channel of the GUI -> 255 = opaque, 0 = transparent DllStructSetData($tBlend, "Format", 1) ;set the format to 1 -> bitmap has alpha channels DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $hGUI, "handle", $hScrDC, "ptr", 0, "struct*", $tSize, "handle", $hMemDC, "struct*", $tSource, "dword", 0, "struct*", $tBlend, "dword", $ULW_ALPHA) ;display bitmap on screen ;release resources otherwise memory will filled up (memory leak) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_BitmapDispose($hBitmap) Local $aResource[7] = [$hGUI, $hScrDC, $hHBitmap, $hMemDC, $tBlend, $tSize, $tSource] ;return the handle to release it later Return $aResource EndFunc ;==>DisplayImage ; This function releases the resources of a specific image and closes it Func ReleaseResources(ByRef $aResource) If Not IsArray($aResource) Then Return SetError(1, 0, 0) If UBound($aResource) <> 7 Then Return SetError(2, 0, 0) _WinAPI_ReleaseDC($aResource[0], $aResource[1]) _WinAPI_DeleteDC($aResource[3]) _WinAPI_DeleteObject($aResource[2]) GUIDelete($aResource[0]) EndFunc ;==>ReleaseResources ; To fade in an image leave $bIn at default (True); to fade out specify False. ; There are also options to set the ending transparency level (0 transparent, 255 opaque), speed and delay. ; If you change the speed or delay be sure to specify $bIn and $iTrans, otherwise you'll wonder why the fade-in or out isn't what you hoped for. ; The default values are specified in the function below. Func _Fader($res1, $bIn = True, $iTrans = 255, $speed = 3, $delay = 10 ) If Not IsArray($res1) Then Return SetError(1, 0, 0) If UBound($res1) <> 7 Then Return SetError(2, 0, 0) Switch $bIn Case True For $a = 0 To $iTrans Step $speed DllStructSetData($res1[4], "Alpha", $a) DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $res1[0], "handle", $res1[1], "ptr", 0, "struct*", $res1[5], "handle", $res1[3], "struct*", $res1[6], "dword", 0, "struct*", $res1[4], "dword", $ULW_ALPHA) ;display bitmap on screen Sleep($delay) Next Case Else For $a = $iTrans To 0 Step -$speed DllStructSetData($res1[4], "Alpha", $a) DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $res1[0], "handle", $res1[1], "ptr", 0, "struct*", $res1[5], "handle", $res1[3], "struct*", $res1[6], "dword", 0, "struct*", $res1[4], "dword", $ULW_ALPHA) ;display bitmap on screen Sleep($delay) Next EndSwitch EndFunc ;==>_FadeIn #region GDI and GDI+ functions Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iPixelFormat = $GDIP_PXF32ARGB, $iStride = 0, $pScan0 = 0) Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[6] EndFunc ;==>_GDIPlus_BitmapCreateFromScan0 #endregion GDI and GDI+ functions images.zip