Что нового

[Script] Радар для курсора

dwerf

Использует ArchLinux
Сообщения
478
Репутация
219
AutoIt: 3.3.6.1
Версия: 1

Категория: Графика / GDI+

Описание: Радар на мышей :smile:
В зависимости от положения курсора рисует точку в окне.

Код
Код:
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt('GUIOnEventMode', 1)

$iAng = 0
$iPointX = -10
$iPointY = -10
$iAngSave = 0
$iPointSave = ''

$aTaskPos = WinGetPos('[class:Shell_TrayWnd]')

$hWnd = GUICreate('Radar', 151, 151, @DesktopWidth-151, @DesktopHeight-151-$aTaskPos[3], BitOR($WS_POPUP, $WS_SYSMENU), $WS_EX_TOPMOST)
GUISetBkColor(0)
GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit')

_GDIPlus_Startup()
$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
$hBackbufferBmp = _GDIPlus_BitmapCreateFromGraphics(151, 151, $hGraphics)
$hBackbufferGra = _GDIPlus_ImageGetGraphicsContext($hBackbufferBmp)
$hBackbuffer0Bmp = _GDIPlus_BitmapCreateFromGraphics(151, 151, $hBackbufferGra)
$hBackbuffer0Gra = _GDIPlus_ImageGetGraphicsContext($hBackbuffer0Bmp)

$hPen1 = _GDIPlus_PenCreate(0xFF00FF00)
$hBrush1 = _GDIPlus_BrushCreateSolid(0xFF00FF00)

_GDIPlus_GraphicsDrawLine($hBackbuffer0Gra, 75, 0, 75, 150, $hPen1)
_GDIPlus_GraphicsDrawLine($hBackbuffer0Gra, 0, 75, 150, 75, $hPen1)
_GDIPlus_GraphicsDrawEllipse($hBackbuffer0Gra, 0, 0, 150, 150, $hPen1)
_GDIPlus_GraphicsDrawEllipse($hBackbuffer0Gra, 25, 25, 100, 100, $hPen1)
_GDIPlus_GraphicsDrawEllipse($hBackbuffer0Gra, 50, 50, 50, 50, $hPen1)

OnAutoItExitRegister('_OnExit')

GUISetState()

While 1
	For $iAng = 359 To 0 Step -1
		_Draw()
		Sleep(20)
	Next
WEnd

Func _Exit()
	Exit
EndFunc

Func _OnExit()
	_GDIPlus_BrushDispose($hBrush1)
	_GDIPlus_PenDispose($hPen1)
	_GDIPlus_GraphicsDispose($hBackbuffer0Gra)
	_GDIPlus_BitmapDispose($hBackbuffer0Bmp)
	_GDIPlus_GraphicsDispose($hBackbufferGra)
	_GDIPlus_BitmapDispose($hBackbufferBmp)
	_GDIPlus_GraphicsDispose($hGraphics)
	_GDIPlus_Shutdown()
EndFunc

Func _Draw()
	_GDIPlus_GraphicsClear($hBackbufferGra)
	_GDIPlus_GraphicsDrawImage($hBackbufferGra, $hBackbuffer0Bmp, 0, 0)
	$aMousePos = MouseGetPos()
	$iLineEndX = 75+(75*Cos($iAng*ACos(-1)/180))
	$iLineEndY = 75-(75*Sin($iAng*ACos(-1)/180))
	$iNewPointX = Round(150/@DesktopWidth*MouseGetPos(0))
	$iNewPointY = Round(150/@DesktopHeight*MouseGetPos(1))
	If (($iNewPointX <= $iLineEndX And $iNewPointX >= 75) Or ($iNewPointX >= $iLineEndX And $iNewPointX <= 75)) And (($iNewPointY <= $iLineEndY And $iNewPointY >= 75) Or ($iNewPointY >= $iLineEndY And $iNewPointY <= 75)) And (Round(($iNewPointX-75)/Cos($iAng*ACos(-1)/180), -1) = Round((75-$iNewPointY)/Sin($iAng*ACos(-1)/180), -1) Or $iAng = 0 Or $iAng = 90) Then
		$iPointX = $iNewPointX
		$iPointY = $iNewPointY
		$iPointSave = $iPointX & @LF & $iPointY
		$iAngSave = $iAng
		Beep(500, 10)
	ElseIf $iAngSave = $iAng And $iPointSave <> $iNewPointX & @LF & $iNewPointY Then
		$iPointX = -10
		$iPointY = -10
	EndIf
	_GDIPlus_GraphicsDrawLine($hBackbufferGra, 75, 75, $iLineEndX, $iLineEndY, $hPen1)
	_GDIPlus_GraphicsFillEllipse($hBackbufferGra, $iPointX-2, $iPointY-2, 5, 5, $hBrush1)
	_GDIPlus_GraphicsDrawImage($hGraphics, $hBackbufferBmp, 0, 0)
EndFunc

Снимок:


Автор(ы): dwerf

Дело было вечером, делать было нечего, на оффоруме попалась тема с названием "Mouse Radar".
 

Garrett

Модератор
Локальный модератор
Сообщения
3,999
Репутация
964
Готовая функция к shooter`у ;D
 

Waik

Знающий
Сообщения
60
Репутация
16
Шииикарно!
Ждём функции :
Перезарядка мыши.
Лазерный прицел у стрелочки.
:rofl:
 
Верх