Jump to content

Drawing "on the screen".


AzKay
 Share

Recommended Posts

Any ideas on drawing "on screen"?

For example, mspaint, but drawing on the screen using coords, and colour.

Grease pencil is OK on CRTs, but messy. Don't even TRY felt tip markers! My kids experimented on my monitors with crayons years ago, but it doesn't fill in well (thankfully)...

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

OH YOU CRIMINAL.

Now I gotta clean the screen. AGAIN.

:)

TIME TO REPHRASE.

Ive seen a few scripts that have used functions, dllcalls I believe, to draw lines.

I want that, But to draw 1x1 pixels. With colour.

Edited by AzKay
# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

This was another thread about drawing lines on the screen: Draw?, Nothing too hard, but I can't figure this out

Hope that helps.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Grease pencil is OK on CRTs, but messy. Don't even TRY felt tip markers! My kids experimented on my monitors with crayons years ago, but it doesn't fill in well (thankfully)...

:)

Hmm... Sharpies work too!

Just use some 70% Isopropyl to clean it off.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

This was another thread about drawing lines on the screen: Draw?, Nothing too hard, but I can't figure this out

Hope that helps.

:)

Yeah, that's my thread :P

I don't wanna open a new thread and since you guys are talking about this, I'll ask my question.

I wanted to make a script to draw a line from a point on the screen, that is set by a click, to the current position of the mouse. This works:

#Include <Misc.au3>
#include <Guiconstants.au3>
#include <Constants.au3>
HotKeySet("{F10}","_exit")
$Color=0x94DF08
$Wh=GUICreate("",@DesktopWidth,@DesktopHeight,-1,-1,-1)
$LabID=GUICtrlCreateEdit("",0,0,@DesktopWidth-1,@DesktopHeight-1,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
;~ WinSetTrans($Wh,"",170)
GUICtrlSetCursor(-1,3)
GUISetState()

While 1

If _IsPressed(01) Then
    $LPos = MouseGetPos()
Do 

    GUICtrlSetData($LabID,"")
    $LPos1 = MouseGetPos()
    dibujar()
    Sleep(25)
Until NOT _IsPressed(01)

EndIf
Sleep(50)
WEnd
Func dibujar()
    $hand = DllCall("user32.dll","int", "GetDC", "hwnd", 0)
    $pen = DllCall("gdi32.dll", "int", "CreatePen", "int", 0 , "int",2, "int", $Color)
    DllCall("gdi32.dll", "int", "SelectObject", "int", $hand[0], "int", $pen[0])
    DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hand[0], "int", $LPos[0], "int", $LPos[1], "int", 0)
    DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hand[0], "int", $LPos1[0], "int", $LPos1[1])
EndFunc
Func _exit()
    Exit
EndFunc

BUT it's useless! I want it to be on the screen and not on a control. So I thought that making the GUI a bit transparent would fix it, but no, it draws BEHIND the GUI :) (uncomment the WinSetTrans part to see).

Why does this happen and how could I fix it?

Link to comment
Share on other sites

Yeah, that's my thread :)

I don't wanna open a new thread and since you guys are talking about this, I'll ask my question.

I wanted to make a script to draw a line from a point on the screen, that is set by a click, to the current position of the mouse. This works:

#Include <Misc.au3>
#include <Guiconstants.au3>
#include <Constants.au3>
HotKeySet("{F10}","_exit")
$Color=0x94DF08
$Wh=GUICreate("",@DesktopWidth,@DesktopHeight,-1,-1,-1)
$LabID=GUICtrlCreateEdit("",0,0,@DesktopWidth-1,@DesktopHeight-1,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
;~ WinSetTrans($Wh,"",170)
GUICtrlSetCursor(-1,3)
GUISetState()

While 1

If _IsPressed(01) Then
    $LPos = MouseGetPos()
Do 

    GUICtrlSetData($LabID,"")
    $LPos1 = MouseGetPos()
    dibujar()
    Sleep(25)
Until NOT _IsPressed(01)

EndIf
Sleep(50)
WEnd
Func dibujar()
    $hand = DllCall("user32.dll","int", "GetDC", "hwnd", 0)
    $pen = DllCall("gdi32.dll", "int", "CreatePen", "int", 0 , "int",2, "int", $Color)
    DllCall("gdi32.dll", "int", "SelectObject", "int", $hand[0], "int", $pen[0])
    DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hand[0], "int", $LPos[0], "int", $LPos[1], "int", 0)
    DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hand[0], "int", $LPos1[0], "int", $LPos1[1])
EndFunc
Func _exit()
    Exit
EndFunc

BUT it's useless! I want it to be on the screen and not on a control. So I thought that making the GUI a bit transparent would fix it, but no, it draws BEHIND the GUI :) (uncomment the WinSetTrans part to see).

Why does this happen and how could I fix it?

Maybe you can try the code below:

#Include <Misc.au3>
#include <Guiconstants.au3>
#include <Constants.au3>
HotKeySet("{F10}","_exit")
$Color=0x94DF08
;$Wh=GUICreate("",@DesktopWidth,@DesktopHeight,

If _IsPressed(01) Then
    $LPos = MouseGetPos()
Do 

   ;GUICtrlSetData($LabID,"")
    $LPos1 = MouseGetPos()
    dibujar()
    Sleep(25)
Until NOT _IsPressed(01)

EndIf
Sleep(50)
WEnd
Func dibujar()
    $hand = DllCall("user32.dll","int", "GetDC", "hwnd", 0)
    $pen = DllCall("gdi32.dll", "int", "CreatePen", "int", 0 , "int",2, "int", $Color)
    DllCall("gdi32.dll", "int", "SelectObject", "int", $hand[0], "int", $pen[0])
    DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hand[0], "int", $LPos[0], "int", $LPos[1], "int", 0)
    DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hand[0], "int", $LPos1[0], "int", $LPos1[1])
EndFunc
Func _exit()
    Exit
EndFunc
Link to comment
Share on other sites

Mayby you need to open internet explorer and close it so all lines will disapear ??

I dont know what the parameters of Internet.lnk are so:

#Include <Misc.au3>
#include <Guiconstants.au3>
#include <Constants.au3>
HotKeySet("{F10}","_exit")
HotKeySet("{F11}", "_EmptyScreen") 
$Color=0x94DF08
;$Wh=GUICreate("",@DesktopWidth,@DesktopHeight,

While 1
If _IsPressed(01) Then
    $LPos = MouseGetPos()
Do 

   ;GUICtrlSetData($LabID,"")
    $LPos1 = MouseGetPos()
    dibujar()
    Sleep(25)
Until NOT _IsPressed(01)

EndIf
Sleep(50)
WEnd
Func dibujar()
    $hand = DllCall("user32.dll","int", "GetDC", "hwnd", 0)
    $pen = DllCall("gdi32.dll", "int", "CreatePen", "int", 0 , "int",2, "int", $Color)
    DllCall("gdi32.dll", "int", "SelectObject", "int", $hand[0], "int", $pen[0])
    DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hand[0], "int", $LPos[0], "int", $LPos[1], "int", 0)
    DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hand[0], "int", $LPos1[0], "int", $LPos1[1])
EndFunc

Func _EmptyScreen()
$empty_screen = ShellExecute("Internet.lnk", "parameter", "open", @SW_MAXIMIZE) 
Send("!{f4}") 
EndFunc

Func _exit()
    Exit
EndFunc

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

Mayby you need to open internet explorer and close it so all lines will disapear ??

I dont know what the parameters of Internet.lnk are so:

#Include <Misc.au3>
#include <Guiconstants.au3>
#include <Constants.au3>
HotKeySet("{F10}","_exit")
HotKeySet("{F11}", "_EmptyScreen") 
$Color=0x94DF08
;$Wh=GUICreate("",@DesktopWidth,@DesktopHeight,

While 1
If _IsPressed(01) Then
    $LPos = MouseGetPos()
Do 

   ;GUICtrlSetData($LabID,"")
    $LPos1 = MouseGetPos()
    dibujar()
    Sleep(25)
Until NOT _IsPressed(01)

EndIf
Sleep(50)
WEnd
Func dibujar()
    $hand = DllCall("user32.dll","int", "GetDC", "hwnd", 0)
    $pen = DllCall("gdi32.dll", "int", "CreatePen", "int", 0 , "int",2, "int", $Color)
    DllCall("gdi32.dll", "int", "SelectObject", "int", $hand[0], "int", $pen[0])
    DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hand[0], "int", $LPos[0], "int", $LPos[1], "int", 0)
    DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hand[0], "int", $LPos1[0], "int", $LPos1[1])
EndFunc

Func _EmptyScreen()
$empty_screen = ShellExecute("Internet.lnk", "parameter", "open", @SW_MAXIMIZE) 
Send("!{f4}") 
EndFunc

Func _exit()
    Exit
EndFunc
Mmm no.. that'd make it slow and would cover the screen.

And why not use Run and ProcessClose?

Link to comment
Share on other sites

tO KEEP THE LINES ON THE SCREEN,wHY NOT USE ARRAY TO REMEMBER THE POINTS WHILE YOU GETTING ANY POS?

That's not the problem. He wants to move the line or remove the previous line and redraw it in another position. But it's a line of bit-mapped points, not a vector object, so it can't be "moved".

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

tO KEEP THE LINES ON THE SCREEN,wHY NOT USE ARRAY TO REMEMBER THE POINTS WHILE YOU GETTING ANY POS?

Lol... He want to get the lines OF the screen (Screen Refresh)

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

That's not the problem. He wants to move the line or remove the previous line and redraw it in another position. But it's a line of bit-mapped points, not a vector object, so it can't be "moved".

:)

Exactly. I still don't know why the script draws behind my semi-transparent GUI. It works great as long as I don't use WinSetTrans, even if I set it to 255(solid).

Could there be an alternate method to draw a line?

Link to comment
Share on other sites

Yeah, that's my thread :)

I don't wanna open a new thread and since you guys are talking about this, I'll ask my question.

I wanted to make a script to draw a line from a point on the screen, that is set by a click, to the current position of the mouse. This works:

#Include <Misc.au3>
#include <Guiconstants.au3>
#include <Constants.au3>
HotKeySet("{F10}","_exit")
$Color=0x94DF08
$Wh=GUICreate("",@DesktopWidth,@DesktopHeight,-1,-1,-1)
$LabID=GUICtrlCreateEdit("",0,0,@DesktopWidth-1,@DesktopHeight-1,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
;~ WinSetTrans($Wh,"",170)
GUICtrlSetCursor(-1,3)
GUISetState()

While 1

If _IsPressed(01) Then
    $LPos = MouseGetPos()
Do 

    GUICtrlSetData($LabID,"")
    $LPos1 = MouseGetPos()
    dibujar()
    Sleep(25)
Until NOT _IsPressed(01)

EndIf
Sleep(50)
WEnd
Func dibujar()
    $hand = DllCall("user32.dll","int", "GetDC", "hwnd", 0)
    $pen = DllCall("gdi32.dll", "int", "CreatePen", "int", 0 , "int",2, "int", $Color)
    DllCall("gdi32.dll", "int", "SelectObject", "int", $hand[0], "int", $pen[0])
    DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hand[0], "int", $LPos[0], "int", $LPos[1], "int", 0)
    DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hand[0], "int", $LPos1[0], "int", $LPos1[1])
EndFunc
Func _exit()
    Exit
EndFunc

BUT it's useless! I want it to be on the screen and not on a control. So I thought that making the GUI a bit transparent would fix it, but no, it draws BEHIND the GUI :) (uncomment the WinSetTrans part to see).

Why does this happen and how could I fix it?

Here's a step towards a solution maybe

#Include <Misc.au3>
#include <Guiconstants.au3>
#include <Constants.au3>
HotKeySet("{F10}","_exit")
$Color=0x94DF08
$Wh=GUICreate("",@DesktopWidth,@DesktopHeight,-1,-1,-1)
$LabID=GUICtrlCreateEdit("",0,0,@DesktopWidth-1,@DesktopHeight-1,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
 WinSetTrans($Wh,"",170);255)
 
GUICtrlSetCursor(-1,3)
$c = WinGetClientSize($wh)
$g = GUICtrlCreateGraphic(0,0,$c[0],$c[1])
GUISetState()

While 1

If _IsPressed(01) Then
    $LPos = MouseGetPos()
Do

    GUICtrlSetData($LabID,"")
    $LPos1 = MouseGetPos()
    dibujar()
    Sleep(25)
Until NOT _IsPressed(01)

EndIf
Sleep(50)
WEnd
Func dibujar()
    $hand = DllCall("user32.dll","int", "GetDC", "hwnd",GUICtrlGetHandle($g)); 0)
    $pen = DllCall("gdi32.dll", "int", "CreatePen", "int", 0 , "int",2, "int", $Color)
    DllCall("gdi32.dll", "int", "SelectObject", "int", $hand[0], "int", $pen[0])
    DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hand[0], "int", $LPos[0], "int", $LPos[1], "int", 0)
    DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hand[0], "int", $LPos1[0], "int", $LPos1[1])
EndFunc
Func _exit()
    Exit
EndFunc
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...