Re: Simple drawing question
"valery_vi" <[email protected]>
| Newsgroups | gmane.comp.windows.autoit.user |
|---|---|
| Message-ID | <[email protected]> |
Someone from AutoItScript forum wrote:
"
Maybe possible to make a transparent window ?
"
It's possible, too:
#include <GUIConstants.au3>
Global $Transp_Flag = 100
Global $user = DllOpen("user32.dll")
Global $gdi = DllOpen("gdi32.dll")
Global $hDC, $Pen
HotKeySet("{Esc}", "On_Escape")
$hWnd = GUICreate("box", 600, 400, -1, -1, $WS_POPUP)
WinSetTrans ($hWnd, "", $Transp_Flag)
$hDC = DllCall($user, "int", "GetDC", "hwnd", $hWnd)
$hDC = $hDC[0]
$Pen = DllCall($gdi, "int", "CreatePen", "int", 0, "int", 4, "int",
0x00AAFF)
$Pen = $Pen[0]
DllCall($gdi, "int", "SelectObject", "int", $hDC, "int", $Pen)
GUISetState(@SW_SHOW)
$x1 = 10
$x2 = 590
$y1 = 10
$y2 = 390
DrawBox($x1, $y1, $x2, $y2)
While 1
$Msg = GUIGetMsg()
if $Msg = $GUI_EVENT_CLOSE then ExitLoop
WEnd
On_Exit()
func On_Escape()
DllCall($user, "int", "ReleaseDC", "hwnd", 0, "int", $hDC)
DllClose($user)
DllClose($gdi)
exit
endfunc
Func DrawBox($x1, $y1, $x2, $y2)
if $x1 = '' or $x2 = '' then return
DllCall($gdi, "int", "MoveToEx", "hwnd", $hDC, "int", $x1, "int",
$y1, "int", 0)
DllCall($gdi, "int", "LineTo", "hwnd", $hDC, "int", $x1, "int", $y2)
DllCall($gdi, "int", "LineTo", "hwnd", $hDC, "int", $x2, "int", $y2)
DllCall($gdi, "int", "LineTo", "hwnd", $hDC, "int", $x2, "int", $y1)
DllCall($gdi, "int", "LineTo", "hwnd", $hDC, "int", $x1, "int", $y1)
EndFunc
Valery
--- In [email protected], "valery_vi" <shehrer1@...> wrote:
>
> Someone from AutoItScript forum wrote:
> "
> I want to draw a box on my screen but i don't manage to make it
stay
> on the screen. When the box is finished drawind, it disappears !
>
> What sould i do ?
> "
>
> This script works for me:
> #include <GUIConstants.au3>
> Global $user = DllOpen("user32.dll")
> Global $gdi = DllOpen("gdi32.dll")
> Global $hDC, $Pen
>
> $hWnd = GUICreate("box", 600, 400)
> $hDC = DllCall($user, "int", "GetDC", "hwnd", $hWnd)
> $hDC = $hDC[0]
> $Pen = DllCall($gdi, "int", "CreatePen", "int", 0, "int", 4, "int",
> 0x00AAFF)
> $Pen = $Pen[0]
> DllCall($gdi, "int", "SelectObject", "int", $hDC, "int", $Pen)
>
> GUISetState(@SW_SHOW)
>
> $x1 = 10
> $x2 = 590
> $y1 = 10
> $y2 = 390
> DrawBox($x1, $y1, $x2, $y2)
>
> While 1
> $Msg = GUIGetMsg()
> if $Msg = $GUI_EVENT_CLOSE then ExitLoop
> WEnd
>
> DllCall($user, "int", "ReleaseDC", "hwnd", 0, "int", $hDC)
> DllClose($user)
> DllClose($gdi)
>
> Func DrawBox($x1, $y1, $x2, $y2)
> if $x1 = '' or $x2 = '' then return
> DllCall($gdi, "int", "MoveToEx", "hwnd", $hDC, "int", $x1, "int",
> $y1, "int", 0)
> DllCall($gdi, "int", "LineTo", "hwnd", $hDC, "int", $x1, "int", $y2)
> DllCall($gdi, "int", "LineTo", "hwnd", $hDC, "int", $x2, "int", $y2)
> DllCall($gdi, "int", "LineTo", "hwnd", $hDC, "int", $x2, "int", $y1)
> DllCall($gdi, "int", "LineTo", "hwnd", $hDC, "int", $x1, "int", $y1)
> EndFunc
>
> Valery
>