explorerpl

Adobe AIR like window

8 posts in this topic

It's been long enough since I started looking for a solution, so I post this with a clear conscious. 

I am developing an application that would render keystrokes and click on the screen, much like KeyCastr on Mac OS. I did this once in the past. Back then I faced with the same problem - making a nice semitransparent window. I solved it by using Adobe AIR for the interface and Visual Basic for the data. VB was the server capturing the keystrokes and mouse events and passing them via TCP over localhost to Adobe AIR (compiled to exe). This solution worked quite ok. I even tried reviving it few hours before posting it with no success.

Important note - this is NOT a keylogger, though it shares some core functionality with such application. I do not ask for tips on capturing keyboards events (though if someone could post something useful I'd be grateful). 

These are some posts that I've found on the forum:
https://www.autoitscript.com/forum/topic/137618-two-questions-about-layered-gui/#comment-963975
https://www.autoitscript.com/forum/topic/102961-multiple-png-images-as-gui-elements/
https://www.autoitscript.com/forum/topic/47651-png-as-gui-drop-shadows-curved-edges-you-name-it/
https://www.autoitscript.com/forum/topic/102920-advanced-gui-udf-design/
https://www.autoitscript.com/forum/topic/157841-gui-fun/#comment-1144334
https://www.autoitscript.com/forum/topic/140053-just-the-text/#comment-983400
and even more...

The reason for not using an existing application is that there aren't many for windows, they look ugly, and they do not behave the way I need them too.

I've tried these approaches, but I'm either to stupid to understand them fully or I'm simply missing something. The main problem that I'm having is having the window transparent and displaying a label with text on top of it. As you know regular controls will not be transparent. I figured out that making a child window (transparent) on top of the parent transparent window might be the solution (I figured it out myself before finding some posts about it so I'm pretty proud of myself :)). Still... even if I do so the text is not anti-aliased and simply looks ugly.

I could really use an example code that creates a window that has a PNG as a background with a nice label on top that has drop shadow (two labels? one black for the shadow and one white for the text). The window should also be dragable with a mouse.

Here's a video with my old app running (start watching from 0:50)https://www.youtube.com/watch?v=C7fSpZntpfA
Here's a similar application called KeyPose: http://jungsbluth.de/magnus/blog/keypose/keypose.html

At some point I thought I'd just create a flash object on my window and make it transparent (I've seen this done even back in Windows 98). The difficulty here is that it's not a binary transparency, but a 32bpc one - real, smooth alpha channel like in a PNG, which is what most of the code I've seen is doing. Unfortunately I wasn't able to check that code, because I fail to create the Shockwave.Shockwave.11 object. I've installed the Flash player and the Shockwave player manually, registered the OCX, but no success.

TL;DR

Honestly - the solution to all my problems and problems other users are having would be replicating the behavior of such apps, that take an SWF and make a windowless EXE out of them. Just take a look at the attached file. Please note that the BG is semi-transparent, the labels are anti-aliased with a drop shadow. This is my old solution using Adobe AIR (Flash). I'd like to replicate that as closely as possible.

I really hope some good soul will help me with this.
Thank you.

 

screen.png

Share this post


Link to post
Share on other sites



explorerpl,

I do not ask for tips on capturing keyboards events (though if someone could post something useful I'd be grateful). 

Good, because if the thread does stray into that area it will be closed - and anyone posting such code will be sanctioned.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

Good, because if the thread does stray into that area it will be closed - and anyone posting such code will be sanctioned.

I've noticed :) I fully understand the policy, though hooking into system events is a valid programming skill and it would be nice to have some examples and have them stripped out of "keylogging" functionality but have them close enough so that a smart person can figure it out. Still - that wouldn't help me :) I'm not that smart, that's why I need help, but not with keylogging. I'm solving one problem at a time :)

The solution to my problem (which essentially is creating a nice antialiased text on transparent background) seems so close with all the examples on the forum, yet I can't figure it out. Examples I've seen use a binary transparency (based on one color) which causes nasty edges. 8 bit transparency like with PNG and Layered Windows) use PNG's and that's great, but doesn't help me either.

At some point I was thinking about painting the PNG "in memory" (no files required) and then passing the resulting image as a "fake PNG" to use along with the Layered Windows examples. Again - this is to complex for my brain.

As for Adobe AIR it seems this is exactly what they are doing to create these nice transparent windows. How else could they do that? There's no single color to be set as transparent, the SWF that is being displayed can be anything and it works. If someone could figure out how to do that we all would be saved and eternaly happy creating out GUIs in Adobe Flash, publish them to SWF, and then put them in out AutoIt apps.

But again... The bottom line is that I need a nice antialiased text, with a shadow, on a semi transparent window with rounded corners.

Anyone?

Share this post


Link to post
Share on other sites

Ok. I think I'm done. I've seen people asking for good keyboard and mouse hooks UDF's, but due to forum policy such a thing (especially a keyboard hook) would constitute a KeyLogger. Just as mentioned above in this thread my project is NOT a keylogger though it shares many of such application characteristics. 

Would it be ok if I posted my compiled project so that others could also use it instead of a keylogger UDF? The app sends what it captures to localhost over TCP connection. No source code.

Share this post


Link to post
Share on other sites

explorerpl,

Would it be ok if I posted my compiled project so that others could also use it instead of a keylogger UDF? The app sends what it captures to localhost over TCP connection. No source code.

You are joking? At least I do hope so. There is no way can you post something that.

M23 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

Just wanted to make sure :) It's somewhat strange to me that while there are examples in the AutoIt documentation on how to do global keyboard hookds it's not considered ethical to post usage of that on the forum. But whatever you say. Don't want to piss anyone off. :)

Share this post


Link to post
Share on other sites

Here something similar which I had created in the past without text and buttons:

;coded by UEZ 2013

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>

Global Const $SC_DRAGMOVE = 0xF012
Global Const $iW = 300, $iH = 200
_GDIPlus_Startup()

                            ;text                           x       y           text color      font                font size
Global $aText[6][6] = [ [   "Windows Translucent GUI",      10,     12,         0xFFFFFFFF,     "Arial",            18          ], _
                        [   "Connection port:",             10,     80,         0xFFFFFFFF,     "Arial",            11          ], _
                        [   "80",                           150,    80,         0xFFFFFFFF,     "Arial",            11          ], _
                        [   "Connection status:",           10,     100,        0xFFFFFFFF,     "Arial",            11          ], _
                        [   "offline",                      150,    100,        0xFFFF8080,     "Arial",            12          ], _
                        [   "Coded by UEZ 2015 ;-)",        10,     150,        0xFFFFFFFF,     "Comic Sans MS",    15          ]]

                            ;   x       y       w       h       bmp handle
Global $aButtons[2][5] = [  [   230,    150,    24,     24,     _GDIPlus_BitmapCreateFromMemory(_Nok2_24x24png())       ], _
                            [   260,    150,    24,     24,     _GDIPlus_BitmapCreateFromMemory(_Ok2_24x24png())        ]]

Global Const $hGUI = GUICreate("", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_LAYERED) ;must be set before _GDIPlus_CreateCurvedTranslucentPanel
Global Const $aReturn = _GDIPlus_CreateCurvedTranslucentPanel($aText, $aButtons, 0xE04576B2, 0x509FBADC, $iW, $iH)
GUISetState()

_WinAPI_BitmapSetTransparent($hGUI, $aReturn[0])

GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")

Do
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            _GDIPlus_BitmapDispose($aReturn[0])
            _GDIPlus_Shutdown()
            GUIDelete($hGUI)
            Exit
        Case $aReturn[1] ;cancel
            MsgBox(0, "Info", "Cancel was pressed")
        Case $aReturn[2] ;ok
            MsgBox(0, "Info", "Ok was pressed")
    EndSwitch
Until False


Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
EndFunc   ;==>_WM_LBUTTONDOWN

Func _GDIPlus_CreateCurvedTranslucentPanel($aText, $aButtons, $iColorBG, $iColorFrame, $iW, $iH, $iRadiusCorner = 20, $bTextShadow = True) ;build 2015-11-03 by UEZ
    Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local Const $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hCtxt, 2)
    _GDIPlus_GraphicsSetInterpolationMode($hCtxt, 7)
    _GDIPlus_GraphicsSetPixelOffsetMode($hCtxt, 2)
    _GDIPlus_GraphicsSetTextRenderingHint($hCtxt, 5)

    Local Const $hPath = _GDIPlus_PathCreate()
    Local Const $hPath_Shape = _GDIPlus_PathCreate()

    Local $iPenSize = 2

    _GDIPlus_PathAddArc($hPath, $iW - ($iRadiusCorner * 2), 0, $iRadiusCorner * 2, $iRadiusCorner * 2, 270, 90)
    _GDIPlus_PathAddArc($hPath, $iW - ($iRadiusCorner * 2), $iH - ($iRadiusCorner * 2), $iRadiusCorner * 2, $iRadiusCorner * 2, 0, 90)
    _GDIPlus_PathAddArc($hPath, 0, $iH - ($iRadiusCorner * 2), $iRadiusCorner * 2, $iRadiusCorner * 2, 90, 90)
    _GDIPlus_PathAddArc($hPath, 0, 0, $iRadiusCorner * 2, $iRadiusCorner * 2, 180, 90)
    _GDIPlus_PathCloseFigure($hPath)

    Local $iColorBG2 = BitAND(0xFF000000, $iColorBG) + BitAND(0x00FF0000, $iColorBG) - 0x200000 + BitAND(0x0000FF00, $iColorBG) - 0x2000 + BitAND(0x000000FF, $iColorBG) - 0x20
    Local $hBrush_Bg = _GDIPlus_LineBrushCreate($iW / 2, 0, $iW / 2, $iH, $iColorBG2, $iColorBG)
    _GDIPlus_GraphicsFillPath($hCtxt, $hPath, $hBrush_Bg)


    Local $hBrush_Shape = _GDIPlus_LineBrushCreate($iW / 2, $iH / 5 + 7, $iW / 2, 0, $iColorFrame, 0xA0FFFFFF)

    _GDIPlus_PathAddArc($hPath_Shape, 0, 0, $iRadiusCorner * 2, $iRadiusCorner * 2, 180, 90)
    _GDIPlus_PathAddArc($hPath_Shape, $iW - ($iRadiusCorner * 2), 0, $iRadiusCorner * 2, $iRadiusCorner * 2, 270, 90)

    _GDIPlus_PathAddLine($hPath_Shape, 0, $iRadiusCorner, 0, $iH / 5)
    _GDIPlus_PathAddLine($hPath_Shape, 0, $iH / 5, $iW / 2, $iH / 5 + 7)
    _GDIPlus_PathAddLine($hPath_Shape, $iW, $iH / 5, $iW, $iRadiusCorner)
    _GDIPlus_PathCloseFigure($hPath_Shape)

    _GDIPlus_GraphicsFillPath($hCtxt, $hPath_Shape, $hBrush_Shape)

    Local $hPen = _GDIPlus_PenCreate(0xF0000000 + $iColorFrame, $iPenSize)
    _GDIPlus_GraphicsDrawPath($hCtxt, $hPath, $hPen)

    _GDIPlus_PathReset($hPath)
    Local $i, $hBrush, $hFamily, $hFormat, $tLayout
    Local $hBrush_Shadow = _GDIPlus_BrushCreateSolid(0xFF101010)
    For $i = 0 To UBound($aText) - 1
        $hBrush = _GDIPlus_BrushCreateSolid($aText[$i][3])  ;color
        $hFamily = _GDIPlus_FontFamilyCreate($aText[$i][4]) ;font
        $hFormat = _GDIPlus_StringFormatCreate()
        _GDIPlus_StringFormatSetAlign($hFormat, 0)  ;alignment
        $tLayout = _GDIPlus_RectFCreate($aText[$i][1] + $aText[$i][5] / 8, $aText[$i][2] + $aText[$i][5] / 8)
        _GDIPlus_PathAddString($hPath, $aText[$i][0], $tLayout, $hFamily, 0, $aText[$i][5], $hFormat)
        _GDIPlus_GraphicsFillPath($hCtxt, $hPath, $hBrush_Shadow)   ;draw shadow
        _GDIPlus_PathReset($hPath)
        $tLayout = _GDIPlus_RectFCreate($aText[$i][1], $aText[$i][2])
        _GDIPlus_PathAddString($hPath, $aText[$i][0], $tLayout, $hFamily, 0, $aText[$i][5], $hFormat)
        _GDIPlus_GraphicsFillPath($hCtxt, $hPath, $hBrush)
        _GDIPlus_PathReset($hPath)
        _GDIPlus_BrushDispose($hBrush)
        _GDIPlus_FontFamilyDispose($hFamily)
        _GDIPlus_StringFormatDispose($hFormat)
    Next

    Local $aReturn[UBound($aButtons) + 1]
    $aReturn[0] = $hBitmap
    For $i = 0 To UBound($aButtons) - 1
        _GDIPlus_GraphicsDrawImageRect($hCtxt, $aButtons[$i][4], $aButtons[$i][0], $aButtons[$i][1], $aButtons[$i][2], $aButtons[$i][3])
        _GDIPlus_ImageDispose($aButtons[$i][4])
        $aReturn[$i + 1] = GUICtrlCreateLabel("", $aButtons[$i][0], $aButtons[$i][1], $aButtons[$i][2], $aButtons[$i][3])
    Next

    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PathDispose($hPath_Shape)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush_Bg)
    _GDIPlus_BrushDispose($hBrush_Shape)
    _GDIPlus_BrushDispose($hBrush_Shadow)
    _GDIPlus_GraphicsDispose($hCtxt)
    Return $aReturn
EndFunc   ;==>_GDIPlus_CreateCurvedTranslucentPanel

Func _WinAPI_BitmapSetTransparent($hGUI, $hImage, $iOpacity = 0xFF)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", 1)
    _WinAPI_UpdateLayeredWindow($hGUI, $hMemDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc   ;==>_WinAPI_BitmapSetTransparent

;Code below was generated by: 'File to Base64 String' Code Generator v1.20 Build 2015-09-19

Func _Nok2_24x24png($bSaveBinary = False, $sSavePath = @ScriptDir)
    Local $Nok2_24x24png
    $Nok2_24x24png &= 'iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAABzpAAAc6QHh0LjlAAAFfUlEQVRIiYWWX2hbVxLGf+dKWDWKrJRYSuLIJVFCtFuZQLsPtpsGTO04pfQp1JSExSkJCwFTSltvk4fmqQ8l7D40gRKHPnm9mBaVFNqH4KQtBTe4gppiGpOVG0qwLNeSLNfXsixfSefOPpwospP9MzDc0WjON/PNnXvOUSLCNhHxoJQLSCmbjS1PTp5ev3nzeO2rrw6rfD4IINGo7T1xYm5HX9/t1hdeGPfv2ZMCFCIWSumtcGpbAtf1YFm6XCjsT4+NfVB5++2BnX19vuCJE/ieeQaPzweVCrpQwEmlsG/eZDWVcpquXk20nzp1qbm19UEd48kEpnKdSyb/vNDVNbLvtdf84fPnRR044CKi2NxUlMuKchkcR3AcoVgUmZuzcqOjKgOlyPj4+XBn5z/rWI0EDx2Z27eHC/39f/vDtWtuU3+/i9YeWV1VamMDNjfBcczzoUqlgtJa2NzUlelp61+JhLVrYuKv+/r7/17HVK7repRSOptMDma7ukY7xsZqVleXJSsrltrYgGrVAJbLjSTlMlQqxl5fN4lc13Xn5927N254d09Nndnd1fUPcV2PEhHK+fyhe+HwdPzy5Rbfyy+7FAoWjmMAbBtqNdAa6kyqVVhdNerzGV+pBOA6v/5qzW5srP3x22//1BwO37cA0onEpbYjR1p8nZ01WVy0sG34/XfI5eC556C5GdJpKBaNzs1BNAqDg3D/Piwvg20j2azlCwRqbbOzLekvvrgEoIqLi/EHbW3J+JUrfnXwoLC6qqhUYG0Nenuho8NUev06/PKLYfHss/DmmxAMwnffwblzsHevSa61SC6nZsPh0v5btzqt5WRyIAh+tWuXlmxWsbYGS0vQ3W3AtYadO+HMGchmTUuGhgy41tDTAx99BHfugOMguZxSgYAOzs76l3/8ccBb+v773vaTJ6FUUsq2zaJ79+DBA2hvN5VpDXv2wMcfg9cLTz9tfB6Pac/XX5tRX1lB5fPg86kgkJ6a6vX8xXEu7z140O956ikoFhUzM/DZZzA9DfPz8OKL0NICIoZJIGBsyzLgFy7AyAhEIoY5wNoaClTW621mBqq1s2dFLlwQOXnSfBWhkEg0auxXXhFJp0VERLQ2KiKyuChy6pSJqcdu0RrITChUtQAz1+k03LgBoRDk843tIxg0rXhcajUoFIxdqTz5f11+OnYs5/T0iDz/vPuogkjEPM+eFcnnTcWuK4+kziKT2c66wcB1QH7q6clx9+LFSduA6m2Bb73VAK/VGm2pt6vuy2RMIVvXRiLaBrl78eKk5e/u/sYGaGoy214gYKgdOwatrdun5b33zIguLRmf1tDWBsePmzWBAALg94sN+Lu7v6GYycR/jsfX3YfUtrXoyy9NlbmcyBtvNFowMGDYiJiYrWt6elz3pZfk51hsvZjJxBERUiMjo7+BSCxWdesgdbqJhMjwcGNa6kBDQyKffrot1n31VZF33qn+BpK6dm304U4tbGSzh6aPHLE3QyGRUEg/8bJDoYZd/731pUYihuGHH+rN11+X6WjU3shmD4kIuFp7RISlqanBGRAdj1clFNKPmESj28Hq4HXf0aPivv++yPXrWr/7bnUGZGlqalBEcLX2ICKI63pEhIWJieEZECca1RKLVQXcR4ke12hU3KEhkU8+cWVsrOoMDekZkIVbt4a3Yv7nI/PcuZF9s7P+cCgkKhBwqVQUoPD7FQcOQEeHcPiwsGOHyPy8lRsfV5mVlVLk88//y5H5+KGfz+9PJxIfVK5eHdiZSvmCgO/oUTzRKOzejfZ6cRYWsCcmWM3nnaYrVxLtp0//n0O/LluvLUtLseVk8vT6nTvHa5OTh9UPP5hrSyxme/v65nb09t5u7e7+n9eWfwNJOhRLmn3GvAAAAABJRU5ErkJggg=='
    Local $bString = _WinAPI_Base64Decode($Nok2_24x24png)
    If @error Then Return SetError(1, 0, 0)
    $bString = Binary($bString)
    If $bSaveBinary Then
        Local Const $hFile = FileOpen($sSavePath & "\Nok2_24x24.png", 18)
        If @error Then Return SetError(2, 0, $bString)
        FileWrite($hFile, $bString)
        FileClose($hFile)
    EndIf
    Return $bString
EndFunc   ;==>_Nok2_24x24png

Func _Ok2_24x24png($bSaveBinary = False, $sSavePath = @ScriptDir)
    Local $Ok2_24x24png
    $Ok2_24x24png &= 'iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAA2IAAANiAGC02DBAAAGHklEQVRIiXWWW29U1xmGn3XYhzns2TNj7zE2G4cYgkU4qOEkhEqlOKqESgQ0JEpx05tK/QO5afoL0tKEi15UipqmqmiqVmlzE6jqUpckqBHCARKbAEbU5TBgPNux8Yzn4Jl96IW5sFNY3826et5X31r63k/wzeMhCQCIGUKzkd108wIptiEoIQHhVWgEE1QYZZIxPiYEJB4QEK/EicfAE4YQPMcruLyOyU5f+8o1izi2w3zjIZNLFXxtgSSiw8Xy7NIJLgQf8DEJHmKlyEoBBUT8CJ9NvIfmu57yk6LtikI6HxnKYGFxTky35rAgQZiYwlBInRgGor7UPFP+YurHnKSMhyIgWikg8YgZZis9nCah37f90LVd4Vh5ZQiD/87fodypLTsXJggDU2oMQaSxEqWVXqJxZ/LmVwd5nysESCCWeMsXjtDPGk4R0z+QGQjdVFE7Vl5ljQyVWkA5rOEbq+EIsFRaKW3qxXgp7FY9/VsGd5ziCP1AjIdUNIADwHb+BOwayA6EWSurXdOhYBdotJtcqt5ado6JKQ3UI3heOVTDBdphi36rT15vToZrrLVFt6uwOYim32cCJJCwlWNIDgxkBqKsldeO4eLaBbQ0uVedxpfLzk1pgFiGd+k8l9rn2ZveyUff/5C//uDP/Hbfr3W5ORN5zpoD/i7/GJAovgds5B3f9td1pUs4piOydpac5XJ//h4PmmW0TmOK1fCxpRu8mjnMLw8fZ4O/gSRJWN+1noWZgLHapOjJeb3lzq33JBvYh2ZPMV0iZznSsbIUU13M1+c4X72BpZ0nwId468hx+rw+6s06rVaLMAppx21pSYNsOr/He9bbJ8nxvG/4upjKx1kzRzHVxcP6PFeDGwzq0mq4sRL+Fn1dfbTaLdpLbSzDYvSrUU7O/gPf6ok1li6Wep+XWGx3zSLFdBHHyvLg4TTXK1cpR1NMRhVSMoMh1LLz1mp4s91kqbWEqUxGxkd4+eLL7HQ2EycxpjTIOe52jaDkGGnanTY3Z6aYbt0laAcMe8MoZXAy+D173f2cb17n1cwQbx95m96uXuqtOp12B0tbjEyMcPTzo7yYP0acxCA0UipMnSppFJQXy5yv/ocBWSRoB7y7512G9w9DAkcuH+LomaO81vcabx56k1KhxMLiAnEUYxv2ajgxUiikVGg0EokGr7KUgK8c2rIDpsfB5w6SslJ0wg6Hdh3ilD7FYO8g3U431VoVANu0GRl/DPxRKaWJk7AiaQXjlloeGq7MQhQwW50l7ITUG3XqzTpDW4bocXuot+pPgIMWCoCUkSZrZACo1RbHJQ85izRDE0MCYHr8YvQ4M/MzWNoiiiOa7SadsAMJy235BhwgTCBnujxb2sTTxfWyE3fCuUr5rOQGnxG2L6A0IcQ7rA38oXqSNz76GV/XvsY2bOI4JkkSbGPFgxaGiZOYmJi0TvFUbi2bugfImJm4E4U8bMxdKE+UP1PchOoOq1kq5I7qRMeRiOQmezOnmxeZvT3FnnV7KGQKaKU4c+WfvPT5S7yYP0aYhGSMLGudXny3j2KmSErbRFEc36rdlV9Ojv10/nfBleXuZxoTqYHM3ozObJLCCGNiudFay+WlG1y79QWyrfj05jl+fu1X7HS+jaUMepw19OV6yNkuljIxpIGpjHC6NquvVSb+fnnk328w5QnxKMVifkL/4Le2f5oT7lMIFSohdVrZ1OI2Y60v8Y11bE0/Q8Fy6c4USBkZDKExlIGlbSxlhpXFOT0+N3H7b5/88Tv8hjt4yNWB80O2bhncfTqv3H6ZyBAhhSVNZeoUWiiKqQJuysVQBqY0sZSFZdiRSGQS1Of01fmrd8YunzkYnAiusDypY/VIICGD4l/MBMX7f8mV8ttSqewzlrQFKJFAtCbXk7ipPKYyElvZsamtRAktG52WuF0r'
    $Ok2_24x24png &= 'q/EHl86Mnv3wcOOdxk08FI3lD/b40N+P8Pf7r5TWPv16Pl3YacuM6koVyBoZtDIRCDpxh4V2LXqwcP/irdvXTkx9MvkB57wEL3hi6K8UAYjZj/a2ebuLfu8LGcfZZqpUSQlJO2pXqtXqxOS9u6OMB2OcIwRP4gX/t7b8DwlNcnxkhYu3AAAAAElFTkSuQmCC'
    Local $bString = _WinAPI_Base64Decode($Ok2_24x24png)
    If @error Then Return SetError(1, 0, 0)
    $bString = Binary($bString)
    If $bSaveBinary Then
        Local Const $hFile = FileOpen($sSavePath & "\Ok2_24x24.png", 18)
        If @error Then Return SetError(2, 0, $bString)
        FileWrite($hFile, $bString)
        FileClose($hFile)
    EndIf
    Return $bString
EndFunc   ;==>_Ok2_24x24png

Func _WinAPI_Base64Decode($sB64String)
    Local $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(1, 0, "")
    Local $bBuffer = DllStructCreate("byte[" & $aCrypt[5] & "]")
    $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $bBuffer, "dword*", $aCrypt[5], "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(2, 0, "")
    Return DllStructGetData($bBuffer, 1)
EndFunc   ;==>_WinAPI_Base64Decode

 


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!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

Wow! Thanks UEZ. Once again you save the day. I have already completed the project using Adobe AIR and AutoIt, but your code will most certainly come in handy. I'm using TCP to get the applications talking, though I can only make a one way connection, but that's luckily enough. Now I'm struggling with an unfortunate memory leak. To bad I can't post the code so that someone could help me with the project. I'm an educator and the tool is designed to show all my keyboard shourcuts and mouse button combinations, but it does without a doubt a keylogger in nature.

Thanks again for your code.

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

    • mdwerne
      By mdwerne
      I'm attempting to cobble together a replacement for the 64bit version of BGInfo that will run within WinPE 10/64. I've located a couple useful threads:
       Between the two, they get me close (see code below), but for some reason GDI+ is not working the same within WinPE as it does in Windows 10. Bottomline is that the "Text" never get's written to WallPaper.
      Here is what I have thus far. Any thoughts if any of the GDI commands might not work within WinPE? Any other way to achieve the same result (system information on the wallpaper in WinPE 10)?
      #include <GDIPlus.au3> #include <Date.au3> _GDIPlus_Startup() $image = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\WallPaper.bmp") $imagegraphics = _GDIPlus_ImageGetGraphicsContext($image) $w = _GDIPlus_ImageGetWidth($image) $h = _GDIPlus_ImageGetHeight($image) $whitebrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) $fontfamily = _GDIPlus_FontFamilyCreate("Arial") $font = _GDIPlus_FontCreate($fontfamily, 16) $stringformat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($stringformat, 2) $rect = _GDIPlus_RectFCreate(0, $h - $h + 100, $w - 25, $h) ;$rect = _GDIPlus_RectFCreate(100, 100, 200, 200) _GDIPlus_GraphicsDrawStringEx($imagegraphics, _Now() & @CRLF & @UserName & @CRLF & @ComputerName & @CRLF & @IPAddress1, $font, $rect, $stringformat, $whitebrush) _GDIPlus_ImageSaveToFile($image, @ScriptDir & "\NewWallPaper.bmp") _GDIPlus_ImageDispose($image) _GDIPlus_GraphicsDispose($imagegraphics) _GDIPlus_BrushDispose($whitebrush) _GDIPlus_FontFamilyDispose($fontfamily) _GDIPlus_FontDispose($font) _GDIPlus_StringFormatDispose($stringformat) _GDIPlus_Shutdown() _ChangeDesktopWallpaper(@ScriptDir & "\NewWallPaper.bmp", 2) Func _ChangeDesktopWallpaper($bmp, $style = 0) ;=============================================================================== ; ; Function Name: _ChangeDesktopWallPaper ; Description: Update WallPaper Settings ; Usage: _ChangeDesktopWallPaper(@WindowsDir & '\' & 'zapotec.bmp',1) ; Parameter(s): $bmp - Full Path to BitMap File (*.bmp) ; [$style] - 0 = Centered, 1 = Tiled, 2 = Stretched ; Requirement(s): None. ; Return Value(s): On Success - Returns 0 ; On Failure - -1 ; Author(s): FlyingBoz ; Thanks: Larry - DllCall Example - Tested and Working under XPHome and W2K Pro ; Excalibur - Reawakening my interest in Getting This done. ; ;=============================================================================== If Not FileExists($bmp) Then Return -1 ;The $SPI* values could be defined elsewhere via #include - if you conflict, ; remove these, or add if Not IsDeclared "SPI_SETDESKWALLPAPER" Logic Local $SPI_SETDESKWALLPAPER = 20 Local $SPIF_UPDATEINIFILE = 1 Local $SPIF_SENDCHANGE = 2 Local $REG_DESKTOP = "HKEY_CURRENT_USER\Control Panel\Desktop" If $style = 1 Then RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 1) RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", 0) Else RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 0) RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", $style) EndIf DllCall("user32.dll", "int", "SystemParametersInfo", _ "int", $SPI_SETDESKWALLPAPER, _ "int", 0, _ "str", $bmp, _ "int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE)) Return 0 EndFunc ;==>_ChangeDesktopWallpaper Thanks for your time,
      -Mike
    • UEZ
      By UEZ
      Here some graphical examples written completely in FreeBasic just for fun.  
      3D Starfield Scrolling v1 Booster 3D Starfield Scrolling v3 Booster GDI - GDI+ 3D Sinus Wave GDI - GDI+ Animated Pythagoras Tree GDI - GDI+ Particles - Repulsive Force Sim v2.0 GDI - GDI+ Plasma v5 Booster GDI - GDI+ Random Pattern GDI - GDI+ Tunnel Flight - WipeOut Style GDI Classic Raytraced Tunnel GDI Elastic Twister Effect GDI Exploding Pixels GDI Liquid Pixels GDI Particle Repulsion Grid GDI Particles Mouse Attraction GDI Starfield GDI The Nautilus Raymarcher GDI+ Performance Test - Au3 vs FB Mandelbrot Rutt_Etra_Izer_Booster  
      Download: FreeBasic Examples build 2017-01-22.7z
      I will add new examples from time to time.
       
      FreeBasic source codes are also included.
       
    • UEZ
      By UEZ
      Here a small function to mark a region on the desktop and capture that region to a bitmap handle or to the clipboard:
      #include-once #include <Clipboard.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WinAPIGdi.au3> #include <WindowsConstants.au3> #Region Example ;capture manual coordinates FileDelete(@ScriptDir & "\Captured.bmp") Global $hHBitmap = _WinAPI_MarkScreenRegionAndCapture(0, False, True, 0, 0, 99, 99) _WinAPI_SaveHBITMAPToFile(@ScriptDir & "\Captured.bmp", $hHBitmap) _WinAPI_DeleteObject($hHBitmap) If FileExists(@ScriptDir & "\Captured.bmp") Then ShellExecute(@ScriptDir & "\Captured.bmp") ;save the captured bitmap to a file FileDelete(@ScriptDir & "\Captured.bmp") Global $hHBitmap = _WinAPI_MarkScreenRegionAndCapture() _WinAPI_SaveHBITMAPToFile(@ScriptDir & "\Captured.bmp", $hHBitmap) _WinAPI_DeleteObject($hHBitmap) If FileExists(@ScriptDir & "\Captured.bmp") Then ShellExecute(@ScriptDir & "\Captured.bmp") ;copy captured bitmap to clipboard Switch _WinAPI_MarkScreenRegionAndCapture(1, True) Case 1 MsgBox($MB_ICONINFORMATION, "Information", "Marked region was properly captured to clipboard!", 30) Case 0 MsgBox($MB_ICONERROR, "ERROR", "An error has occured!", 30) EndSwitch #EndRegion ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WinAPI_MarkScreenRegionAndCapture ; Description ...: Selected area on desktop will be captured and save to clipbord or GDI bitmap handle will be returned. ; Syntax ........: _WinAPI_MarkScreenRegionAndCapture([$iFillMode = 0[, $bClipboard = True]]) ; Parameters ....: $iFillMode - [optional] an integer value. Default is 0. ; 0: marked area filled with solid color ; 1: marked area filled with hatch pattern ($HS_DIAGCROSS) ; 2: marked area without any fill pattern / color - only red border ; $bClipboard - [optional] a boolean value. Default is False. If True then no GDI bitmap handle will be returned. ; If false then GDI bitmap handle will be returned. ; $bManual - [optional] a boolean value. Default is False. If True manual capturing is activated. ; $iX1 - [optional] an integer value. Default is 0. If $bManual is true enter the x1 screen pos. ; $iY1 - [optional] an integer value. Default is 0. If $bManual is true enter the Y1 screen pos. ; $iX2 - [optional] an integer value. Default is 0. If $bManual is true enter the x2 screen pos. ; $iY2 - [optional] an integer value. Default is 0. If $bManual is true enter the y2 screen pos. ; Return values .: 0 / 1 / -1 / GDI bitmap handle ; Author ........: UEZ ; Version .......: 0.92 build 2017-01-22 ; Modified ......: ; Remarks .......: Do not forget to dispose returned GDI bitmap handle for non clipboard mode using _WinAPI_DeleteObject! ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _WinAPI_MarkScreenRegionAndCapture($iFillMode = 0, $bClipboard = False, $bManual = False, $iX1 = 0, $iY1 = 0, $iX2 = 0, $iY2 = 0) If @OSBuild > 6299 Then ;https://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx DllCall("Shcore.dll", "long", "PROCESS_DPI_AWARENESS", 1) ;PROCESS_SYSTEM_DPI_AWARE = 1 (https://msdn.microsoft.com/en-us/library/windows/desktop/dn280512(v=vs.85).aspx) Else DllCall("User32.dll", "bool", "SetProcessDPIAware") EndIf Local $iOld = AutoItSetOption("MouseCoordMode", 1) If Not $bManual Then Local Const $hDesktop = WinGetHandle("[TITLE:Program Manager;CLASS:Progman]") Local Const $aFullScreen = WinGetPos($hDesktop) ;should work also on multi screens Local Const $iW = $aFullScreen[2], $iH = $aFullScreen[3] Local Const $hGUI_Screencapture = GUICreate("", $iW, $iH, $aFullScreen[0], $aFullScreen[1], $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED)) GUISetState(@SW_SHOW, $hGUI_Screencapture) Local Const $hDC = _WinAPI_GetDC($hGUI_Screencapture) Local Const $hGfxDC = _WinAPI_CreateCompatibleDC($hDC) Local Const $hBitmapGDI = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) Local $hObjOld = _WinAPI_SelectObject($hGfxDC, $hBitmapGDI) Local $tSize = DllStructCreate($tagSIZE) $tSize.x = $iW $tSize.y = $iH Local $tSource = DllStructCreate($tagPOINT) Local $tBlend = DllStructCreate($tagBLENDFUNCTION) $tBlend.Alpha = 0xFF $tBlend.Format = 1 Local $tDest = DllStructCreate($tagPOINT), $pPoint = DllStructGetPtr($tDest) $tDest.x = $aFullScreen[0] $tDest.y = $aFullScreen[1] Local Const $hPen = _WinAPI_CreatePen($PS_SOLID, 1, 0x0000FF) Local Const $hPen_Orig = _WinAPI_SelectObject($hGfxDC, $hPen) Local $hBrush, $iAlpha2, $iFlag $iFillMode = $iFillMode > 2 ? 2 : $iFillMode < 0 ? 0 : $iFillMode Switch $iFillMode Case 0 $hBrush = _WinAPI_CreateBrushIndirect($BS_SOLID, 0x808080) $iAlpha2 = 0xA0 $iFlag = $ULW_ALPHA Case 1 $hBrush = _WinAPI_CreateBrushIndirect($BS_HATCHED, 0x808000, $HS_DIAGCROSS) $iAlpha2 = 0x30 $iFlag = $ULW_ALPHA Case 2 $hBrush = _WinAPI_CreateBrushIndirect($BS_HOLLOW, 0x000000) $iAlpha2 = 0xFF ;not needed $iFlag = $ULW_COLORKEY EndSwitch Local $hBrush_Orig = _WinAPI_SelectObject($hGfxDC, $hBrush) Else If Not BitOr($iX1, $iX2, $iY1, $iY2) Then Return SetError(4, 0, 0) EndIf Local $aMPos[5], $aMPos_old[4], $tRECT = _WinAPI_CreateRect(0, 0, 0, 0) Do If $bManual Then $aMPos[2] = 1 Else GUISetCursor(16, 1, $hGUI_Screencapture) $aMPos = GUIGetCursorInfo($hGUI_Screencapture) $aMPos_old[0] = $aMPos[0] $aMPos_old[1] = $aMPos[1] $aMPos_old[2] = MouseGetPos(0) $aMPos_old[3] = MouseGetPos(1) EndIf Switch $aMPos[2] Case 0 ;display crosshair _WinAPI_BitBlt($hGfxDC, 0, 0, $iW, $iH, $hGfxDC, 0, 0, $CAPTUREBLT) _WinAPI_DrawLine($hGfxDC, $tDest.x, $aMPos[1], $iW, $aMPos[1]) _WinAPI_DrawLine($hGfxDC, $aMPos[0], $tDest.y, $aMPos[0], $iH) _WinAPI_UpdateLayeredWindow($hGUI_Screencapture, $hDC, $tDest, $tSize, $hGfxDC, $tSource, 0, $tBlend, $ULW_COLORKEY) Case 1 ;capture selected region If Not $bManual Then $tBlend.Alpha = $iAlpha2 While $aMPos[2] ;mark region GUISetCursor(14, 1, $hGUI_Screencapture) ;WinGetHandle(AutoItWinGetTitle())) $aMPos = GUIGetCursorInfo($hGUI_Screencapture) _WinAPI_BitBlt($hGfxDC, 0, 0, $iW, $iH, $hGfxDC, 0, 0, $CAPTUREBLT) ;clear bitmap ;draw rectangle $tRECT.Left = $aMPos_old[0] $tRECT.Top = $aMPos_old[1] $tRECT.Right = $aMPos[0] $tRECT.Bottom = $aMPos[1] _WinAPI_Rectangle($hGfxDC, $tRECT) If $iFillMode <> 2 Then _WinAPI_InvertRect($hGfxDC, $tRECT) _WinAPI_UpdateLayeredWindow($hGUI_Screencapture, $hDC, $tDest, $tSize, $hGfxDC, $tSource, 0, $tBlend, $iFlag) Sleep(10) WEnd _WinAPI_SelectObject($hGfxDC, $hObjOld) _WinAPI_ReleaseDC($hGUI_Screencapture, $hDC) _WinAPI_DeleteDC($hGfxDC) _WinAPI_DeleteObject($hBitmapGDI) _WinAPI_SelectObject($hGfxDC, $hPen_Orig) _WinAPI_DeleteObject($hPen) _WinAPI_SelectObject($hGfxDC, $hBrush_Orig) _WinAPI_DeleteObject($hBrush) GUIDelete($hGUI_Screencapture) ;capture region $aMPos[0] = MouseGetPos(0) $aMPos[1] = MouseGetPos(1) Else $aMPos_old[2] = $iX1 $aMPos_old[3] = $iY1 $aMPos[0] = $iX2 $aMPos[1] = $iY2 EndIf Local Const $hDC_Region = _WinAPI_GetDC(0) Local Const $hMemDC = _WinAPI_CreateCompatibleDC($hDC_Region) Local Const $iW_Region = Abs($aMPos[0] - $aMPos_old[2]) + 1, $iH_Region = Abs($aMPos[1] - $aMPos_old[3]) + 1 Local $hHBitmap_Captured = _WinAPI_CreateCompatibleBitmap($hDC_Region, $iW_Region, $iH_Region) $hObjOld = _WinAPI_SelectObject($hMemDC, $hHBitmap_Captured) _WinAPI_BitBlt($hMemDC, 0, 0, $iW_Region, $iH_Region, $hDC_Region, _ $aMPos[0] > $aMPos_old[2] ? $aMPos_old[2] : $aMPos[0], _ $aMPos[1] > $aMPos_old[3] ? $aMPos_old[3] : $aMPos[1], BitOR($SRCCOPY, $CAPTUREBLT)) Local $hHBitmap_Clipboard = _WinAPI_CopyImage($hHBitmap_Captured, 0, 0, 0, BitOR($LR_COPYDELETEORG, $LR_COPYRETURNORG)) _WinAPI_SelectObject($hHBitmap_Captured, $hObjOld) _WinAPI_DeleteDC($hHBitmap_Captured) _WinAPI_ReleaseDC(0, $hDC_Region) AutoItSetOption("MouseCoordMode", $iOld) If $bClipboard Then ;put captured region to clipboard If Not _ClipBoard_Open(0) Then _WinAPI_DeleteObject($hHBitmap_Clipboard) Return SetError(1, 0, 0) EndIf If Not _ClipBoard_Empty() Then _WinAPI_DeleteObject($hHBitmap_Clipboard) Return SetError(2, 0, 0) EndIf Local Const $hCP = _ClipBoard_SetDataEx($hHBitmap_Clipboard, $CF_BITMAP) If Not $hCP Or @error Then _WinAPI_DeleteObject($hHBitmap_Clipboard) Return SetError(3, 0, 0) EndIf _ClipBoard_Close() _WinAPI_DeleteObject($hHBitmap_Clipboard) Return 1 Else Return $hHBitmap_Clipboard EndIf EndSwitch Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _WinAPI_SelectObject($hGfxDC, $hObjOld) _WinAPI_ReleaseDC($hGUI_Screencapture, $hDC) _WinAPI_DeleteDC($hGfxDC) _WinAPI_DeleteObject($hBitmapGDI) _WinAPI_SelectObject($hGfxDC, $hPen_Orig) _WinAPI_DeleteObject($hPen) GUIDelete($hGUI_Screencapture) AutoItSetOption("MouseCoordMode", $iOld) Return -1 EndSwitch Until False EndFunc ;==>_WinAPI_MarkScreenRegionAndCapture Might be useful...
       
      Download:  _WinAPI_MarkScreenRegionAndCapture.au3  (same as above in the code box)
       
      Tested only on Win10 x64 but should work also on other Window versions. If not please reply.
       
    • UEZ
      By UEZ
      As requested by @Lakes here:
      GDI and GDI+ versions of 3D Sinus Wave. GDI ≠ GDI+!
       
      GDI:
      ;coded by UEZ build 2017-01-18 #pragma compile(Icon, "c:\Program Files (x86)\AutoIt3\Icons\au3.ico") #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so /pe /rm #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_stripped.au3" #include <GuiConstantsEx.au3> #include <WinAPIGdi.au3> #include <WindowsConstants.au3> Global $__f1, $__f2, $__f3, $__fY0, $__fZ0, $__fX1, $__fY1 Global $hGUI, $iFPS = 0, $iShowFPS = 0, $bExit, $fZoom = 5.0 Global Const $iW = @DesktopWidth * 0.75, $iH = @DesktopHeight * 0.75, $iWh = $iW / 2, $iHh = $iH / 2, $sTitle = "GDI+ 3D Sinus Wave v1.1 coded by UEZ / FPS: " Global Const $fPi = ACos(-1), $fRad = $fPi / 180, $fDeg = 180 / $fPi, $fPi2 = ACos(-1) * 2 AutoItSetOption("GUIOnEventMode", 1) GDIPlus_3DSinusWave() AutoItSetOption("GUIOnEventMode", 0) Func GDIPlus_3DSinusWave() $bExit = False $hGUI = GUICreate($sTitle, $iW, $iH) ;, 0, 0, $WS_POPUP) GUISetState(@SW_SHOW, $hGUI) ;~ GUISetCursor(16, 1) ;create canvas elements Local Const $hDC = _WinAPI_GetDC($hGUI) Local Const $hBitmapGDI = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) Local Const $hGfxDC = _WinAPI_CreateCompatibleDC($hDC) Local Const $hObjOld = _WinAPI_SelectObject($hGfxDC, $hBitmapGDI) Local Const $hPen = _WinAPI_GetStockObject($DC_PEN) Local Const $hPen_Old = _WinAPI_SelectObject($hGfxDC, $hPen) _WinAPI_SetStretchBltMode($hDC, $HALFTONE) $iFPS = 0 Local Const $fEuler = 2.7182818284 Local $fSpace = 6, $iPoints = 16, $fSpace2 = $fSpace / 2, $iPoints2 = $iPoints / 2 Local $fRotX = Random(-360, 360), $fRotY = Random(-360, 360), $fRotZ = Random(-360, 360), $fPower = 20.0 Local $fRx = Random(-1.5, 1,5), $fRy = Random(-1.5, 1,5), $fRz = Random(-1.5, 1,5) Local $c = 0, $t = 0, $aCoords[$iPoints ^ 2][3] Local $i, $j, $x, $y, $z, $x1, $y1, $z1, $x2, $y2, $z2, $x3, $y3, $z3, $fDistance, $r, $g, $b Local $hDLL_gdi32 = DllOpen("gdi32.dll") Local $tLOGBRUSH = DllStructCreate($tagLOGBRUSH) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit_About") GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL") AdlibRegister("CalcFPS", 1000) Do _WinAPI_BitBlt($hGfxDC, 0, 0, $iW, $iH, $hGfxDC, 0, 0, $WHITENESS) ;erase canvas background $c = 0 For $i = 0 To $iPoints - 1 For $j = 0 To $iPoints - 1 $aCoords[$c][0] = $fSpace * $i + $fSpace2 - $fSpace * $iPoints2 $aCoords[$c][1] = $fSpace * $j + $fSpace2 - $fSpace * $iPoints2 $fDistance = Dist(0, 0, $aCoords[$c][0], $aCoords[$c][1]) $aCoords[$c][2] = $fEuler ^ (-$fDistance / 50) * Sin(($fDistance / 10) - $t) * $fPower $c += 1 $t += 0.00075 Next Next For $i = 0 To $iPoints - 2 For $j = 0 To $iPoints - 2 $r = Int(0x80 + $aCoords[$j + $iPoints * $i][0] * 2) $g = Int(0x80 + $aCoords[$j + $iPoints * $i][1] * 2) $b = Int(0x80 + $aCoords[$j + $iPoints * $i][2] * 2) DllCall($hDLL_gdi32, "dword", "SetDCPenColor", "handle", $hGfxDC, "dword", BitShift($b, -16) + BitShift($g, -8) + $r) _3Dto2D($aCoords[$j + $iPoints * $i][0], $aCoords[$j + $iPoints * $i][1], $aCoords[$j + $iPoints * $i][2], $fRotX, $fRotY, $fRotZ, $x1, $y1, $z1) _3Dto2D($aCoords[$j + $iPoints * ($i + 1)][0], $aCoords[$j + $iPoints * ($i + 1)][1], $aCoords[$j + $iPoints * ($i + 1)][2], $fRotX, $fRotY, $fRotZ, $x2, $y2, $z2) DllCall($hDLL_gdi32, "bool", "MoveToEx", "handle", $hGfxDC, "int", $iWh + $x1 * $fZoom, "int", $iHh + $y1 * $fZoom, "ptr", 0) DllCall($hDLL_gdi32, "bool", "LineTo", "handle", $hGfxDC, "int", $iWh + $x2 * $fZoom, "int", $iHh + $y2 * $fZoom) _3Dto2D($aCoords[($j + 1) + $iPoints * $i][0], $aCoords[($j + 1) + $iPoints * $i][1], $aCoords[($j + 1) + $iPoints * $i][2], $fRotX, $fRotY, $fRotZ, $x2, $y2, $z2) DllCall($hDLL_gdi32, "bool", "MoveToEx", "handle", $hGfxDC, "int", $iWh + $x1 * $fZoom, "int", $iHh + $y1 * $fZoom, "ptr", 0) DllCall($hDLL_gdi32, "bool", "LineTo", "handle", $hGfxDC, "int", $iWh + $x2 * $fZoom, "int", $iHh + $y2 * $fZoom) Next Next For $i = 0 To $iPoints - 2 $r = Int(0x80 + $aCoords[$j + $iPoints * $i][0] * 2) $g = Int(0x80 + $aCoords[$j + $iPoints * $i][1] * 2) $b = Int(0x80 + $aCoords[$j + $iPoints * $i][2] * 2) DllCall($hDLL_gdi32, "dword", "SetDCPenColor", "handle", $hGfxDC, "dword", BitShift($b, -16) + BitShift($g, -8) + $r) _3Dto2D($aCoords[$j + $iPoints * $i][0], $aCoords[$j + $iPoints * $i][1], $aCoords[$j + $iPoints * $i][2], $fRotX, $fRotY, $fRotZ, $x1, $y1, $z1) _3Dto2D($aCoords[$j + $iPoints * ($i + 1)][0], $aCoords[$j + $iPoints * ($i + 1)][1], $aCoords[$j + $iPoints * ($i + 1)][2], $fRotX, $fRotY, $fRotZ, $x2, $y2, $z2) DllCall($hDLL_gdi32, "bool", "MoveToEx", "handle", $hGfxDC, "int", $iWh + $x1 * $fZoom, "int", $iHh + $y1 * $fZoom, "ptr", 0) DllCall($hDLL_gdi32, "bool", "LineTo", "handle", $hGfxDC, "int", $iWh + $x2 * $fZoom, "int", $iHh + $y2 * $fZoom) Next For $j = 0 To $iPoints - 2 $r = Int(0x80 + $aCoords[$j + $iPoints * $i][0] * 2) $g = Int(0x80 + $aCoords[$j + $iPoints * $i][1] * 2) $b = Int(0x80 + $aCoords[$j + $iPoints * $i][2] * 2) DllCall($hDLL_gdi32, "dword", "SetDCPenColor", "handle", $hGfxDC, "dword", BitShift($b, -16) + BitShift($g, -8) + $r) _3Dto2D($aCoords[$j + $iPoints * $i][0], $aCoords[$j + $iPoints * $i][1], $aCoords[$j + $iPoints * $i][2], $fRotX, $fRotY, $fRotZ, $x1, $y1, $z1) _3Dto2D($aCoords[($j + 1) + $iPoints * $i][0], $aCoords[($j + 1) + $iPoints * $i][1], $aCoords[($j + 1) + $iPoints * $i][2], $fRotX, $fRotY, $fRotZ, $x2, $y2, $z2) DllCall($hDLL_gdi32, "bool", "MoveToEx", "handle", $hGfxDC, "int", $iWh + $x1 * $fZoom, "int", $iHh + $y1 * $fZoom, "ptr", 0) DllCall($hDLL_gdi32, "bool", "LineTo", "handle", $hGfxDC, "int", $iWh + $x2 * $fZoom, "int", $iHh + $y2 * $fZoom) Next $fRotX += $fRx $fRotY += $fRy $fRotZ += $fRz _WinAPI_BitBlt($hDC, 0, 0, $iW, $iH, $hGfxDC, 0, 0, $SRCCOPY) ;blit drawn bitmap to GUI $iFPS += 1 If $bExit Then ExitLoop Until Not Sleep(10) GUIRegisterMsg($WM_MOUSEWHEEL, "") AdlibUnRegister("CalcFPS") ;release resources _WinAPI_SelectObject($hGfxDC, $hPen_Old) _WinAPI_DeleteObject($hPen) _WinAPI_SelectObject($hGfxDC, $hObjOld) _WinAPI_ReleaseDC($hGUI, $hDC) _WinAPI_DeleteDC($hGfxDC) _WinAPI_DeleteObject($hBitmapGDI) GUIDelete($hGUI) DllClose($hDLL_gdi32) EndFunc ;==>GDIPlus_3DSinusWave Func WM_MOUSEWHEEL($hGUI, $iMsg, $wParam, $lParam) Local $wheel_Dir = _WinAPI_HiWord($wParam) If $wheel_Dir > 0 Then $fZoom += 0.25 $fZoom = $fZoom > 20 ? 20 : $fZoom Else $fZoom -= 0.25 $fZoom = $fZoom < 0.25 ? 0.25 : $fZoom EndIf Return "GUI_RUNDEFMSG" EndFunc ;==>WM_MOUSEWHEEL Func Dist($x1, $y1, $x2, $y2) Return Sqrt(($x1 - $x2) * ($x1 - $x2) + ($y1 - $y2) * ($y1 - $y2)) EndFunc ;==>Dist Func _3Dto2D($fX, $fY, $fZ, $fRotX, $fRotY, $fRotZ, ByRef $__fXPos, ByRef $__fYPos, ByRef $__fZPos) ;apply the x-axis rotation to transform coordinates ($fX, $fY, $fZ) into coordinates ($fX0, $fY0, $fZ0) $__f1 = $fRotX * $fRad $__f2 = Cos($__f1) $__f3 = Sin($__f1) $__fY0 = $fY * $__f2 + $fZ * $__f3 $__fZ0 = $fZ * $__f2 - $fY * $__f3 ;apply the y-axis rotation to ($fX0, $__fY0, $fZ0) to obtain ($__fX1, $__fY1, $fZ1) $__f1 = $fRotY * $fRad $__f2 = Cos($__f1) $__f3 = Sin($__f1) $__fX1 = $fX * $__f2 - $__fZ0 * $__f3 $__fY1 = $__fY0 ;~ $__fZ1 = $__fZ0 * $__f2 + $fX * $__f2 ;finally, apply the z-axis rotation to obtain the point ($fXPos, $fYPos) $__f1 = $fRotZ * $fRad $__f2 = Cos($__f1) $__f3 = Sin($__f1) $__fXPos = $__fX1 * $__f2 + $__fY1 * $__f3 $__fYPos = $__fY1 * $__f2 - $__fX1 * $__f3 $__fZPos = $__fZ0 EndFunc ;==>_3Dto2D Func _Exit_About() $bExit = True EndFunc ;==>_Exit_About Func CalcFPS() ;display FPS $iShowFPS = $iFPS $iFPS = 0 WinSetTitle($hGUI, "", $sTitle & $iShowFPS) EndFunc ;==>CalcFPS  
      GDI+
      ;coded by UEZ build 2017-01-17 #pragma compile(Icon, "c:\Program Files (x86)\AutoIt3\Icons\au3.ico") #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so /pe /rm #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_stripped.au3" #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global $__f1, $__f2, $__f3, $__fY0, $__fZ0, $__fX1, $__fY1 Global $hGUI, $iFPS = 0, $iShowFPS = 0, $bExit Global Const $iW = @DesktopWidth * 0.75, $iH = @DesktopHeight * 0.75, $iWh = $iW / 2, $iHh = $iH / 2, $sTitle = "GDI+ 3D Sinus Wave v1.0 coded by UEZ" Global Const $fPi = ACos(-1), $fRad = $fPi / 180, $fDeg = 180 / $fPi, $fPi2 = ACos(-1) * 2 AutoItSetOption("GUIOnEventMode", 1) GDIPlus_3DSinusWave() AutoItSetOption("GUIOnEventMode", 0) _GDIPlus_Shutdown() Func GDIPlus_3DSinusWave() $bExit = False $hGUI = GUICreate($sTitle, $iW, $iH) ;, 0, 0, $WS_POPUP) GUISetState(@SW_SHOW, $hGUI) ;~ GUISetCursor(16, 1) ;create canvas elements Local Const $hDC = _WinAPI_GetDC($hGUI) Local Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) Local Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC) Local Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap) Local Const $hCanvas = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer) _GDIPlus_GraphicsSetSmoothingMode($hCanvas, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetPixelOffsetMode($hCanvas, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) Local Const $hBrush_Clr = _GDIPlus_BrushCreateSolid(0xFFFFFFFF), _ $hBrush_FPS = _GDIPlus_BrushCreateSolid(0xF0808080), _ $hFormat_FPS = _GDIPlus_StringFormatCreate(), _ $hFamily_FPS = _GDIPlus_FontFamilyCreate("Arial"), _ $hFont_FPS = _GDIPlus_FontCreate($hFamily_FPS, 8), _ $tLayout_FPS = _GDIPlus_RectFCreate(0, 0, 60, 16), _ $hPath = _GDIPlus_PathCreate(), _ $hPen = _GDIPlus_PenCreate(0xCF101010, 1.25) _GDIPlus_PenSetLineJoin($hPen, 2) ;~ _GDIPlus_PenSetDashCap($hPen, $GDIP_DASHCAPROUND) ;~ _GDIPlus_PenSetLineCap($hPen, 0x12, 0x12, 2) $iFPS = 0 Local $fEuler = 2.7182818284 Local $fSpace = 6, $iPoints = 16, $fSpace2 = $fSpace / 2, $iPoints2 = $iPoints / 2 Local $fRotX = Random(-360, 360), $fRotY = Random(-360, 360), $fRotZ = Random(-360, 360), $fZoom = 5.0, $fPower = 20.0 Local $fRx = Random(-1.5, 1,5), $fRy = Random(-1.5, 1,5), $fRz = Random(-1.5, 1,5) Local $c = 0, $t = 0, $aCoords[$iPoints ^ 2][3] Local $i, $j, $x, $y, $z, $x1, $y1, $z1, $x2, $y2, $z2, $x3, $y3, $z3, $fDistance, $r, $g, $b GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit_About") AdlibRegister("CalcFPS", 1000) Do ;~ DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hCanvas, "handle", $hBrush_Clr, "float", 0, "float", 0, _ ;~ "float", $iW, "float", $iH) ;erase canvas background _WinAPI_BitBlt($hDC_backbuffer, 0, 0, $iW, $iH, $hDC_backbuffer, 0, 0, $WHITENESS) $c = 0 For $i = 0 To $iPoints - 1 For $j = 0 To $iPoints - 1 $aCoords[$c][0] = ($fSpace * $i + $fSpace2 - $fSpace * $iPoints2) $aCoords[$c][1] = ($fSpace * $j + $fSpace2 - $fSpace * $iPoints2) $fDistance = Dist(0, 0, $aCoords[$c][0], $aCoords[$c][1]) $aCoords[$c][2] = $fEuler ^ (-$fDistance / 50) * Sin(($fDistance / 10) - $t) * $fPower $c += 1 $t += 0.00075 Next Next For $i = 0 To $iPoints - 2 For $j = 0 To $iPoints - 2 _3Dto2D($aCoords[$j + $iPoints * $i][0], $aCoords[$j + $iPoints * $i][1], $aCoords[$j + $iPoints * $i][2], $fRotX, $fRotY, $fRotZ, $x1, $y1, $z1) _3Dto2D($aCoords[$j + $iPoints * ($i + 1)][0], $aCoords[$j + $iPoints * ($i + 1)][1], $aCoords[$j + $iPoints * ($i + 1)][2], $fRotX, $fRotY, $fRotZ, $x2, $y2, $z2) DllCall($__g_hGDIPDll, "int", "GdipDrawLine", "handle", $hCanvas, "handle", $hPen, _ "float", $iWh + $x1 * $fZoom, "float", $iHh + $y1 * $fZoom, "float", $iWh + $x2 * $fZoom, "float", $iHh + $y2 * $fZoom) _3Dto2D($aCoords[($j + 1) + $iPoints * $i][0], $aCoords[($j + 1) + $iPoints * $i][1], $aCoords[($j + 1) + $iPoints * $i][2], $fRotX, $fRotY, $fRotZ, $x2, $y2, $z2) DllCall($__g_hGDIPDll, "int", "GdipDrawLine", "handle", $hCanvas, "handle", $hPen, _ "float", $iWh + $x1 * $fZoom, "float", $iHh + $y1 * $fZoom, "float", $iWh + $x2 * $fZoom, "float", $iHh + $y2 * $fZoom) Next Next For $i = 0 To $iPoints - 2 _3Dto2D($aCoords[$j + $iPoints * $i][0], $aCoords[$j + $iPoints * $i][1], $aCoords[$j + $iPoints * $i][2], $fRotX, $fRotY, $fRotZ, $x1, $y1, $z1) _3Dto2D($aCoords[$j + $iPoints * ($i + 1)][0], $aCoords[$j + $iPoints * ($i + 1)][1], $aCoords[$j + $iPoints * ($i + 1)][2], $fRotX, $fRotY, $fRotZ, $x2, $y2, $z2) DllCall($__g_hGDIPDll, "int", "GdipDrawLine", "handle", $hCanvas, "handle", $hPen, _ "float", $iWh + $x1 * $fZoom, "float", $iHh + $y1 * $fZoom, "float", $iWh + $x2 * $fZoom, "float", $iHh + $y2 * $fZoom) Next For $j = 0 To $iPoints - 2 _3Dto2D($aCoords[$j + $iPoints * $i][0], $aCoords[$j + $iPoints * $i][1], $aCoords[$j + $iPoints * $i][2], $fRotX, $fRotY, $fRotZ, $x1, $y1, $z1) _3Dto2D($aCoords[($j + 1) + $iPoints * $i][0], $aCoords[($j + 1) + $iPoints * $i][1], $aCoords[($j + 1) + $iPoints * $i][2], $fRotX, $fRotY, $fRotZ, $x2, $y2, $z2) DllCall($__g_hGDIPDll, "int", "GdipDrawLine", "handle", $hCanvas, "handle", $hPen, _ "float", $iWh + $x1 * $fZoom, "float", $iHh + $y1 * $fZoom, "float", $iWh + $x2 * $fZoom, "float", $iHh + $y2 * $fZoom) Next $fRotX += $fRx $fRotY += $fRy $fRotZ += $fRz _GDIPlus_GraphicsDrawStringEx($hCanvas, "FPS: " & $iShowFPS, $hFont_FPS, $tLayout_FPS, $hFormat_FPS, $hBrush_FPS) ;draw background message text _WinAPI_BitBlt($hDC, 0, 0, $iW, $iH, $hDC_backbuffer, 0, 0, $SRCCOPY) ;blit drawn bitmap to GUI $iFPS += 1 If $bExit Then ExitLoop Until Not Sleep(10) AdlibUnRegister("CalcFPS") ;release resources _GDIPlus_PenDispose($hPen) _GDIPlus_PathDispose($hPath) _GDIPlus_FontDispose($hFont_FPS) _GDIPlus_FontFamilyDispose($hFamily_FPS) _GDIPlus_StringFormatDispose($hFormat_FPS) _GDIPlus_BrushDispose($hBrush_Clr) _GDIPlus_BrushDispose($hBrush_FPS) _GDIPlus_GraphicsDispose($hCanvas) _WinAPI_SelectObject($hDC_backbuffer, $DC_obj) _WinAPI_DeleteDC($hDC_backbuffer) _WinAPI_DeleteObject($hHBitmap) _WinAPI_ReleaseDC($hGUI, $hDC) GUIDelete($hGUI) EndFunc ;==>GDIPlus_3DSinusWave Func Dist($x1, $y1, $x2, $y2) Return Sqrt(($x1 - $x2) * ($x1 - $x2) + ($y1 - $y2) * ($y1 - $y2)) EndFunc ;==>Dist Func _3Dto2D($fX, $fY, $fZ, $fRotX, $fRotY, $fRotZ, ByRef $__fXPos, ByRef $__fYPos, ByRef $__fZPos) ;apply the x-axis rotation to transform coordinates ($fX, $fY, $fZ) into coordinates ($fX0, $fY0, $fZ0) $__f1 = $fRotX * $fRad $__f2 = Cos($__f1) $__f3 = Sin($__f1) $__fY0 = $fY * $__f2 + $fZ * $__f3 $__fZ0 = $fZ * $__f2 - $fY * $__f3 ;apply the y-axis rotation to ($fX0, $__fY0, $fZ0) to obtain ($__fX1, $__fY1, $fZ1) $__f1 = $fRotY * $fRad $__f2 = Cos($__f1) $__f3 = Sin($__f1) $__fX1 = $fX * $__f2 - $__fZ0 * $__f3 $__fY1 = $__fY0 ;~ $__fZ1 = $__fZ0 * $__f2 + $fX * $__f2 ;finally, apply the z-axis rotation to obtain the point ($fXPos, $fYPos) $__f1 = $fRotZ * $fRad $__f2 = Cos($__f1) $__f3 = Sin($__f1) $__fXPos = $__fX1 * $__f2 + $__fY1 * $__f3 $__fYPos = $__fY1 * $__f2 - $__fX1 * $__f3 $__fZPos = $__fZ0 EndFunc ;==>_3Dto2D Func _Exit_About() $bExit = True EndFunc ;==>_Exit_About Func CalcFPS() ;display FPS $iShowFPS = $iFPS $iFPS = 0 EndFunc ;==>CalcFPS  
      In the attached 7-Zip file you can find the compiled and also a FreeBasic version. -> DL: 3D Sinus Wave.7z
       
      Have fun. 
    • marcoauto
      By marcoauto
      ciao,
      I need to scale an outlined GDI text in a GUI. The problem is that I can't do this. The outline is often out of the GUI
      I started from this script:
      https://www.autoitscript.com/autoit3/docs/libfunctions/_GDIPlus_PathTransform.htm
      that fit a string to windows and I changed
       $aBounds = _GDIPlus_PathGetWorldBounds($hPath) ;Get bounding rectangle of the path
      $aBounds = _GDIPlus_PathGetWorldBounds($hPath) ;Get bounding rectangle of the path with 
      $aBounds = _GDIPlus_PathGetWorldBounds($hPath,$hMatrix,$hPen) ;Get bounding rectangle of the path with pen size but doesn't work
      so, I tried to change other thins, but nothing... Sometimes works, but if I change the string often result change
      This is my script:
      #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <array.au3> Example() Func Example() Local $iW, $iH, $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hFamily, $tLayout, $hMatrix, $aBounds ; Create GUI $iW = 650 $iH = 300 $hGUI = GUICreate("GDI+", $iW, $iH) GUISetState(@SW_SHOW) ; Draw a string using path _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing) ;~ _GDIPlus_GraphicsClear($hGraphic, 0xFF000000) $MergedImageBackgroundColor = 0x00000000 _GDIPlus_GraphicsClear($hGraphic, $MergedImageBackgroundColor) $hBrush = _GDIPlus_BrushCreateSolid(0xFFDD2200) $stroke_size = 15 $hPen = _GDIPlus_PenCreate(0xFFFFBB00, $stroke_size) ;stroke size in pixel $hPen2 = _GDIPlus_PenCreate(0xFFFFff00, 2) ;stroke size in pixel _GDIPlus_PenSetLineJoin($hPen,$GDIP_PENSETLINEJOIN_ROUND) $hPath = _GDIPlus_PathCreate() ;Create new path object ;~ $fSize = 20 $hFamily = _GDIPlus_FontFamilyCreate("Myriad Pro") ;Create font family object $tLayout = _GDIPlus_RectFCreate() ;Create string bounding rectangle X=0, Y=0 Local $hFormat = _GDIPlus_StringFormatCreate() _GDIPlus_PathAddString($hPath, "autoitForeverLollipop", $tLayout, $hFamily);, 0, $fSize, $hFormat) ;Add the outline of the string to the path ;~ _GDIPlus_PathAddString($hPath, $sText, $tLayout, $hFamily, 0, $fSize, $hFormat) ; Tranform Path to fit to window $aBounds = _GDIPlus_PathGetWorldBounds($hPath) ;Get bounding rectangle of the path $aPoints = _GDIPlus_PathGetPoints($hPath) ConsoleWrite($aBounds[0] & @CRLF) ConsoleWrite($aBounds[1] & @CRLF) ConsoleWrite($aBounds[2] & @CRLF) ConsoleWrite($aBounds[3] & @CRLF) ConsoleWrite($aPoints[$aPoints[0][0]][0] & " - " & $aPoints[1][0] & " + 2*" & $stroke_size & " = " & $aPoints[$aPoints[0][0]][0]-$aPoints[1][0]+2*$stroke_size & @CRLF) ;~ $aBounds[0] = $aBounds[0] $aBoundsNp = _GDIPlus_PathGetWorldBounds($hPath,0,$hPen) ;Get bounding rectangle of the path with pen ConsoleWrite($aBoundsNp[0] & @CRLF) ConsoleWrite($aBoundsNp[1] & @CRLF) ConsoleWrite($aBoundsNp[2] & @CRLF) ConsoleWrite($aBoundsNp[3] & @CRLF) ConsoleWrite($iW & " / 2 = " & $iW / 2 & @CRLF) ConsoleWrite("$ih / 2 = " & $iH / 2 & @CRLF) ;~ ConsoleWrite($iW & " $aBounds[2] = " & $iW / $aBounds[2] & @CRLF) ConsoleWrite($iW & " $aBoundsNp[2] = " & $iW / $aBoundsNp[2] & @CRLF) ConsoleWrite($iH & " $aBoundsNp[3] = " & $iH / $aBoundsNp[3] & @CRLF) ;~ _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI) ;~ _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI) $hMatrix = _GDIPlus_MatrixCreate() $iW = $iW - $stroke_size ;+ $stroke_size $iH = $iH - $stroke_size ConsoleWrite(" -$aBounds[0]+1*$stroke_size/72 = " & -$aBounds[0]+1*$stroke_size/72 & @CRLF) ConsoleWrite(" -1.8+1*$stroke_size/72 = " & -1.8+1*$stroke_size/72 & @CRLF) _GDIPlus_MatrixTranslate($hMatrix, -$aBounds[0]+2*$stroke_size/72, -$aBounds[1]+1*$stroke_size/72) ;Translate Matrix to the offset of the bounding rectangle ;~ _GDIPlus_MatrixTranslate($hMatrix, -1.59166666666667+0*($stroke_size/72), -$aBounds[1]+1*$stroke_size/72) ;Translate Matrix to the offset of the bounding rectangle ;~ _GDIPlus_MatrixScale($hMatrix, $iW / $aBounds[2], $iH / $aBounds[3], True) ;Scale Matrix _GDIPlus_MatrixScale($hMatrix, $iW / $aBounds[2], $iH / $aBounds[3], True) ;Scale Matrix _GDIPlus_PathTransform($hPath, $hMatrix) ;Translate and Scale Path $aBoundsNp = _GDIPlus_PathGetWorldBounds($hPath,0,$hPen) ;Get bounding rectangle of the path with pen ConsoleWrite($aBoundsNp[0] & @CRLF) ConsoleWrite($aBoundsNp[1] & @CRLF) ConsoleWrite($aBoundsNp[2] & @CRLF) ConsoleWrite($aBoundsNp[3] & @CRLF) ;~ _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI) _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI) _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_PathDispose($hPath) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>Example if you change the line 
      _GDIPlus_PathAddString($hPath, "autoitForeverLollipop", $tLayout, $hFamily);, 0, $fSize, $hFormat) ;Add the outline of the string to the path with a smaller string
      _GDIPlus_PathAddString($hPath, "autoitFitted", $tLayout, $hFamily);, 0, $fSize, $hFormat) ;Add the outline of the string to the path the result is ok
      Can someone can help me?
      Thankyou