Sign in to follow this  
Followers 0
nitekram

Want to draw to screen

21 posts in this topic

#1 ·  Posted (edited)

I know that I have seen/read this and now cannot find the code. I want to use the mouse to draw anywhere on the screen (on any application/window). Can someone point me to the OP?

I want to create a highlighter/line/arrow/circle/text drawing on the window and then be able to take a screen shot of the new info.

I have found a circle - but it draws it - i want to be able to pick location on the spot not static but dynamic.

I have also found FreeText from Valuater:

Any help would be greatfull

EDIT - also be able clear the drawing with hotkey (know how to create hotkey, but not the code to refresh the screen)

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites



Take a look at and ! Posted Image


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

#3 ·  Posted (edited)

edit: found the link

Heres a circle where you can easily set the GUI location, all credit goes to the folks who assisted

#include 
#include 
#include 

Opt("TrayIconHide", 1)

_Circle()


Func _Circle()
    Local $h = 100
    Local $w = $h

    ; Initialize GDI+
    _GDIPlus_Startup()

    Local $hGUI = GUICreate("", $w, $h, @DesktopWidth / 2 - 50, @DesktopHeight / 2 - 50 , $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
    ;WinSetTrans($hGUI,"", 255)
    Local $bg = 0xFFFFFF
    GUISetBkColor(0xABCDEF)
    _WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF)

    GUISetState()

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($w, $h, $hGraphics)
    Local $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)

    ; Using antialiasing
    _GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)

    ; Create a Pen object
    Local $pen_size = Floor($h / 6)
    Local $hPen = _GDIPlus_PenCreate(0, $pen_size)
    Local $hPen1 = _GDIPlus_PenCreate(0, $pen_size)

    ; Setup font parameters
    Local $fsize = Floor($h / 10)
    Local $angle = 360
    Local $countdown_t = 3 ;seconds
    Local $countdown = $countdown_t
    Local $timer = TimerInit()
    Local $t_calc = Round(1000 * ($countdown_t + 1) / 360, 0)
    Local $z = 1
    Local $lastcolor = Execute("0xFF" & Hex(Random(0x000000, 0xFFFFFF), 6))
    Local $randomColor = Execute("0xFF" & Hex(Random(0x000000, 0xFFFFFF), 6))

    While 1
        If GUIGetMsg() = -3 Then ExitLoop
        _GDIPlus_GraphicsClear($hBackbuffer, 0x00000000)
        _GDIPlus_PenSetColor($hPen1, $randomColor)
        _GDIPlus_PenSetColor($hPen, $lastcolor)
        _GDIPlus_GraphicsDrawEllipse($hBackbuffer, $pen_size / 2, $pen_size / 2, $w - $pen_size, $h - $pen_size, $hPen)

        If $countdown > 0 Then
            _GDIPlus_PenSetColor($hPen, "0xFF" & $randomColor)
            _GDIPlus_GraphicsDrawArc($hBackbuffer, $pen_size / 2, $pen_size / 2, $w - $pen_size, $h - $pen_size, -90, -360 + $angle, $hPen1)
            _GDIPlus_GraphicsDrawArc($hBackbuffer, $pen_size / 2, $pen_size / 2, $w - $pen_size, $h - $pen_size, -90, $angle, $hPen)
            _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $w, $h)
        EndIf
;~
        If TimerDiff($timer) >= $t_calc Then
            $countdown -= $t_calc / 1000
            $timer = TimerInit()
            $angle = 360 * $countdown / $countdown_t
            $z += 2
        EndIf

        If $angle < 3 Then
            $angle = 360
            $timer = TimerInit()
            $countdown_t = 3
            $countdown = $countdown_t
            $lastcolor = $randomColor
            $randomColor = Execute("0xFF" & Hex(Random(0x000000, 0xFFFFFF), 6))
        EndIf
    WEnd
    _GDIPlus_GraphicsDispose($hGraphics)
    _WinAPI_DeleteObject($hBitmap)
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_PenDispose($hPen1)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Circle

Func Max($a, $b)
    If $a >= $b Then
        Return $a
    Else
        Return $b
    EndIf
EndFunc   ;==>Max
Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Take a look at and ! Posted Image

These appear really old - i will have to look for the includes (A3LWinAPI.au3) as the code is not included...thanks for the links though!


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

The other example shows the circle (after i added the includes - thanks for the link - iamtheky) , i may be able to change the code, but i thought that there was something newer, that would draw where ever you wanted. I will have to take a closer look at it.

Anyone else?

EDIT - I would like the user to be able to pick the location, and draw the line/whatever whereever on the screen they desire - not picked by the program but the user

EDIT

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

this may do what your edit asks

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

Opt("TrayIconHide", 1)

    while 1
    if _IsPressed (01) Then
Global  $pos = mousegetpos ()
        _Circle()
    EndIf
    wend



Func _Circle()



    Local $h = 100
    Local $w = $h

    ; Initialize GDI+
    _GDIPlus_Startup()


    Local $hGUI = GUICreate("", $w, $h, $pos[0] - 50, $pos[1] - 50 , $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
    ;WinSetTrans($hGUI,"", 255)
    Local $bg = 0xFFFFFF
    GUISetBkColor(0xABCDEF)
    _WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF)

    GUISetState()

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($w, $h, $hGraphics)
    Local $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)

    ; Using antialiasing
    _GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)

    ; Create a Pen object
    Local $pen_size = Floor($h / 6)
    Local $hPen = _GDIPlus_PenCreate(0, $pen_size)
    Local $hPen1 = _GDIPlus_PenCreate(0, $pen_size)

    ; Setup font parameters
    Local $fsize = Floor($h / 10)
    Local $angle = 360
    Local $countdown_t = 3 ;seconds
    Local $countdown = $countdown_t
    Local $timer = TimerInit()
    Local $t_calc = Round(1000 * ($countdown_t + 1) / 360, 0)
    Local $z = 1
    Local $lastcolor = Execute("0xFF" & Hex(Random(0x000000, 0xFFFFFF), 6))
    Local $randomColor = Execute("0xFF" & Hex(Random(0x000000, 0xFFFFFF), 6))

    While 1
        If GUIGetMsg() = -3 Then ExitLoop
        _GDIPlus_GraphicsClear($hBackbuffer, 0x00000000)
        _GDIPlus_PenSetColor($hPen1, $randomColor)
        _GDIPlus_PenSetColor($hPen, $lastcolor)
        _GDIPlus_GraphicsDrawEllipse($hBackbuffer, $pen_size / 2, $pen_size / 2, $w - $pen_size, $h - $pen_size, $hPen)

        If $countdown > 0 Then
            _GDIPlus_PenSetColor($hPen, "0xFF" & $randomColor)
            _GDIPlus_GraphicsDrawArc($hBackbuffer, $pen_size / 2, $pen_size / 2, $w - $pen_size, $h - $pen_size, -90, -360 + $angle, $hPen1)
            _GDIPlus_GraphicsDrawArc($hBackbuffer, $pen_size / 2, $pen_size / 2, $w - $pen_size, $h - $pen_size, -90, $angle, $hPen)
            _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $w, $h)
        EndIf
;~
        If TimerDiff($timer) >= $t_calc Then
            $countdown -= $t_calc / 1000
            $timer = TimerInit()
            $angle = 360 * $countdown / $countdown_t
            $z += 2
        EndIf

        If $angle < 3 Then
            $angle = 360
            $timer = TimerInit()
            $countdown_t = 3
            $countdown = $countdown_t
            $lastcolor = $randomColor
            $randomColor = Execute("0xFF" & Hex(Random(0x000000, 0xFFFFFF), 6))
        EndIf
    WEnd
    _GDIPlus_GraphicsDispose($hGraphics)
    _WinAPI_DeleteObject($hBitmap)
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_PenDispose($hPen1)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Circle

Func Max($a, $b)
    If $a >= $b Then
        Return $a
    Else
        Return $b
    EndIf

EndFunc ;==>Max


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Try this:

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#Include <Misc.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)

_GDIPlus_Startup()

$hGUI = GUICreate("Mark screen by UEZ", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_LAYERED)
GUISetBkColor(0xABCDEF)
_WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 0x60)
GUISetState()

$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
;~ _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2)
_GDIPlus_GraphicsClear($hGraphic, 0xFFABCDEF)
$hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFF00)

GUISetOnEvent(-3, "_Exit")
OnAutoItExitRegister("_Exit")
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "Draw", $hGUI)

Global $om = MouseGetCursor()
GUISetCursor(5, 1, $hGUI)

While Sleep(100000)
WEnd

Func Draw()
    Local Const $w = 8, $h = 16
    Local Const $w2 = $w / 2, $h2 = $h / 2
    Local $aMC
    Do
        GUISetCursor(5, 1, $hGUI)
        $aMPos = MouseGetPos()
        _GDIPlus_GraphicsFillRect($hGraphic, $aMPos[0] - $w2, $aMPos[1] - $h2, $w, $h, $hBrush)
        $aMC = GUIGetCursorInfo($hGUI)
    Until Not $aMC[2]
EndFunc

Func _Exit()
    GUISetCursor($om, 1, $hGUI)
    GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "")
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
    Exit
EndFunc

It will mark the area while you press the left mouse button.

Tested on Win7 x64 + Aero only.

Br,

UEZ

Edited by 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

#8 ·  Posted (edited)

Try this:

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#Include <Misc.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)

_GDIPlus_Startup()

$hGUI = GUICreate("Mark screen by UEZ", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_LAYERED)
GUISetBkColor(0xABCDEF)
_WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 0x60)
GUISetState()

$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
;~ _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2)
_GDIPlus_GraphicsClear($hGraphic, 0xFFABCDEF)
$hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFF00)

GUISetOnEvent(-3, "_Exit")
OnAutoItExitRegister("_Exit")
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "Draw", $hGUI)

Global $om = MouseGetCursor()
GUISetCursor(5, 1, $hGUI)

While Sleep(100000)
WEnd

Func Draw()
    Local Const $w = 8, $h = 16
    Local Const $w2 = $w / 2, $h2 = $h / 2
    Local $aMC
    Do
        GUISetCursor(5, 1, $hGUI)
        $aMPos = MouseGetPos()
        _GDIPlus_GraphicsFillRect($hGraphic, $aMPos[0] - $w2, $aMPos[1] - $h2, $w, $h, $hBrush)
        $aMC = GUIGetCursorInfo($hGUI)
    Until Not $aMC[2]
EndFunc

Func _Exit()
    GUISetCursor($om, 1, $hGUI)
    GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "")
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
    Exit
EndFunc

It will mark the area while you press the left mouse button.

Tested on Win7 x64 only.

Br,

UEZ

This does not work on XP sp3 - thanks for your help though

EDIT XP not SP (duh)

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

this may do what your edit asks

looking into code today - thanks for your help

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Hmmm, my code seems to be running properly only when Aero is enabled.

Br,

UEZ

Edited by 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

Hi,

because I've translated just some old WinApi/GDI+ examples from A3lib / PaulIA here a quick translation from above address "drow-on-screen". Which works, but could be polished :-)

HTH, Reinhard

#include <misc.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Dim $Mpos_1 = "", $Mpos_1A = "", $Mpos_2 = "", $Mpos_2A = "", $line = ""
$LineColor = 0x00ff00; color BGR
$LineWidth = 5

HotKeySet( "{ESC}", "Get_Exit")

While 1
   ;Sleep(1)
    Global $hnd = _WinAPI_GetDesktopWindow()
    If _IsPressed(1) Then
        While _IsPressed(1)
            Local $firstPos = MouseGetPos()
            DrawBox($firstPos[0],$firstPos[1],$firstPos[0]+1,$firstPos[1]+1)
        WEnd
    EndIf
_WinAPI_RedrawWindow($hnd,Default,Default,$RDW_ERASENOW)
WEnd

Func Get_pos_one()
    GUICtrlDelete($line)
    $Ms_In = MouseGetPos()
    $Mpos_1 = $Ms_In[0]
    $Mpos_2 = $Ms_In[1]

EndFunc ;==>Get_pos_one

Func Get_pos_two()
    GUICtrlDelete($line)
    $Ms_In2 = MouseGetPos()
    $Mpos_1A = $Ms_In2[0]
    $Mpos_2A = $Ms_In2[1]

EndFunc ;==>Get_pos_two

Func DrawBox($firstPos_x, $firstPos_y, $secondPos_x, $secondPos_y)

    If $firstPos_x = "" Or $secondPos_x = "" Then
        Return
    EndIf

    $hd = DllCall("user32.dll", "int", "GetDC", "hwnd", 0)
    $pen = DllCall("gdi32.dll", "int", "CreatePen", "int", 0, "int", $LineWidth, "int", $LineColor)
    DllCall("gdi32.dll", "int", "SelectObject", "int", $hd[0], "int", $pen[0])
    DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hd[0], "int", $firstPos_x, "int", $firstPos_y, "int", 0)
    DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hd[0], "int", $secondPos_x, "int", $secondPos_y)
    DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $hd[0])

EndFunc ;==>Get_drawing

Func Get_Exit()
    Exit
EndFunc ;==>Get_Exit

Share this post


Link to post
Share on other sites

Here another one, I saved some time ago.

You may search for some words to get the discussion / author.

HTH, Reinhard

HotKeySet ("d", "Draw")
HotKeySet ("^e", "MyExit")
MsgBox (4096, "NOTE", "Press 'D' to draw and Ctrl+E to exit... The default color is Green.")

Func SetPixel ($handle, $x, $y, $color)
    $dc= DllCall ("user32.dll", "int", "GetDC", "hwnd", $handle)
    DllCall ("gdi32.dll", "long", "SetPixel", "long", $dc[0], "long", $x, "long", $y, "long", $color)
    DllCall ("user32.dll", "int", "ReleaseDC", "hwnd", 0,  "int", $dc[0])
EndFunc





Func Draw ()
    $pos= MouseGetPos ()
    SetPixel ("", $pos[0], $pos[1], 0x00FF00)
    Sleep (10)
EndFunc

Func MyExit ()
    Exit
EndFunc

While 1

        $pos= MouseGetPos ()
        SetPixel ("", $pos[0], $pos[1], 0x00FF00)

    ;Sleep (100)
wend

Share this post


Link to post
Share on other sites

Thanks for the code - I will have to play later - at work...but thanks for the reply and help.


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

Try this for non Aero desktops.

#include <GUIConstantsEx.au3>
#Include <Misc.au3>
#include <ScreenCapture.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)

_GDIPlus_Startup()
Global $hBitmap = _ScreenCapture_Capture("", 0, 0, @DesktopWidth, @DesktopHeight, 0)
Global $hBmp = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

Global $hGUI = GUICreate("Mark screen by UEZ", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)

Global $hDC_Draw = _WinAPI_GetWindowDC($hGUI)
Global $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC_Draw)
Global $hBitmap_backbuffer = _WinAPI_CreateCompatibleBitmap($hDC_Draw, @DesktopWidth, @DesktopHeight)
Global $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hBitmap_backbuffer)
Global $backbuffer = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer)
_GDIPlus_GraphicsDrawImage($backbuffer, $hBmp, 0, 0)

GUISetState()
_WinAPI_BitBlt($hDC_Draw, 0, 0, @DesktopWidth, @DesktopHeight, $hDC_backbuffer, 0, 0, $SRCCOPY)
_WinAPI_SelectObject($hDC_Draw, $DC_obj)
_WinAPI_DeleteDC($hDC_backbuffer)
_WinAPI_DeleteObject($hBitmap_backbuffer)
_WinAPI_DeleteObject($hBitmap)
_GDIPlus_BitmapDispose($hBmp)
_GDIPlus_Shutdown()

Global $hBrush = _WinAPI_CreateSolidBrush(0x0000FF) ;BGR
Global $obj_orig = _WinAPI_SelectObject($hDC_Draw, $hBrush)
_WinAPI_SetBkMode($hDC_Draw, $TRANSPARENT)
Global $tRECT = DllStructCreate($tagRect)


GUISetOnEvent(-3, "_Exit")
OnAutoItExitRegister("_Exit")
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "Draw", $hGUI)

Global $om = MouseGetCursor()

While Sleep(1000000)
WEnd

Func Draw()
    Local $aMC
    Local Const $w = 8, $h = 16
    Local Const $w2 = $w / 2, $h2 = $h / 2
    Do
        GUISetCursor(0, 1, $hGUI)
        $aMPos = MouseGetPos()
        DllStructSetData($tRECT, "Left", $aMPos[0])
        DllStructSetData($tRECT, "Top", $aMPos[1])
        DllStructSetData($tRECT, "Right", $aMPos[0] + $w2)
        DllStructSetData($tRECT, "Bottom", $aMPos[1] + $h2)
        _WinAPI_FillRect($hDC_Draw, DllStructGetPtr($tRect), $hBrush)
        $aMC = GUIGetCursorInfo($hGUI)
    Until Not $aMC[2]
EndFunc

Func _Exit()
    GUISetCursor($om, 1, $hGUI)
    GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "")
    _WinAPI_SelectObject($hDC_Draw, $obj_orig)
    _WinAPI_DeleteObject($hBrush)
    _WinAPI_ReleaseDC(0, $hDC_Draw)
    $tRECT = 0
    GUIDelete($hGUI)
    Exit
EndFunc

Maybe it is not an elegant code...

Tell me if it is working for you.

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

#15 ·  Posted (edited)

Hi,

very impressive script - like ever - and works good on XP.

But I would use/prefer to use something like:

$hPen = _GDIPlus_PenCreate(0x55000099,4) ;ARGB color

_GDIPlus_GraphicsDrawLine($hGraphics, $iX1, $iY1, $iX2, $iY2, $hPen)

that avoid broken lines and with ARGB you can set the transparency (A), which may be usefull.

I'm not real good at this, but I just startet to write tracks on my maps.

However, it's on nitekram's side to decide, where to go.

best regards, Reinhard

PS: iamtheky's cicle runs now for one hour on my screen. Can that somehow stopped :-)

Edited by ReFran

Share this post


Link to post
Share on other sites

in my defense i only use the circle in a PE environment where its almost mandatory to run as a separate process to get smooth movement. so the intended behavior is to run until killed.


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Another version which should run properly also on non Aero desktops and WinXP:

#Include <ScreenCapture.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)

_GDIPlus_Startup()

Global Const $HBITMAP = _ScreenCapture_Capture("", 0, 0, @DesktopWidth, @DesktopHeight, 0)

Global Const $hGUI = GUICreate("Mark screen by UEZ", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
GUISetState(@SW_SHOW, $hGUI)

Global Const $hGraphic_Bg = _GDIPlus_GraphicsCreateFromHWND($hGUI)
Global Const $hBmp = _GDIPlus_BitmapCreateFromHBITMAP($HBITMAP)
_GDIPlus_GraphicsDrawImage($hGraphic_Bg, $hBmp, 0, 0)
_WinAPI_DeleteObject($HBITMAP)

Global Const $pen_size = 8
Global Const $hPen = _GDIPlus_PenCreate(0xA0FFFF00, $pen_size)

GUISetOnEvent(-3, "_Exit")
OnAutoItExitRegister("_Exit")
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "Draw", $hGUI)

Global Const $om = MouseGetCursor()

While Sleep(100000)
WEnd

Func Draw()
    Local $aMC, $mxo, $myo
    $aMC = GUIGetCursorInfo($hGUI)
    Sleep(50)
    Do
        GUISetCursor(0, 1, $hGUI)
        $mxo = $aMC[0]
        $myo = $aMC[1]
        $aMC = GUIGetCursorInfo($hGUI)
        If $mxo <> $aMC[0] Or $myo <> $aMC[1] Then
            _GDIPlus_GraphicsDrawLine($hGraphic_Bg, $aMC[0], $aMC[1], $mxo, $myo, $hPen)
            $mxo = $aMC[0]
            $myo = $aMC[1]
        EndIf
    Until Not $aMC[2]
EndFunc

Func _Exit()
    GUISetCursor($om, 1, $hGUI)
    GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "")
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic_Bg)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
    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

#18 ·  Posted (edited)

Fantastic UEZ,

that should it make real easy to me writing polylines as tracks and save it.

For testing I worked with a penwidth of 4 and ARGB colour 0x55000099 (ca. 50% transparency).

Looks good and it seems to work stabil on XP.

Hopefully it's also that what nitekram wanted.

Thanks very much,

Reinhard

PS: During the first test I went out to get a cup of coffee. As I returned the screen was gray. After pressing ESC the screendisplay recovered. I tried to repeat that. But after some cups of coffee I gave up, because that may not very health. So the gray screen may have been triggered from another open application.

Edited by ReFran

Share this post


Link to post
Share on other sites

Another version which should run properly also on non Aero desktops and WinXP:

Br,

UEZ

Awsome...thanks so much for your help - this will get me started on my project and thanks again for your help...just want to know if the Start (taskbar) is supposed to turn off color (all applications/shortcuts/time/date disappear from taskbar (OS = XP SP3)). Not really to concerned as it comes back after hitting ESC key, but just wondering.


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

As you can see the code takes a screenshot from the active screen and you can do your paintings on it. The real desktop is behind. :huh2:

Of course it is possible to paint directly to the main screen but when the screen receives a refresh all your paintings will be erased. I tried to paint with polygones but it makes not much sense when using 2 different points.

This is a very basic code and has enough place for improvements. Go ahead.

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

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