Jump to content

Recommended Posts

Posted

Hi!

Here's a basic idea:

#include <GDIPlus.au3>
#include <misc.au3>
Opt("GUIOnEventMode",1)
Opt("MouseCoordMode",2)
$hwnd=GUICreate("Sample",400,400)
GUISetOnEvent(-3,"close")
GUISetState()

_GDIPlus_Startup()
$graphics=_GDIPlus_GraphicsCreateFromHWND($hwnd)
_GDIPlus_GraphicsClear($graphics,0xFFFFFFFF)
$brush=_GDIPlus_BrushCreateSolid(0xFF000000)

$dll=DllOpen("user32.dll")

Do
    If _IsPressed("01",$dll) Then
        _GDIPlus_GraphicsFillRect($graphics,MouseGetPos(0),MouseGetPos(1),2,2,$brush)
        Do
            Sleep(25)
        Until Not _IsPressed("01",$dll)
    EndIf
    Sleep(25)
Until False



Func close()
    _GDIPlus_BrushDispose($brush)
    _GDIPlus_GraphicsDispose($graphics)
    _GDIPlus_Shutdown()
    Exit
EndFunc

muttley

Broken link? PM me and I'll send you the file!

Posted

Thanks monoceres, it`s perfect. If I want to switch colors (red, yellow, blue,pink,...) I should modify brush color?

$brush=_GDIPlus_BrushCreateSolid(0xFF000000)

Posted

Thanks monoceres, it`s perfect. If I want to switch colors (red, yellow, blue,pink,...) I should modify brush color?

$brush=_GDIPlus_BrushCreateSolid(0xFF000000)
Yup muttley

Broken link? PM me and I'll send you the file!

Posted

How can I do, if I don't release mouse left click, to continue drawing, like in paint.

Add this to the Do...Until loop inside the If statement:

$pos = MouseGetPos()
_GDIPlus_GraphicsFillRect($graphics, $pos[0], $pos[1], 2, 2, $brush)

You should also remove the sleep.

Broken link? PM me and I'll send you the file!

Posted (edited)

I made a even better version, it now acts just like paint muttley

#include <GDIPlus.au3>
#include <misc.au3>
Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 2)
$hwnd = GUICreate("Sample", 400, 400)
GUISetOnEvent(-3, "close")
GUISetState()

_GDIPlus_Startup()
$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
_GDIPlus_GraphicsClear($graphics, 0xFFFFFFFF)
$pen = _GDIPlus_PenCreate(0xFF00FF00)

$dll = DllOpen("user32.dll")

Do
    If _IsPressed("01", $dll) And WinActive("Sample") Then
        $oldpos=MouseGetPos()
        _GDIPlus_GraphicsDrawRect($graphics,$oldpos[0],$oldpos[1],1,1,$pen)
        Do
            $pos = MouseGetPos()
            _GDIPlus_GraphicsDrawLine($graphics,$oldpos[0],$oldpos[1],$pos[0],$pos[1],$pen)
            $oldpos=$pos
        Until Not _IsPressed("01", $dll)
    EndIf
    Sleep(25)
Until False



Func close()
    _GDIPlus_PenDispose($pen)
    _GDIPlus_GraphicsDispose($graphics)
    _GDIPlus_Shutdown()
    Exit
EndFunc  ;==>close
Edited by monoceres

Broken link? PM me and I'll send you the file!

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
×
×
  • Create New...