Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Drawing on screen


  • Please log in to reply
15 replies to this topic
evan
  • Guests
  • Last active:
  • Joined: --
hello everyone,
i want to create a program similar to the function in powerpoint
that u can draw stuff with "pen" in your presentation

instead, i want to drew on normal desktop screen

i manage to create a GUI that can display what i type on the screen
but have no idea how i can "drew"

any suggestions?

thank you

Zippo()
  • Guests
  • Last active:
  • Joined: --
See this topic: http://www.autohotke... ... 2016#32016

I've been looking for this for a while but didn't find it until I searched for an answer to this question :)

Zippo()
  • Guests
  • Last active:
  • Joined: --
Bah scratch that. This is the one I've been looking for. Should help you too.

http://www.autohotke... ... draw mouse

evan
  • Guests
  • Last active:
  • Joined: --
nice, exactly what i wanted
probably i will try to combine my TEXT display and the drawing part now
thanks

evan
  • Guests
  • Last active:
  • Joined: --
ehm, interesting program
what it does is not really drawing on active screen
it kind of take a screenshot of the screen
then u draw ontop of it

Zippo()
  • Guests
  • Last active:
  • Joined: --
Ok, you said desktop, so I thought desktop.

So you just need to modify it a little:
OnExit, Exit
Gui, Show, h300 w300, Test
hWnd := WinExist("Test")
hDC := DllCall("GetDC", UInt, hWnd)
color := 0xff
OnMessage(0x200, "Draw")
Return

Draw(wParam, lParam)
{
	Global hDC, color
	DllCall("SetPixel", UInt, hDC, Int, lParam & 0xFFFF, Int, lParam >> 16, UInt, color)
}

GuiClose:
GuiEscape:
Exit:
If hDC
	DllCall("ReleaseDC", UInt, hDC)
ExitApp


evan
  • Guests
  • Last active:
  • Joined: --
finally finished combining =)

CoordMode, Mouse, Screen 
 
Black    = 000000
Green    = 008000
Silver    = C0C0C0
Lime       = 00FF00
Gray       = 808080
Olive       = 808000
White    = FFFFFF
Yellow    = FFFF00
Maroon    = 800000
Navy    = 000080
Red       = FF0000
Blue       = 0000FF
Purple    = 800080
Teal       = 008080
Fuchsia    = FF00FF
Aqua    = 00FFFF

hh := A_ScreenHeight - 51
ww := A_ScreenWidth / 3
ColorChoice = Black
LineWidth = 11
xpos=0
ypos=0
word=

Gui 2: Color, black
Gui 2: Add, Button, Default x-100 y1 gokbt,
Gui 2: +LastFound +AlwaysOnTop +ToolWindow -Caption
Gui 2: Add, Edit, vword x20 y1 w%ww%, 
 Gui 2: Add, DropDownList, w80 x+20 y1 choose2 vColorChoice gchange, Aqua|Black|Blue|Fuchsia|Gray|Green|Lime|Maroon|Navy|Olive|Purple|Red|Silver|Teal|White|Yellow|
Gui 2: Add, DropDownList, w40 x+20 y1 choose4 vLineWidth gchange2, 8|9|10|11|12|14|16|18|20|22|24|26|28|36|48|72|
Gui 2: Show, x-1 y%hh% w%A_ScreenWidth% h22

Gui, 1:+LastFound +AlwaysOnTop
Gui, 1:-Caption
Gui, 1:Color, FF0000
WinSet, TransColor, FF0000
GuiHwnd := WinExist()
Gui, 1:Show
Gui, 1:Maximize

SetTimer, DrawLine, 100

return


okbt:
Gui 2: Submit, NoHide
StringLen, length, ww
Send {Ctrl down}
Send {a}
Send {Ctrl up}
Send {del}
fontsize := LineWidth * 3
MouseGetPos, xpos, ypos
Gui 3: Color, EEAA99
Gui 3: +LastFound +AlwaysOnTop +ToolWindow -Caption 
WinSet, TransColor, EEAA99
gui 3: font, s%fontsize% C%ColorChoice%, Verdana  
Gui 3: Add, Text, x1 y1, %word%
Gui 3: Show, x%xpos% y%ypos% w%A_ScreenWidth%
length=
return



DrawLine:
GetKeyState, state, LButton  
GetKeyState, state2, Ctrl
MouseGetPos, M_x, M_y
if state = D
if state2 = D
{

sleep 25
MouseGetPos, M_x2, M_y2
Canvas_DrawLine(GuihWnd, M_x, M_y, M_x2, M_y2, LineWidth, %ColorChoice%)

loop 30 
{
GetKeyState, state, LButton  
GetKeyState, state2, Ctrl
if state = U
{
break
}
else if state2 = U
{
break
}
sleep 25
MouseGetPos, M_x3, M_y3
Canvas_DrawLine(GuihWnd, M_x3, M_y3, M_x2, M_y2, LineWidth, %ColorChoice%)
sleep 25
MouseGetPos, M_x2, M_y2
Canvas_DrawLine(GuihWnd, M_x3, M_y3, M_x2, M_y2, LineWidth, %ColorChoice%)
}
}
return

Canvas_DrawLine(hWnd, p_x1, p_y1, p_x2, p_y2, p_w, p_color) ; r,angle,width,color)
   {
   p_x1 -= 1, p_y1 -= 1, p_x2 -= 1, p_y2 -= 1
   hDC := DllCall("GetDC", UInt, hWnd)
   hCurrPen := DllCall("CreatePen", UInt, 0, UInt, p_w, UInt, Convert_BGR(p_color))
   DllCall("SelectObject", UInt,hdc, UInt,hCurrPen)
   DllCall("gdi32.dll\MoveToEx", UInt, hdc, Uint,p_x1, Uint, p_y1, Uint, 0 )
   DllCall("gdi32.dll\LineTo", UInt, hdc, Uint, p_x2, Uint, p_y2 )
   DllCall("ReleaseDC", UInt, 0, UInt, hDC)  ; Clean-up.
   DllCall("DeleteObject", UInt,hCurrPen)
   }

Convert_BGR(RGB)
   {
   StringLeft, r, RGB, 2
   StringMid, g, RGB, 3, 2
   StringRight, b, RGB, 2
   Return, "0x" . b . g . r
   }
   
return
   
change:
Gui 2: submit
Gui 2: Color, %ColorChoice%
Gui 2: Show, x-1 y%hh% w2000 h22
return

change2:
Gui 2: submit
Gui 2: Show, x-1 y%hh% w2000 h22
return
   
esc::exitapp  
 
^r::
{
WinSet, Redraw,, ahk_id %GuiHwnd%
Gui 3: Cancel
return
}
   
   
   
   
   


evan
  • Guests
  • Last active:
  • Joined: --
and here is my testing screenshot

Posted Image

thank you once again
i think problem solved =)

Zippo()
  • Guests
  • Last active:
  • Joined: --
You picked up on that quick :shock:

Very nice :)

evan
  • Guests
  • Last active:
  • Joined: --
working on it for 3 hrs already
phew, didnt waste my afford

i was planning to use this on my video edits
(before loading it up in Movie editor)

or maybe sometimes drawing @_@

o btw, this program does not dot dot dot dot dot to paint lines
it connects the dots like the line function in Paint

Z Gecko
  • Guests
  • Last active:
  • Joined: --
little bugfix:
CoordMode, Mouse, Screen 
 
Black    = 000000
Green    = 008000
Silver    = C0C0C0
Lime       = 00FF00
Gray       = 808080
Olive       = 808000
White    = FFFFFF
Yellow    = FFFF00
Maroon    = 800000
Navy    = 000080
Red       = FF0000
Blue       = 0000FF
Purple    = 800080
Teal       = 008080
Fuchsia    = FF00FF
Aqua    = 00FFFF

hh := A_ScreenHeight - 51
ww := A_ScreenWidth / 3
ColorChoice = Black
LineWidth = 11
xpos=0
ypos=0
word=

Gui 2: Color, black
Gui 2: Add, Button, Default x-100 y1 gokbt,
Gui 2: +LastFound +AlwaysOnTop +ToolWindow -Caption
Gui 2: Add, Edit, vword x20 y1 w%ww%, 
 Gui 2: Add, DropDownList, w80 x+20 y1 choose2 vColorChoice gchange, Aqua|Black|Blue|Fuchsia|Gray|Green|Lime|Maroon|Navy|Olive|Purple|Red|Silver|Teal|White|Yellow|
Gui 2: Add, DropDownList, w40 x+20 y1 choose4 vLineWidth gchange2, 8|9|10|11|12|14|16|18|20|22|24|26|28|36|48|72|
Gui 2: Show, x-1 y%hh% w%A_ScreenWidth% h22

Gui, 1:+LastFound +AlwaysOnTop
Gui, 1:-Caption
Gui, 1:Color, FF0000
WinSet, TransColor, FF0000
GuiHwnd := WinExist()
Gui, 1:Show
Gui, 1:Maximize

SetTimer, DrawLine, 100

return


okbt:
Gui 2: Submit, NoHide
StringLen, length, ww
Send {Ctrl down}
Send {a}
Send {Ctrl up}
Send {del}
fontsize := LineWidth * 3
MouseGetPos, xpos, ypos
[color=red]Gui 3: Destroy[/color]
Gui 3: Color, EEAA99
Gui 3: +LastFound +AlwaysOnTop +ToolWindow -Caption 
WinSet, TransColor, EEAA99
gui 3: font, s%fontsize% C%ColorChoice%, Verdana  
Gui 3: Add, Text, x1 y1, %word%
Gui 3: Show, x%xpos% y%ypos% w%A_ScreenWidth%
length=
return



DrawLine:
GetKeyState, state, LButton  
GetKeyState, state2, Ctrl
MouseGetPos, M_x, M_y
if state = D
if state2 = D
{

sleep 25
MouseGetPos, M_x2, M_y2
Canvas_DrawLine(GuihWnd, M_x, M_y, M_x2, M_y2, LineWidth, %ColorChoice%)

loop 30 
{
GetKeyState, state, LButton  
GetKeyState, state2, Ctrl
if state = U
{
break
}
else if state2 = U
{
break
}
sleep 25
MouseGetPos, M_x3, M_y3
Canvas_DrawLine(GuihWnd, M_x3, M_y3, M_x2, M_y2, LineWidth, %ColorChoice%)
sleep 25
MouseGetPos, M_x2, M_y2
Canvas_DrawLine(GuihWnd, M_x3, M_y3, M_x2, M_y2, LineWidth, %ColorChoice%)
}
}
return

Canvas_DrawLine(hWnd, p_x1, p_y1, p_x2, p_y2, p_w, p_color) ; r,angle,width,color)
   {
   p_x1 -= 1, p_y1 -= 1, p_x2 -= 1, p_y2 -= 1
   hDC := DllCall("GetDC", UInt, hWnd)
   hCurrPen := DllCall("CreatePen", UInt, 0, UInt, p_w, UInt, Convert_BGR(p_color))
   DllCall("SelectObject", UInt,hdc, UInt,hCurrPen)
   DllCall("gdi32.dll\MoveToEx", UInt, hdc, Uint,p_x1, Uint, p_y1, Uint, 0 )
   DllCall("gdi32.dll\LineTo", UInt, hdc, Uint, p_x2, Uint, p_y2 )
   DllCall("ReleaseDC", UInt, 0, UInt, hDC)  ; Clean-up.
   DllCall("DeleteObject", UInt,hCurrPen)
   }

Convert_BGR(RGB)
   {
   StringLeft, r, RGB, 2
   StringMid, g, RGB, 3, 2
   StringRight, b, RGB, 2
   Return, "0x" . b . g . r
   }
   
return
   
change:
Gui 2: submit
Gui 2: Color, %ColorChoice%
Gui 2: Show, x-1 y%hh% w2000 h22
return

change2:
Gui 2: submit
Gui 2: Show, x-1 y%hh% w2000 h22
return
   
esc::exitapp  
 
^r::
{
WinSet, Redraw,, ahk_id %GuiHwnd%
Gui 3: Cancel
return
}
   
   
   
   
   


SomeGuy
  • Members
  • 86 posts
  • Last active: May 17 2008 10:33 PM
  • Joined: 21 Apr 2008
here is my origional code.
<!-- m -->http://www.autohotke... ... 873#108873<!-- m -->

evanxxxm
  • Members
  • 10 posts
  • Last active: Jan 05 2013 12:22 PM
  • Joined: 14 Jun 2007
yes thats the script i developed in.
not sure if u are the author, but i will quote a mail here:

Posted Image
which its on another thread, that i develop it to act like a "aimer"
<!-- m -->http://www.autohotke...pic.php?t=26092<!-- m -->
(for people that are interested in like a line generating in the center)

anyhow since its working, i will not check this thread as often
so hopefully it will eventually help some people that want to drawing

PS*thanks for providing a working script
without the script, i cant develop this

ahklerner
  • Members
  • 1386 posts
  • Last active: Oct 08 2014 10:29 AM
  • Joined: 26 Jun 2006
:) No problems.
Posted Image
ʞɔпɟ əɥʇ ʇɐɥʍ

Rhys
  • Members
  • 761 posts
  • Last active: Aug 09 2013 04:53 PM
  • Joined: 17 Apr 2007
Cool script(s)! It might be improved by putting the gui at the bottom of the workspace (so sideways or double height taskbars are supported). I wish there was a palette on the GUI too... Maybe 8 squares of common colors and a more ddl?