Advertisement
Alan72104

Line from center to mouse overlay

Jan 21st, 2022
2,458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.51 KB | None | 0 0
  1. #include <GuiConstantsEx.au3>
  2. #include <GDIPlus.au3>
  3. #include <WindowsConstants.au3>
  4. #include <WinAPI.au3>
  5.  
  6. Global $hGUI, $hGraphic, $hPen, $hPenBg
  7. Global Const $targetFps = 60
  8. HotKeySet("{F7}", "Terminate")
  9. Opt("MouseCoordMode", 1) ;1=absolute, 0=relative, 2=client
  10. Opt('MustDeclareVars', 1)
  11.  
  12. _Main()
  13.  
  14. Func _Main()
  15.     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
  16.     $hGUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED, $WS_EX_TRANSPARENT, $WS_EX_NOACTIVATE))
  17.     _WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF)
  18.  
  19.     _GDIPlus_Startup()
  20.     $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
  21.  
  22.     $hPen = _GDIPlus_PenCreate(0xFFFF0000, 2)
  23.     $hPenBg = _GDIPlus_PenCreate(0xFFABCDEF, 2)
  24.  
  25.     GUISetState()
  26.     _GDIPlus_GraphicsClear($hGraphic, 0xFFABCDEF)
  27.     Local $oldPos = MouseGetPos()
  28.     While 1
  29.         Local $pos = MouseGetPos()
  30.         _GDIPlus_GraphicsDrawLine($hGraphic, @DesktopWidth / 2, @DesktopHeight / 2 , $oldPos[0], $oldPos[1], $hPenBg)
  31.         _GDIPlus_GraphicsDrawLine($hGraphic, @DesktopWidth / 2, @DesktopHeight / 2 , $pos[0], $pos[1], $hPen)
  32.         $oldPos = $pos
  33.         Sleep(1000 / $targetFps)
  34.     WEnd
  35.     Terminate()
  36. EndFunc   ;==>_Main
  37.  
  38. Func Terminate()
  39.     _GDIPlus_PenDispose($hPen)
  40.     _GDIPlus_PenDispose($hPenBg)
  41.     _GDIPlus_GraphicsDispose($hGraphic)
  42.     _GDIPlus_Shutdown()
  43.     Exit
  44. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement