Sign in to follow this  
Followers 0
Markus

Drawing in AutoIt

8 posts in this topic

How to draw live and without window reactivation?

#include <GUIConstants.au3>
#include <misc.au3>
Global $vorher_x_pos=0,$vorher_y_pos=0
Global $storaged_x_pos[10000],$storaged_y_pos[10000]
Global $count=0
Opt("MouseCoordMode", 0)  
$child=GUICreate("My Draw",600,600)
$a=GuiCtrlCreateGraphic(0, 0, 600,600)
GUICtrlSetBkColor(-1,0xffffff)
GUICtrlSetColor(-1,0)
GUISetState()
Do
    $msg=GUIGetMsg()
    If _IsPressed(01) Then
        While _IsPressed(01) 
            $pos=MouseGetPos()
            If $pos[0]-4<>$vorher_x_pos Or $pos[1]-30<>$vorher_y_pos Then
                $storaged_x_pos[$count]=$pos[0]-4
                $storaged_y_pos[$count]=$pos[1]-30 
                $vorher_x_pos=$storaged_x_pos[$count]
                $vorher_y_pos=$storaged_y_pos[$count]
                $count+=1
            EndIf
        WEnd
        For $i=1 To $count
            GUICtrlSetGraphic ($a, $GUI_GR_PIXEL ,$storaged_x_pos[$i], $storaged_y_pos[$i])
        Next
        GUISetState(@SW_HIDE)
        GUISetState()
        $count=1
    EndIf
Until $msg=$GUI_EVENT_CLOSE

"It's easier to disintegrate an atom than a prejudice." (A.Einstein)---------------------------------------------------------------------------My C++ - tools:Tidy tool-->indents your c++ sourceCleanscript --> cleans autoit-code before compiling (co-author: peethebee)My tools:GUIBuilder-->build your window and get the source; german versionMy Games:OnlineGameCenter-->Online Chess and Connect4 with a rtf-chatSnake-->including a level editor to build your own levelsTetris-->the well known game, big funOther things:Tower of Hanoi-->perfect riddler with graphic output

Share this post


Link to post
Share on other sites



But it's an example script :whistle:

OK, i have to admit that my question is verbalized that way, that i should have posted it in the support forum...


"It's easier to disintegrate an atom than a prejudice." (A.Einstein)---------------------------------------------------------------------------My C++ - tools:Tidy tool-->indents your c++ sourceCleanscript --> cleans autoit-code before compiling (co-author: peethebee)My tools:GUIBuilder-->build your window and get the source; german versionMy Games:OnlineGameCenter-->Online Chess and Connect4 with a rtf-chatSnake-->including a level editor to build your own levelsTetris-->the well known game, big funOther things:Tower of Hanoi-->perfect riddler with graphic output

Share this post


Link to post
Share on other sites

GUICtrlSetGraphic($a, $GUI_GR_REFRESH)

#include <GUIConstants.au3>
#include <misc.au3>
Global $vorher_x_pos=0,$vorher_y_pos=0
Global $storaged_x_pos[10000],$storaged_y_pos[10000]
Global $count=0
Opt("MouseCoordMode", 0)  
$child=GUICreate("My Draw",600,600)
$a=GuiCtrlCreateGraphic(0, 0, 600,600)
GUICtrlSetBkColor(-1,0xffffff)
GUICtrlSetColor(-1,0)
GUISetState()
Do
    $msg=GUIGetMsg()
    If _IsPressed(01) Then
        While _IsPressed(01)
            $pos=MouseGetPos()
            If $pos[0]-4<>$vorher_x_pos Or $pos[1]-30<>$vorher_y_pos Then
                $storaged_x_pos[$count]=$pos[0]-4
                $storaged_y_pos[$count]=$pos[1]-30
                $vorher_x_pos=$storaged_x_pos[$count]
                $vorher_y_pos=$storaged_y_pos[$count]
                $count+=1
            EndIf
        WEnd
        For $i=1 To $count
            GUICtrlSetGraphic ($a, $GUI_GR_PIXEL ,$storaged_x_pos[$i], $storaged_y_pos[$i])
        Next
        GUICtrlSetGraphic($a, $GUI_GR_REFRESH)
        $count=1
    EndIf
Until $msg=$GUI_EVENT_CLOSE

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

Share this post


Link to post
Share on other sites

Wow! it's realy cool!

I didn't know that it is possible to drowing with AutoIt!

Here how you can drown "on-fly" (see what you drowing):

#include <GUIConstants.au3>
Opt("MouseCoordMode", 0)  
Global $vorher_x_pos=0,$vorher_y_pos=0

$child=GUICreate("My Draw",600,600)
$a=GuiCtrlCreateGraphic(0, 0, 600,600)
GUISetState()

Do
    $msg=GUIGetMsg()
    $CurInfo = GUIGetCursorInfo()
    If IsArray($CurInfo) And $CurInfo[2] = 1 Then
       AdlibEnable("Refresh", 10)
        While $CurInfo[2] = 1
            $CurInfo = GUIGetCursorInfo()
            If $CurInfo[0]-4 <> $vorher_x_pos Or $CurInfo[1]-30 <> $vorher_y_pos Then
                $vorher_x_pos = $CurInfo[0]-4
                $vorher_y_pos = $CurInfo[1]-30
                GUICtrlSetGraphic($a, $GUI_GR_PIXEL, $vorher_x_pos, $vorher_y_pos)
            EndIf
        WEnd
        AdlibDisable()
    EndIf
    
Until $msg=$GUI_EVENT_CLOSE

Func Refresh()
    GUICtrlSetGraphic($a, $GUI_GR_REFRESH)
EndFunc

If you set the backcolour of graphic to white, then you see a litle "flicking" of window when its refreshing.


Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Here is a quick modification to thicken the "ink"...

#include <GUIConstants.au3>
Opt("MouseCoordMode", 0)  
Global $vorher_x_pos=0,$vorher_y_pos=0

$child=GUICreate("My Draw",600,600)
$a=GuiCtrlCreateGraphic(0, 0, 600,600)
GUISetState()

Do
    $msg=GUIGetMsg()
    $CurInfo = GUIGetCursorInfo()
    If IsArray($CurInfo) And $CurInfo[2] = 1 Then
       AdlibEnable("Refresh", 10)
        While $CurInfo[2] = 1
            $CurInfo = GUIGetCursorInfo()
            If $CurInfo[0]-4 <> $vorher_x_pos Or $CurInfo[1]-30 <> $vorher_y_pos Then
                $vorher_x_pos = $CurInfo[0]-4
                $vorher_y_pos = $CurInfo[1]-30
                GUICtrlSetGraphic($a, $GUI_GR_PIXEL, $vorher_x_pos, $vorher_y_pos)
                GUICtrlSetGraphic($a, $GUI_GR_PIXEL, $vorher_x_pos+1, $vorher_y_pos+1)
                GUICtrlSetGraphic($a, $GUI_GR_PIXEL, $vorher_x_pos-1, $vorher_y_pos-1)
                GUICtrlSetGraphic($a, $GUI_GR_PIXEL, $vorher_x_pos+1, $vorher_y_pos-1)
                GUICtrlSetGraphic($a, $GUI_GR_PIXEL, $vorher_x_pos-1, $vorher_y_pos+1)
            EndIf
        WEnd
        AdlibDisable()
    EndIf
    
Until $msg=$GUI_EVENT_CLOSE

Func Refresh()
    GUICtrlSetGraphic($a, $GUI_GR_REFRESH)
EndFunc

"I've seen your work in the past, and it's novice at best..." SmOke_N

Share this post


Link to post
Share on other sites

Found the $GUI_GR_DOT syntax ...

#include <GUIConstants.au3>
Opt("MouseCoordMode", 0)  
Global $vorher_x_pos=0,$vorher_y_pos=0

$child=GUICreate("My Draw",600,600)
$a=GuiCtrlCreateGraphic(0, 0, 600,600)
GUISetState()

Do
    $msg=GUIGetMsg()
    $CurInfo = GUIGetCursorInfo()
    If IsArray($CurInfo) And $CurInfo[2] = 1 Then
       AdlibEnable("Refresh", 10)
        While $CurInfo[2] = 1
            $CurInfo = GUIGetCursorInfo()
            If $CurInfo[0]-4 <> $vorher_x_pos Or $CurInfo[1]-30 <> $vorher_y_pos Then
                $vorher_x_pos = $CurInfo[0]-4
                $vorher_y_pos = $CurInfo[1]-30
                GUICtrlSetGraphic($a, $GUI_GR_Dot, $vorher_x_pos, $vorher_y_pos)
            EndIf
        WEnd
        AdlibDisable()
    EndIf
    
Until $msg=$GUI_EVENT_CLOSE

Func Refresh()
    GUICtrlSetGraphic($a, $GUI_GR_REFRESH)
EndFunc

"I've seen your work in the past, and it's novice at best..." SmOke_N

Share this post


Link to post
Share on other sites

And to get even more obsessive-compulsive, this fills in the center of the Dot...

#include <GUIConstants.au3>
Opt("MouseCoordMode", 0)  
Global $vorher_x_pos=0,$vorher_y_pos=0

$child=GUICreate("My Draw",600,600)
$a=GuiCtrlCreateGraphic(0, 0, 600,600)
GUISetState()

Do
    $msg=GUIGetMsg()
    $CurInfo = GUIGetCursorInfo()
    If IsArray($CurInfo) And $CurInfo[2] = 1 Then
       AdlibEnable("Refresh", 10)
        While $CurInfo[2] = 1
            $CurInfo = GUIGetCursorInfo()
            If $CurInfo[0]-4 <> $vorher_x_pos Or $CurInfo[1]-30 <> $vorher_y_pos Then
                $vorher_x_pos = $CurInfo[0]-4
                $vorher_y_pos = $CurInfo[1]-30
                GUICtrlSetGraphic($a, $GUI_GR_Dot, $vorher_x_pos, $vorher_y_pos)
    GUICtrlSetGraphic($a, $GUI_GR_PIXEL, $vorher_x_pos, $vorher_y_pos)
            EndIf
        WEnd
        AdlibDisable()
    EndIf
    
Until $msg=$GUI_EVENT_CLOSE

Func Refresh()
    GUICtrlSetGraphic($a, $GUI_GR_REFRESH)
EndFunc

"I've seen your work in the past, and it's novice at best..." SmOke_N

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