AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Drawing on screen
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
evan
Guest





PostPosted: Fri May 02, 2008 4:28 am    Post subject: Drawing on screen Reply with quote

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
Back to top
Zippo()
Guest





PostPosted: Fri May 02, 2008 4:55 am    Post subject: Reply with quote

See this topic: http://www.autohotkey.com/forum/viewtopic.php?p=32016#32016

I've been looking for this for a while but didn't find it until I searched for an answer to this question Smile
Back to top
Zippo()
Guest





PostPosted: Fri May 02, 2008 5:22 am    Post subject: Reply with quote

Bah scratch that. This is the one I've been looking for. Should help you too.

http://www.autohotkey.com/forum/topic7378.html&highlight=draw+mouse
Back to top
evan
Guest





PostPosted: Fri May 02, 2008 6:46 am    Post subject: Reply with quote

nice, exactly what i wanted
probably i will try to combine my TEXT display and the drawing part now
thanks
Back to top
evan
Guest





PostPosted: Fri May 02, 2008 7:17 am    Post subject: Reply with quote

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
Back to top
Zippo()
Guest





PostPosted: Fri May 02, 2008 8:47 am    Post subject: Reply with quote

Ok, you said desktop, so I thought desktop.

So you just need to modify it a little:
Code:
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
Back to top
evan
Guest





PostPosted: Fri May 02, 2008 10:14 am    Post subject: Reply with quote

finally finished combining =)

Code:

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
}
   
   
   
   
   
   
Back to top
evan
Guest





PostPosted: Fri May 02, 2008 10:19 am    Post subject: Reply with quote

and here is my testing screenshot



thank you once again
i think problem solved =)
Back to top
Zippo()
Guest





PostPosted: Fri May 02, 2008 10:37 am    Post subject: Reply with quote

You picked up on that quick Shocked

Very nice Smile
Back to top
evan
Guest





PostPosted: Fri May 02, 2008 10:44 am    Post subject: Reply with quote

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
Back to top
Z Gecko
Guest





PostPosted: Fri May 02, 2008 10:44 am    Post subject: Reply with quote

little bugfix:
Code:

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: Destroy
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
}
   
   
   
   
   
   
Back to top
SomeGuy



Joined: 21 Apr 2008
Posts: 96
Location: somewhere

PostPosted: Fri May 02, 2008 1:05 pm    Post subject: Reply with quote

here is my origional code.
http://www.autohotkey.com/forum/viewtopic.php?p=108873#108873
Back to top
View user's profile Send private message
evanxxxm



Joined: 14 Jun 2007
Posts: 5

PostPosted: Fri May 02, 2008 5:45 pm    Post subject: Reply with quote

yes thats the script i developed in.
not sure if u are the author, but i will quote a mail here:


which its on another thread, that i develop it to act like a "aimer"
http://www.autohotkey.com/forum/viewtopic.php?t=26092
(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
Back to top
View user's profile Send private message
ahklerner



Joined: 26 Jun 2006
Posts: 1205
Location: USA

PostPosted: Fri May 02, 2008 6:38 pm    Post subject: Reply with quote

Smile No problems.
_________________
Back to top
View user's profile Send private message
Rhys



Joined: 17 Apr 2007
Posts: 722
Location: Florida

PostPosted: Fri May 02, 2008 7:46 pm    Post subject: Reply with quote

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?
_________________
[Join IRC!]
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group