<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK V2: GUI окно мерцает (GDIP)]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=18405</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=18405&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK V2: GUI окно мерцает (GDIP)».]]></description>
		<lastBuildDate>Sat, 22 Mar 2025 08:05:13 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK V2: GUI окно мерцает (GDIP)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=162115#p162115</link>
			<description><![CDATA[<p>Если хотите отобразить картинку с прозрачностью без окна, это делается по-другому, не через AddPicture и WinSetTransColor. Советую найти туториал по GDIp.ahk, подойдёт для AHK v1, чтобы понять принцип.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sat, 22 Mar 2025 08:05:13 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=162115#p162115</guid>
		</item>
		<item>
			<title><![CDATA[AHK V2: GUI окно мерцает (GDIP)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=162112#p162112</link>
			<description><![CDATA[<p>Всех приветствую! </p><p>Мой скрипт - это, по сути, Radial Menu, и он практически доделан. Но у меня возникала проблема, которую я не могу решить, а именно мерцание GUI окна. Как я понимаю, это происходит из-за WinSetTransColor, так как если закомментировать эту строку кода, то все будет работать нормально. Почему так работает, я не особо понимаю. </p><p>GUI мерцает не особо часто, но всё же это хорошо заметно. У кого-нибудь есть идеи, как это исправить?<br />Буду признателен за любую помощь. </p><p>И да, для запуска скрипта нужна библиотека<br />GDIP: <a href="https://raw.githubusercontent.com/buliasz/AHKv2-Gdip/master/Gdip_All.ahk">https://raw.githubusercontent.com/bulia … ip_All.ahk</a><br />А также класс Vector: <a href="https://www.autohotkey.com/boards/viewtopic.php?f=83&amp;t=132770&amp;p=583213#p583213">https://www.autohotkey.com/boards/viewt … 13#p583213</a></p><div class="codebox"><pre><code>#Requires AutoHotkey v2.0
#SingleInstance Force
#Include Gdip_All.ahk ; https://raw.githubusercontent.com/buliasz/AHKv2-Gdip/master/Gdip_All.ahk
#Include Vectors.ahk  ; https://www.autohotkey.com/boards/viewtopic.php?f=83&amp;t=132770&amp;p=583213#p583213
CoordMode &quot;Mouse&quot;, &quot;Screen&quot;


pToken          := Gdip_Startup()
Gui1            := Gui(&quot;+ToolWindow -Caption +E0x02000000 +E0x00080000 +E0x80000&quot;)
Gui1.BackColor  := &quot;0x010101&quot;
Gui1.Elements2  := CursorElements()
Gui1.Elements   := OwerlayElements()
;Cursorpic      := Gui1.Add(&quot;Picture&quot;, &quot;x190 y190 w20 h20 +BackgroundTrans&quot;, &quot;.\Pic\cor.png&quot;)
Gui1.Pic1       := Gui1.Add( &quot;Picture&quot; , &quot;x185 y185 +BackgroundTrans&quot; , &quot;hBitmap: &quot; CursorFunction( Gui1.Elements2 ,, &quot;hBitmap&quot; ) ) ; custom cursor
Gui1.Pic2       := Gui1.Add( &quot;Picture&quot; , &quot;x-0 y-0&quot; , &quot;hBitmap: &quot; OwerlayFunction( Gui1.Elements ,, &quot;hBitmap&quot; ) )                    ; circle
WinSetTransColor(Gui1.BackColor &quot; 255&quot;, Gui1)
;WinSetTransColor &quot;010101 250&quot;, Gui1


OwerlayElements(){
	local Elements := []
	Elements.Push( { Index: 1 ,  Layer: 1 , ElementType: &quot;DrawArc&quot; , Rect: { X: 115 + 0 , Y: 115 + 0 , W: 170 , H: 170 } , StartAngle: &quot;0&quot; , SweepAngle: &quot;360&quot; , Thickness: &quot;3&quot; , Note: &quot;&quot; , BrushObject: { BrushType: &quot;SolidBrush&quot; ,  Color1: &quot;0xFFFF0000&quot; } } )
	Elements.Push( { Index: 2 ,  Layer: 1 , ElementType: &quot;DrawArc&quot; , Rect: { X: 118 + 0 , Y: 118 + 0 , W: 164 , H: 164 } , StartAngle: &quot;0&quot; , SweepAngle: &quot;360&quot; , Thickness: &quot;3&quot; , Note: &quot;&quot; , BrushObject: { BrushType: &quot;SolidBrush&quot; ,  Color1: &quot;0xFF000000&quot; } } )
	Elements.Push( { Index: 3 ,  Layer: 1 , ElementType: &quot;DrawArc&quot; , Rect: { X: 121 + 0 , Y: 121 + 0 , W: 158 , H: 158 } , StartAngle: &quot;0&quot; , SweepAngle: &quot;360&quot; , Thickness: &quot;3&quot; , Note: &quot;&quot; , BrushObject: { BrushType: &quot;SolidBrush&quot; ,  Color1: &quot;0xFFFF0000&quot; } } )
	Elements.Push( { Index: 4 ,  Layer: 1 , ElementType: &quot;DrawArc&quot; , Rect: { X: 124 + 0 , Y: 124 + 0 , W: 152 , H: 152 } , StartAngle: &quot;0&quot; , SweepAngle: &quot;360&quot; , Thickness: &quot;3&quot; , Note: &quot;&quot; , BrushObject: { BrushType: &quot;SolidBrush&quot; ,  Color1: &quot;0xFF000000&quot; } } )
	Elements.Push( { Index: 5 ,  Layer: 1 , ElementType: &quot;BorderedSimplePolygon&quot; , StartVector: { X: 300 + 0 , Y: 200 + 0 } , Radius: 12 , Sides: 3 , StartAngle: 120 , Thickness: 6 , Color1: 0xFFFA7878 , Color2: 0xFF373737 , Note: &quot;&quot; } )
	Elements.Push( { Index: 6 ,  Layer: 1 , ElementType: &quot;BorderedSimplePolygon&quot; , StartVector: { X: 270 + 0 , Y: 270 + 0 } , Radius: 12 , Sides: 3 , StartAngle: 165 , Thickness: 6 , Color1: 0xFFFA7878 , Color2: 0xFF373737 , Note: &quot;&quot; } )
	Elements.Push( { Index: 7 ,  Layer: 1 , ElementType: &quot;BorderedSimplePolygon&quot; , StartVector: { X: 200 + 0 , Y: 300 + 0 } , Radius: 12 , Sides: 3 , StartAngle: 210 , Thickness: 6 , Color1: 0xFFFA7878 , Color2: 0xFF373737 , Note: &quot;&quot; } )
	Elements.Push( { Index: 8 ,  Layer: 1 , ElementType: &quot;BorderedSimplePolygon&quot; , StartVector: { X: 130 + 0 , Y: 270 + 0 } , Radius: 12 , Sides: 3 , StartAngle: 255 , Thickness: 6 , Color1: 0xFFFA7878 , Color2: 0xFF373737 , Note: &quot;&quot; } )
	Elements.Push( { Index: 9 ,  Layer: 1 , ElementType: &quot;BorderedSimplePolygon&quot; , StartVector: { X: 100 + 0 , Y: 200 + 0 } , Radius: 12 , Sides: 3 , StartAngle: 300 , Thickness: 6 , Color1: 0xFFFA7878 , Color2: 0xFF373737 , Note: &quot;&quot; } )
	Elements.Push( { Index: 10 , Layer: 1 , ElementType: &quot;BorderedSimplePolygon&quot; , StartVector: { X: 130 + 0 , Y: 130 + 0 } , Radius: 12 , Sides: 3 , StartAngle: 345 , Thickness: 6 , Color1: 0xFFFA7878 , Color2: 0xFF373737 , Note: &quot;&quot; } )
	Elements.Push( { Index: 11 , Layer: 1 , ElementType: &quot;BorderedSimplePolygon&quot; , StartVector: { X: 200 + 0 , Y: 100 + 0 } , Radius: 12 , Sides: 3 , StartAngle: 390 , Thickness: 6 , Color1: 0xFFFA7878 , Color2: 0xFF373737 , Note: &quot;&quot; } )
	Elements.Push( { Index: 12 , Layer: 1 , ElementType: &quot;BorderedSimplePolygon&quot; , StartVector: { X: 270 + 0 , Y: 130 + 0 } , Radius: 12 , Sides: 3 , StartAngle: 437 , Thickness: 6 , Color1: 0xFFFA7878 , Color2: 0xFF373737 , Note: &quot;&quot; } )
	return Elements
}
;******************************************************************************************************
OwerlayFunction( Elements , Scale := 1 , returnType := &quot;pBitmap&quot; ){
	local pBitmap := Gdip_CreateBitmap( 400 * Scale , 400 * Scale )
	local pGraphics := Gdip_GraphicsFromImage( pBitmap )
	;Layer: 1
	Gdip_SetSmoothingMode( pGraphics , 2 ) , Gdip_SetInterpolationMode( pGraphics , 7 )
	element := Elements[ 1 ] , Brush := element.BrushObject
	pPen := Gdip_CreatePen( Brush.Color1 , element.Thickness * scale )
	Gdip_DrawArc( pGraphics , pPen , ( element.Rect.X ) * scale , ( element.Rect.Y ) * scale , ( element.Rect.W ) * scale , ( element.Rect.H ) * scale , element.StartAngle , element.SweepAngle )
	Gdip_DeletePen( pPen )
	element := Elements[ 2 ] , Brush := element.BrushObject
	pPen := Gdip_CreatePen( Brush.Color1 , element.Thickness * scale )
	Gdip_DrawArc( pGraphics , pPen , ( element.Rect.X ) * scale , ( element.Rect.Y ) * scale , ( element.Rect.W ) * scale , ( element.Rect.H ) * scale , element.StartAngle , element.SweepAngle )
	Gdip_DeletePen( pPen )
	element := Elements[ 3 ] , Brush := element.BrushObject
	pPen := Gdip_CreatePen( Brush.Color1 , element.Thickness * scale )
	Gdip_DrawArc( pGraphics , pPen , ( element.Rect.X ) * scale , ( element.Rect.Y ) * scale , ( element.Rect.W ) * scale , ( element.Rect.H ) * scale , element.StartAngle , element.SweepAngle )
	Gdip_DeletePen( pPen )
	element := Elements[ 4 ] , Brush := element.BrushObject
	pPen := Gdip_CreatePen( Brush.Color1 , element.Thickness * scale )
	Gdip_DrawArc( pGraphics , pPen , ( element.Rect.X ) * scale , ( element.Rect.Y ) * scale , ( element.Rect.W ) * scale , ( element.Rect.H ) * scale , element.StartAngle , element.SweepAngle )
	Gdip_DeletePen( pPen )
	element := Elements[ 5 ]
	pBrush := Gdip_BrushCreateSolid( element.Color1 )
	pPen := Gdip_CreatePen( element.Color2 , element.Thickness * scale )
	sv := Vector( element.StartVector ) 
	sv.Mult( scale ) 
	shape := Vector.PolygonShape( sv , element.Radius * scale , element.Sides , element.StartAngle )
	shape .= &quot;|&quot; StrSplit( shape , &quot;|&quot; )[2]
	Gdip_DrawLines( pGraphics , pPen , shape )
	Gdip_FillPolygon( pGraphics , pBrush , shape )
	Gdip_DeletePen( pPen )
	Gdip_DeleteBrush( pBrush )
	element := Elements[ 6 ]
	pBrush := Gdip_BrushCreateSolid( element.Color1 )
	pPen := Gdip_CreatePen( element.Color2 , element.Thickness * scale )
	sv := Vector( element.StartVector ) 
	sv.Mult( scale ) 
	shape := Vector.PolygonShape( sv , element.Radius * scale , element.Sides , element.StartAngle )
	shape .= &quot;|&quot; StrSplit( shape , &quot;|&quot; )[2]
	Gdip_DrawLines( pGraphics , pPen , shape )
	Gdip_FillPolygon( pGraphics , pBrush , shape )
	Gdip_DeletePen( pPen )
	Gdip_DeleteBrush( pBrush )
	element := Elements[ 7 ]
	pBrush := Gdip_BrushCreateSolid( element.Color1 )
	pPen := Gdip_CreatePen( element.Color2 , element.Thickness * scale )
	sv := Vector( element.StartVector ) 
	sv.Mult( scale ) 
	shape := Vector.PolygonShape( sv , element.Radius * scale , element.Sides , element.StartAngle )
	shape .= &quot;|&quot; StrSplit( shape , &quot;|&quot; )[2]
	Gdip_DrawLines( pGraphics , pPen , shape )
	Gdip_FillPolygon( pGraphics , pBrush , shape )
	Gdip_DeletePen( pPen )
	Gdip_DeleteBrush( pBrush )
	element := Elements[ 8 ]
	pBrush := Gdip_BrushCreateSolid( element.Color1 )
	pPen := Gdip_CreatePen( element.Color2 , element.Thickness * scale )
	sv := Vector( element.StartVector ) 
	sv.Mult( scale ) 
	shape := Vector.PolygonShape( sv , element.Radius * scale , element.Sides , element.StartAngle )
	shape .= &quot;|&quot; StrSplit( shape , &quot;|&quot; )[2]
	Gdip_DrawLines( pGraphics , pPen , shape )
	Gdip_FillPolygon( pGraphics , pBrush , shape )
	Gdip_DeletePen( pPen )
	Gdip_DeleteBrush( pBrush )
	element := Elements[ 9 ]
	pBrush := Gdip_BrushCreateSolid( element.Color1 )
	pPen := Gdip_CreatePen( element.Color2 , element.Thickness * scale )
	sv := Vector( element.StartVector ) 
	sv.Mult( scale ) 
	shape := Vector.PolygonShape( sv , element.Radius * scale , element.Sides , element.StartAngle )
	shape .= &quot;|&quot; StrSplit( shape , &quot;|&quot; )[2]
	Gdip_DrawLines( pGraphics , pPen , shape )
	Gdip_FillPolygon( pGraphics , pBrush , shape )
	Gdip_DeletePen( pPen )
	Gdip_DeleteBrush( pBrush )
	element := Elements[ 10 ]
	pBrush := Gdip_BrushCreateSolid( element.Color1 )
	pPen := Gdip_CreatePen( element.Color2 , element.Thickness * scale )
	sv := Vector( element.StartVector ) 
	sv.Mult( scale ) 
	shape := Vector.PolygonShape( sv , element.Radius * scale , element.Sides , element.StartAngle )
	shape .= &quot;|&quot; StrSplit( shape , &quot;|&quot; )[2]
	Gdip_DrawLines( pGraphics , pPen , shape )
	Gdip_FillPolygon( pGraphics , pBrush , shape )
	Gdip_DeletePen( pPen )
	Gdip_DeleteBrush( pBrush )
	element := Elements[ 11 ]
	pBrush := Gdip_BrushCreateSolid( element.Color1 )
	pPen := Gdip_CreatePen( element.Color2 , element.Thickness * scale )
	sv := Vector( element.StartVector ) 
	sv.Mult( scale ) 
	shape := Vector.PolygonShape( sv , element.Radius * scale , element.Sides , element.StartAngle )
	shape .= &quot;|&quot; StrSplit( shape , &quot;|&quot; )[2]
	Gdip_DrawLines( pGraphics , pPen , shape )
	Gdip_FillPolygon( pGraphics , pBrush , shape )
	Gdip_DeletePen( pPen )
	Gdip_DeleteBrush( pBrush )
	element := Elements[ 12 ]
	pBrush := Gdip_BrushCreateSolid( element.Color1 )
	pPen := Gdip_CreatePen( element.Color2 , element.Thickness * scale )
	sv := Vector( element.StartVector ) 
	sv.Mult( scale ) 
	shape := Vector.PolygonShape( sv , element.Radius * scale , element.Sides , element.StartAngle )
	shape .= &quot;|&quot; StrSplit( shape , &quot;|&quot; )[2]
	Gdip_DrawLines( pGraphics , pPen , shape )
	Gdip_FillPolygon( pGraphics , pBrush , shape )
	Gdip_DeletePen( pPen )
	Gdip_DeleteBrush( pBrush )
	Gdip_DeleteGraphics( pGraphics )
	if( returnType = &quot;hBitmap&quot; ){
		hBitmap := Gdip_CreateHBITMAPFromBitmap( pBitmap )
		Gdip_DisposeImage( pBitmap )
		return hBitmap
	}
	return pBitmap
}
;******************************************************************************************************
;******************************************************************************************************
;******************************************************************************************************

CursorElements(){
	local Elements2 := []
	Elements2.Push( { Index: 1 , Layer: 1 , ElementType: &quot;DrawArc&quot; , Rect: { X: 2 + 0 , Y: 2 + 0 , W: 26 , H: 26 } , StartAngle: &quot;0&quot; , SweepAngle: &quot;360&quot; , Thickness: &quot;2&quot; , Note: &quot;&quot; , BrushObject: { BrushType: &quot;SolidBrush&quot; ,  Color1: &quot;0xFFFF0000&quot; } } )
	Elements2.Push( { Index: 2 , Layer: 1 , ElementType: &quot;DrawArc&quot; , Rect: { X: 4 + 0 , Y: 4 + 0 , W: 22 , H: 22 } , StartAngle: &quot;0&quot; , SweepAngle: &quot;360&quot; , Thickness: &quot;2.5&quot; , Note: &quot;&quot; , BrushObject: { BrushType: &quot;SolidBrush&quot; ,  Color1: &quot;0xFF000000&quot; } } )
	Elements2.Push( { Index: 3 , Layer: 1 , ElementType: &quot;DrawArc&quot; , Rect: { X: 6 + 0 , Y: 6 + 0 , W: 18 , H: 18 } , StartAngle: &quot;0&quot; , SweepAngle: &quot;360&quot; , Thickness: &quot;2&quot; , Note: &quot;&quot; , BrushObject: { BrushType: &quot;SolidBrush&quot; ,  Color1: &quot;0xFFFF0000&quot; } } )
	return Elements2
}
;******************************************************************************************************
CursorFunction( Elements2 , Scale := 1 , returnType := &quot;pBitmap&quot; ){
	local pBitmap := Gdip_CreateBitmap( 30 * Scale , 30 * Scale )
	local pGraphics := Gdip_GraphicsFromImage( pBitmap )
	;Layer: 1
	Gdip_SetSmoothingMode( pGraphics , 2 ) , Gdip_SetInterpolationMode( pGraphics , 7 )
	element := Elements2[ 1 ] , Brush := element.BrushObject
	pPen := Gdip_CreatePen( Brush.Color1 , element.Thickness * scale )
	Gdip_DrawArc( pGraphics , pPen , ( element.Rect.X ) * scale , ( element.Rect.Y ) * scale , ( element.Rect.W ) * scale , ( element.Rect.H ) * scale , element.StartAngle , element.SweepAngle )
	Gdip_DeletePen( pPen )
	element := Elements2[ 2 ] , Brush := element.BrushObject
	pPen := Gdip_CreatePen( Brush.Color1 , element.Thickness * scale )
	Gdip_DrawArc( pGraphics , pPen , ( element.Rect.X ) * scale , ( element.Rect.Y ) * scale , ( element.Rect.W ) * scale , ( element.Rect.H ) * scale , element.StartAngle , element.SweepAngle )
	Gdip_DeletePen( pPen )
	element := Elements2[ 3 ] , Brush := element.BrushObject
	pPen := Gdip_CreatePen( Brush.Color1 , element.Thickness * scale )
	Gdip_DrawArc( pGraphics , pPen , ( element.Rect.X ) * scale , ( element.Rect.Y ) * scale , ( element.Rect.W ) * scale , ( element.Rect.H ) * scale , element.StartAngle , element.SweepAngle )
	Gdip_DeletePen( pPen )
	Gdip_DeleteGraphics( pGraphics )
	if( returnType = &quot;hBitmap&quot; ){
		hBitmap := Gdip_CreateHBITMAPFromBitmap( pBitmap )
		Gdip_DisposeImage( pBitmap )
		return hBitmap
	}
	return pBitmap
}
;******************************************************************************************************


global lastSection           := 0     ; Не нужно это трогать
global snapEnabled           := false ; Флаг для включения / выключения примагничивания
global snapStrength          := 0.05  ; Сила притяжения (0.0 - нет, 1.0 - моментальное прилипание)
global cursorPositionEnabled := false ; Флаг для появления GUI относительно курсора


F1::
{
	SystemCursor(&quot;Hide&quot;)
    MouseGetPos(&amp;startX, &amp;startY)

	if (cursorPositionEnabled) {
        ; Позиция GUI относительно курсора
        guiX := startX - 200
        guiY := startY - 200
        Gui1.Show(&quot;x&quot; guiX &quot; y&quot; guiY &quot; w400 h400&quot;)
    } else {
        Gui1.Show(&quot;w400 h400&quot;)
    }
	
	;DllCall(&quot;ShowCursor&quot;, &quot;int&quot;, 0)
    Gui1.Show(&quot;w400 h400&quot;)
    WinGetPos(&amp;guiX, &amp;guiY, , , Gui1)
    MouseMove(guiX + 199, guiY + 199, 0)
    SetTimer(RestrictCursor, 1)
    
    KeyWait(&quot;F1&quot;)
    SetTimer(RestrictCursor, 0)
    Gui1.Hide()
    SystemCursor(&quot;Show&quot;)
	;DllCall(&quot;ShowCursor&quot;, &quot;int&quot;, 1)

	SystemCursor(cmd) {
		static visible := true, c := Map()
		static sys_cursors := [32512, 32513, 32514, 32515, 32516, 32642
							 , 32643, 32644, 32645, 32646, 32648, 32649, 32650]
		if (cmd = &quot;Reload&quot; or !c.Count) {
			for i, id in sys_cursors {
				h_cursor  := DllCall(&quot;LoadCursor&quot;, &quot;Ptr&quot;, 0, &quot;Ptr&quot;, id)
				h_default := DllCall(&quot;CopyImage&quot;, &quot;Ptr&quot;, h_cursor, &quot;UInt&quot;, 2
					, &quot;Int&quot;, 0, &quot;Int&quot;, 0, &quot;UInt&quot;, 0)
				h_blank   := DllCall(&quot;CreateCursor&quot;, &quot;Ptr&quot;, 0, &quot;Int&quot;, 0, &quot;Int&quot;, 0
					, &quot;Int&quot;, 32, &quot;Int&quot;, 32
					, &quot;Ptr&quot;, Buffer(32*4, 0xFF)
					, &quot;Ptr&quot;, Buffer(32*4, 0))
				c[id] := {default: h_default, blank: h_blank}
			}
		}
		switch cmd {
		case &quot;Show&quot;: visible := true
		case &quot;Hide&quot;: visible := false
		case &quot;Toggle&quot;: visible := !visible
		default: return
		}
		for id, handles in c {
			h_cursor := DllCall(&quot;CopyImage&quot;
				, &quot;Ptr&quot;, visible ? handles.default : handles.blank
				, &quot;UInt&quot;, 2, &quot;Int&quot;, 0, &quot;Int&quot;, 0, &quot;UInt&quot;, 0)
			DllCall(&quot;SetSystemCursor&quot;, &quot;Ptr&quot;, h_cursor, &quot;UInt&quot;, id)
		}
	}

    MouseGetPos(&amp;x, &amp;y)
    x             -= guiX
    y             -= guiY
    centerX       := 200
    centerY       := 200
    radius        := 76
    edgeThreshold := 60

    dist := Sqrt((x - centerX)**2 + (y - centerY)**2)
    if (dist &gt;= edgeThreshold) {
        angle   := ATan2(x - centerX, y - centerY)
        section := Floor(angle / 45) + 1

        switch section {
            Case 1: Run &quot;calc.exe&quot; ; Sector 1 (0° - 45°)    + 22.5
            Case 2: MsgBox &quot;Sector 2 (45°-90°)&quot;   &quot;`nDist: &quot; dist &quot;`nAngle: &quot; angle ; Sector 2 (45° - 90°)   + 22.5
            Case 3: MsgBox &quot;Sector 3 (90°-135°)&quot;  &quot;`nDist: &quot; dist &quot;`nAngle: &quot; angle ; Sector 3 (90° - 135°)  + 22.5
            Case 4: MsgBox &quot;Sector 4 (135°-180°)&quot; &quot;`nDist: &quot; dist &quot;`nAngle: &quot; angle ; Sector 4 (135° - 180°) + 22.5
            Case 5: MsgBox &quot;Sector 5 (180°-225°)&quot; &quot;`nDist: &quot; dist &quot;`nAngle: &quot; angle ; Sector 5 (180° - 225°) + 22.5
            Case 6: MsgBox &quot;Sector 6 (225°-270°)&quot; &quot;`nDist: &quot; dist &quot;`nAngle: &quot; angle ; Sector 6 (225° - 270°) + 22.5
            Case 7: MsgBox &quot;Sector 7 (270°-315°)&quot; &quot;`nDist: &quot; dist &quot;`nAngle: &quot; angle ; Sector 7 (270° - 315°) + 22.5
            Case 8: MsgBox &quot;Sector 8 (315°-360°)&quot; &quot;`nDist: &quot; dist &quot;`nAngle: &quot; angle ; Sector 8 (315° - 360°) + 22.5
        }
    }
    MouseMove(startX, startY, 0)
}


RestrictCursor() {
    MouseGetPos(&amp;x, &amp;y)
    WinGetPos(&amp;guiX, &amp;guiY, , , Gui1)
    relX    := x - guiX
    relY    := y - guiY
    centerX := 200
    centerY := 200
    radius  := 76

    if ((relX - centerX)**2 + (relY - centerY)**2 &gt; radius**2) {
        dx   := relX - centerX
        dy   := relY - centerY
        dist := Sqrt(dx**2 + dy**2)
        if (dist &gt; radius) {
            relX := centerX + dx * radius / dist
            relY := centerY + dy * radius / dist
            MouseMove(relX + guiX, relY + guiY, 0)
        }
    }

	  ; Логика примагничивания
	  edgeThreshold := 64
	  dist := Sqrt((relX - centerX)**2 + (relY - centerY)**2)
	  if (snapEnabled &amp;&amp; dist &gt;= edgeThreshold) {
		  angle := ATan2(relX - centerX, relY - centerY)
		  section := Floor(angle / 45) + 1
		  if (section &gt;= 1 &amp;&amp; section &lt;= 8) {
			  targetAngle := (section - 1) * 45
			  targetRad := targetAngle * 0.0174532925  ; Градусы в радианы (π/180)
			  targetX := centerX + Cos(targetRad) * radius
			  targetY := centerY + Sin(targetRad) * radius
			  ; Интерполяция текущей позиции к целевой
			  relX := relX + (targetX - relX) * snapStrength
			  relY := relY + (targetY - relY) * snapStrength
			  MouseMove(relX + guiX, relY + guiY, 0)
		  }
	  }
    Gui1.Pic1.Move(relX - 14, relY - 14)
	;Cursorpic.Move(relX - 10, relY - 10)


    edgeThreshold := 60
    dist := Sqrt((relX - centerX)**2 + (relY - centerY)**2)
    
    Loop 8 {
        Gui1.Elements[A_Index + 4].Color1 := &quot;0xFFFA7878&quot;
        Gui1.Elements[A_Index + 4].Color2 := &quot;0xFF373737&quot;
        Gui1.Elements[A_Index + 4].Radius := 12
    }

    global currentSection := 0
    if (dist &gt;= edgeThreshold) {
        angle := ATan2(relX - centerX, relY - centerY)
        currentSection := Floor(angle / 45) + 1
        if (currentSection &gt;= 1 &amp;&amp; currentSection &lt;= 8) {
            switch currentSection {
                Case 1: Gui1.Elements[5].Color1  := &quot;0xffff0000&quot;
                        Gui1.Elements[5].Color2  := &quot;0xff000000&quot;
                        Gui1.Elements[5].Radius  := 16

                Case 2: Gui1.Elements[6].Color1  := &quot;0xffff0000&quot;
                        Gui1.Elements[6].Color2  := &quot;0xff000000&quot;
						Gui1.Elements[6].Radius  := 16

                Case 3: Gui1.Elements[7].Color1  := &quot;0xffff0000&quot;
                        Gui1.Elements[7].Color2  := &quot;0xff000000&quot;
						Gui1.Elements[7].Radius  := 16

                Case 4: Gui1.Elements[8].Color1  := &quot;0xffff0000&quot;
                        Gui1.Elements[8].Color2  := &quot;0xff000000&quot;
						Gui1.Elements[8].Radius  := 16

                Case 5: Gui1.Elements[9].Color1  := &quot;0xffff0000&quot;
                        Gui1.Elements[9].Color2  := &quot;0xff000000&quot;
						Gui1.Elements[9].Radius  := 16

                Case 6: Gui1.Elements[10].Color1 := &quot;0xffff0000&quot;
                        Gui1.Elements[10].Color2 := &quot;0xff000000&quot;
						Gui1.Elements[10].Radius := 16

                Case 7: Gui1.Elements[11].Color1 := &quot;0xffff0000&quot;
                        Gui1.Elements[11].Color2 := &quot;0xff000000&quot;
						Gui1.Elements[11].Radius := 16

                Case 8: Gui1.Elements[12].Color1 := &quot;0xffff0000&quot;
                        Gui1.Elements[12].Color2 := &quot;0xff000000&quot;
						Gui1.Elements[12].Radius := 16
            }
        }
    }
    global lastSection
    if (currentSection != lastSection) {
		Sleep 1
        Gui1.Pic2.Value := &quot;hBitmap: &quot; OwerlayFunction(Gui1.Elements ,, &quot;hBitmap&quot;)
        lastSection := currentSection
    }
}

ATan2(x, y) {
	Static Rad2Deg := 45/ATan(1)
	A := DllCall(&quot;msvcrt\atan2&quot;, &quot;Double&quot;, y, &quot;Double&quot;, x, &quot;CDECL Double&quot;) * Rad2Deg
    A := A + 22.5
    return A &lt; 0 ? A + 360 : A
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (disintegration66)]]></author>
			<pubDate>Fri, 21 Mar 2025 15:24:55 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=162112#p162112</guid>
		</item>
	</channel>
</rss>
