 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
evan Guest
|
Posted: Fri May 02, 2008 4:28 am Post subject: Drawing on screen |
|
|
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
|
|
| Back to top |
|
 |
Zippo() Guest
|
|
| Back to top |
|
 |
evan Guest
|
Posted: Fri May 02, 2008 6:46 am Post subject: |
|
|
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
|
Posted: Fri May 02, 2008 7:17 am Post subject: |
|
|
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
|
Posted: Fri May 02, 2008 8:47 am Post subject: |
|
|
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
|
Posted: Fri May 02, 2008 10:14 am Post subject: |
|
|
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
|
Posted: Fri May 02, 2008 10:19 am Post subject: |
|
|
and here is my testing screenshot
thank you once again
i think problem solved =) |
|
| Back to top |
|
 |
Zippo() Guest
|
Posted: Fri May 02, 2008 10:37 am Post subject: |
|
|
You picked up on that quick
Very nice  |
|
| Back to top |
|
 |
evan Guest
|
Posted: Fri May 02, 2008 10:44 am Post subject: |
|
|
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
|
Posted: Fri May 02, 2008 10:44 am Post subject: |
|
|
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
|
|
| Back to top |
|
 |
evanxxxm
Joined: 14 Jun 2007 Posts: 5
|
Posted: Fri May 02, 2008 5:45 pm Post subject: |
|
|
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 |
|
 |
ahklerner
Joined: 26 Jun 2006 Posts: 1205 Location: USA
|
Posted: Fri May 02, 2008 6:38 pm Post subject: |
|
|
No problems. _________________
 |
|
| Back to top |
|
 |
Rhys
Joined: 17 Apr 2007 Posts: 722 Location: Florida
|
Posted: Fri May 02, 2008 7:46 pm Post subject: |
|
|
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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|