Sign in to follow this  
Followers 0
ra95

Draw line and background cliccable.

3 posts in this topic

Hi gui,

I want do a mix of this example:

From 3d http://www.autoitscript.com/forum/index.php?showtopic=87200

example - Rotaring letters Transparent of UEZ user

and

This example: #825185

I want release draws one end of a line that follows the mouse color green or red but with background trasparent and bacground cliccable.

similar this: http://www.autoitscript.com/forum/index.php?showtopic=92784 example.

Now I have see all example and script but i don't have understand how to realize this, have take a source code from example of UEZ (many thanks).

My script:

;coded by UEZ 2009
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0
;~ #AutoIt3Wrapper_Run_After=upx.exe --best "%out%"
#AutoIt3Wrapper_Run_After=upx.exe --ultra-brute "%out%" ;very slow
#AutoIt3Wrapper_Run_After=del "Rotating Letters Transparent_Obfuscated.au3"

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

Global Const $width = 640
Global Const $height = 480
Global Const $pi_div_180 = 4 * ATan(1) / 180
Global $graphics, $backbuffer, $bitmap, $Pen
Global $ScreenDc, $dc, $tSize, $pSize, $tSource, $pSource, $tBlend, $pBlend, $tPoint, $pPoint, $gdibitmap
Global $title = "GDI+: Rotating Letters by UEZ 2009!"
Global Const $MSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo"
;Register callback
$hKey_Proc = DllCallbackRegister("_Mouse_Proc", "int", "int;ptr;ptr")
$hM_Module = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0)
$hM_Hook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", "int", $WH_MOUSE_LL, "ptr", DllCallbackGetPtr($hKey_Proc), "hwnd", $hM_Module[0], "dword", 0)

Opt("GUIOnEventMode", 1)
$hwnd = GUICreate($title, $width, $height, -1, -1, 0, $WS_EX_LAYERED + $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")

_GDIPlus_Startup()
$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
$bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics)
$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
$hPen = _GDIPlus_PenCreate(0xFF609900, 2)
_GDIPlus_GraphicsSetSmoothingMode($backbuffer, 2)

$ScreenDc = _WinAPI_GetDC($hWnd)
$gdibitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($bitmap)
$dc = _WinAPI_CreateCompatibleDC($ScreenDc)
_WinAPI_SelectObject($dc, $gdibitmap)
; _WinAPI_UpdateLayeredWindow parameters
$tSize = DllStructCreate($tagSIZE)
$pSize = DllStructGetPtr($tSize)
DllStructSetData($tSize, "X", $width)
DllStructSetData($tSize, "Y", $height)
$tSource = DllStructCreate($tagPOINT)
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate($tagBLENDFUNCTION)
$pBlend = DllStructGetPtr($tBlend)
Global $alpha = 200
Global $alpha_steps = 5
DllStructSetData($tBlend, "Alpha", $alpha)
DllStructSetData($tBlend, "Format", 1)
$tPoint = DllStructCreate($tagPOINT)
$pPoint = DllStructGetPtr($tPoint)
DllStructSetData($tPoint, "X", 0)
DllStructSetData($tPoint, "Y", 0)

GUISetState()

$brush = _GDIPlus_BrushCreateSolid($hPen)

_GDIPlus_BrushSetSolidColor($brush, 0xFF609900)


Do
    _GDIPlus_GraphicsClear($backbuffer, 0x00000000)
    $msg = GUIGetMsg()
        if $msg = $GUI_EVENT_MOUSEMOVE Then
    _GDIPlus_GraphicsDrawLine($backbuffer, 10, 150, MouseGetPos(0), MouseGetPos(1), $hPen)
    EndIf

    $gdibitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($bitmap)
    _WinAPI_SelectObject($dc, $gdibitmap)
    _WinAPI_UpdateLayeredWindow($hWnd, $ScreenDc, 0, $pSize, $dc, $pSource, 0, $pBlend, 2)
    _WinAPI_DeleteObject($gdibitmap)
;~  _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)
Until False * Not Sleep(30)



;http://www.autoitscript.com/forum/index.php?showtopic=81761
Func _Mouse_Proc($nCode, $wParam, $lParam) ;function called for mouse events.. Made by _Kurt
    ;define local vars
    Local $info, $mouseData

    If $nCode < 0 Then ;recommended, see http://msdn.microsoft.com/en-us/library/ms644986(VS.85).aspx
        $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hM_Hook[0], "int", $nCode, "ptr", $wParam, "ptr", $lParam) ;recommended
        Return $ret[0]
    EndIf
    $info = DllStructCreate($MSLLHOOKSTRUCT, $lParam)
    $mouseData = DllStructGetData($info, 3)

    ;Find which event happened
    Select
        Case $wParam = $WM_MOUSEWHEEL And WinActive($hwnd)
            If _WinAPI_HiWord($mouseData) > 0 Then ;wheel up
                If $alpha + $alpha_steps <= 512 Then $alpha += $alpha_steps
                Switch $alpha
                    Case 0 To 255
                        DllStructSetData($tBlend, "Alpha", $alpha)
                        DllStructSetData($tBlend, "Format", 1)
                    Case 256 To 512
                        DllStructSetData($tBlend, "Alpha", $alpha - 256)
                        DllStructSetData($tBlend, "Format", 0)
                EndSwitch
            Else ;wheel down
                If $alpha - $alpha_steps > 0 Then $alpha -= $alpha_steps
                Switch $alpha
                    Case 0 To 255
                        DllStructSetData($tBlend, "Alpha", $alpha) ;wheel up
                        DllStructSetData($tBlend, "Format", 1)
                    Case 256 To 512
                        DllStructSetData($tBlend, "Alpha", $alpha - 256) ;wheel up
                        DllStructSetData($tBlend, "Format", 0)
                EndSwitch
            EndIf
            ConsoleWrite($alpha & @CRLF)
    EndSelect

    ;This is recommended instead of Return 0
    $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hM_Hook[0], "int", $nCode, "ptr", $wParam, "ptr", $lParam)
    Return $ret[0]
EndFunc   ;==>_Mouse_Proc

Func Close()
    DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $hM_Hook[0])
    $hM_Hook[0] = 0
    DllCallbackFree($hKey_Proc)
    $hKey_Proc = 0

    _WinAPI_DeleteDC($dc)
    _WinAPI_ReleaseDC($hWnd, $ScreenDc)
    _GDIPlus_GraphicsDispose($backbuffer)
    _GDIPlus_BitmapDispose($bitmap)
    _GDIPlus_GraphicsDispose($graphics)
    _GDIPlus_Shutdown()
    WinClose($hwnd)
    Exit
EndFunc   ;==>Close
But nothing happens
someone can help me...??
Thx in advance
A.

Share this post


Link to post
Share on other sites



You mean this?

;coded by UEZ
#include <GDIPLus.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>

Opt("MouseCoordMode", 1)
Opt("GUIOnEventMode", 1)

$w = @DesktopWidth
$h = @DesktopHeight
$hWnd = GUICreate("GDI+ Test", $w, $h, 0, 0, 0, $WS_EX_LAYERED + $WS_EX_TOPMOST)
GUISetState()

_GDIPlus_Startup()

$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($w, $w, $hGraphic)
$hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
$hPen = _GDIPlus_PenCreate(0xFFA0A0A0, 2)
_GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)

$ScreenDc = _WinAPI_GetDC($hWnd)
$gdibitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
$dc = _WinAPI_CreateCompatibleDC($ScreenDc)
_WinAPI_SelectObject($dc, $gdibitmap)
; _WinAPI_UpdateLayeredWindow parameters
$tSize = DllStructCreate($tagSIZE)
$pSize = DllStructGetPtr($tSize)
DllStructSetData($tSize, "X", $w)
DllStructSetData($tSize, "Y", $h)
$tSource = DllStructCreate($tagPOINT)
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate($tagBLENDFUNCTION)
$pBlend = DllStructGetPtr($tBlend)
$alpha = 0xFF
DllStructSetData($tBlend, "Alpha", $alpha)
DllStructSetData($tBlend, "Format", 1)
$tPoint = DllStructCreate($tagPOINT)
$pPoint = DllStructGetPtr($tPoint)
DllStructSetData($tPoint, "X", 0)
DllStructSetData($tPoint, "Y", 0)

GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

$mpos_ox = 0
$mpos_oy = 0

While Sleep(50)
    _GDIPlus_GraphicsClear($hBuffer, 0x00000000)
    $mpos = MouseGetPos()
    If $mpos[0] <> $mpos_oy Or $mpos[1] <> $mpos_oy Then
;~  _GDIPlus_GraphicsDrawLine($hBuffer, 0, 0, $mpos[0], $mpos[1], $hPen)
;~  _GDIPlus_GraphicsDrawLine($hBuffer, @DesktopWidth, 0, $mpos[0], $mpos[1], $hPen)
    _GDIPlus_GraphicsDrawLine($hBuffer, 0, @DesktopHeight, $mpos[0], $mpos[1] + 10, $hPen)
;~  _GDIPlus_GraphicsDrawLine($hBuffer, @DesktopWidth, @DesktopHeight, $mpos[0], $mpos[1], $hPen)
    $mpos_ox = $mpos[0]
    $mpos_oy = $mpos[1] + 10
    EndIf
    $gdibitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
    _WinAPI_SelectObject($dc, $gdibitmap)
    _WinAPI_UpdateLayeredWindow($hWnd, $ScreenDc, 0, $pSize, $dc, $pSource, 0, $pBlend, 2)
    _WinAPI_DeleteObject($gdibitmap)
WEnd


Func _Exit()
    _WinAPI_DeleteDC($dc)
    _WinAPI_ReleaseDC($hWnd, $ScreenDc)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_GraphicsDispose($hBuffer)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($hWnd)
    $tSize = ""
    $tSource = ""
    $tBlend = ""
    $tPoint = ""
    Exit
EndFunc

Br,

UEZ


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

Selection of finest graphical examples at Codepen.io

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

Share this post


Link to post
Share on other sites

Wow.... thath work fine!!!!

Thanks UEZ.

Have a nice day.

A.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0