注册GUI消息WM_PAINT比较好:
#Include <WinAPI.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
Global $hGUI, $x = @DesktopWidth, $y = @DesktopHeight
While 1
Sleep(20)
If _IsPressed("11") Then ;Ctrl to draw
_draw()
EndIf
If _IsPressed("10") Then ; shift to clear
_clear()
EndIf
If _IsPressed("1B") Then ; esc to exit
Exit
EndIf
WEnd
Func _draw()
If IsHWnd($hGUI) Then Return
$hGUI = GUICreate("", $x, $y, 0, 0, $WS_POPUP, $WS_EX_TOPMOST + $WS_EX_LAYERED, WinGetHandle("[CLASS:Progman]"))
GUISetBkColor(0x123456)
_WinAPI_SetLayeredWindowAttributes($hGUI, 0x123456, 255)
GUIRegisterMsg($WM_PAINT, "WM_PAINT")
GUISetState()
EndFunc ;==>_draw
Func WM_PAINT($hWnd, $msg, $wParam, $lParam)
#forceref $hWnd, $Msg, $wParam, $lParam
_WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW)
$hDC1 = _WinAPI_GetWindowDC($hGUI)
$hPen1 = _WinAPI_CreatePen($PS_SOLID, 5, 0xFF)
$obj_orig = _WinAPI_SelectObject($hDC1, $hPen1)
_WinAPI_DrawLine($hDC1, 0, $y * (1 / 3), $x, $y * (1 / 3))
_WinAPI_DrawLine($hDC1, 0, $y * (2 / 3), $x, $y * (2 / 3))
_WinAPI_DrawLine($hDC1, $x * (1 / 3), 0, $x * (1 / 3), $y)
_WinAPI_DrawLine($hDC1, $x * (2 / 3), 0, $x * (2 / 3), $y)
_WinAPI_SelectObject($hDC1, $obj_orig)
_WinAPI_DeleteObject($hPen1)
_WinAPI_ReleaseDC($hGUI, $hDC1)
_WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE)
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_PAINT
Func _clear()
If IsHWnd($hGUI) Then GUIDelete($hGUI)
$hGUI = 0
EndFunc ;==>_clear
|