Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GuiConstantsEx.au3>
- #include <GDIPlus.au3>
- #include <WindowsConstants.au3>
- #include <WinAPI.au3>
- Global $hGUI, $hGraphic, $hPen
- Global Const $targetFps = 60
- HotKeySet("{F7}", "Terminate")
- Opt("MouseCoordMode", 1) ;1=absolute, 0=relative, 2=client
- Opt('MustDeclareVars', 1)
- _Main()
- Func _Main()
- Local $msg
- Local $timer
- Local Const $WS_EX_NOACTIVATE = 0x08000000 ; A top-level window created with this style does not become the foreground window when the user clicks it
- $hGUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED, $WS_EX_TRANSPARENT, $WS_EX_NOACTIVATE))
- DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hGUI, "long", 0xEFCDAB , "byte", 255, "long", 0x1 + 0x2)
- ; Since mouse should be passthrough and the window won't be activated, we don't use window event here
- ; GUIRegisterMsg(0xF, "MY_PAINT")
- _GDIPlus_Startup()
- $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
- $hPen = _GDIPlus_PenCreate(0xFFFF0000, 2)
- ; GDI+ is not hardware accelerated so I personally don't use this, and it messes with the background key 0xABCDEF
- ; _AntiAlias($hGraphic)
- GUISetState()
- $timer = TimerInit()
- While 1
- If TimerDiff($timer) >= 1000 / $targetFps Then
- $timer = TimerInit()
- _GDIPlus_GraphicsClear($hGraphic, 0xFFABCDEF)
- _GDIPlus_GraphicsDrawLine($hGraphic, @DesktopWidth / 2, @DesktopHeight / 2 , MouseGetPos(0), MouseGetPos(1), $hPen)
- EndIf
- WEnd
- Terminate()
- EndFunc ;==>_Main
- Func _AntiAlias($hGraphics)
- Local $aResult
- $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetSmoothingMode", "hwnd", $hGraphics, "int", 2)
- If @error Then Return SetError(@error, @extended, False)
- Return SetError($aResult[0], 0, $aResult[0] = 0)
- EndFunc ;==>_AntiAlias
- Func Terminate()
- _GDIPlus_PenDispose($hPen)
- _GDIPlus_GraphicsDispose($hGraphic)
- _GDIPlus_Shutdown()
- Exit
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement