<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Зона курсора]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=13478&amp;type=atom" />
	<updated>2018-02-19T17:56:52Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=13478</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Зона курсора]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=123781#p123781" />
			<content type="html"><![CDATA[<p>Можно с помощью winapi-функции <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms648383(v=vs.85).aspx">ClipCursor</a>. Пример использования, для наглядности красная рамка по границе области:<br /></p><div class="codebox"><pre><code>Clip:
   ClipCursor( (A_ScreenWidth - 400)/2, (A_ScreenHeight - 400)/2, 400, 400 )
   Return
   
$F10:: Gosub, Clip
$F11:: ClipCursor()
$Esc:: ExitApp

ClipCursor(x := &quot;&quot;, y := &quot;&quot;, w := &quot;&quot;, h := &quot;&quot;)  {
   static myFrame, _ := OnExit( Func(&quot;ClipCursor&quot;).Bind(&quot;&quot;) )
   if (x = &quot;&quot;)
      DllCall(&quot;ClipCursor&quot;, Ptr, 0), myFrame := &quot;&quot;
   else  {
      VarSetCapacity(RECT, 16, 0)
      NumPut(x, RECT)
      NumPut(y, RECT, 4)
      NumPut(x + w + 1, RECT, 8)
      NumPut(y + h + 1, RECT, 12, &quot;Int&quot;)
      DllCall(&quot;ClipCursor&quot;, Ptr, &amp;RECT)
      myFrame := new ColoredFrame(x, y, w, h, 3, 0xFF0000)
   }
}

class ColoredFrame
{
   __New(x, y, width, height, thickness, color)  {
      Gui, New, +hwndhGui +ToolWindow -Caption +LastFound +AlwaysOnTop -DPIScale +E0x20 ; WS_EX_TRANSPARENT = 0x20
      Gui, Color, %color%
      this.hGui := hGui

      t := thickness, w := width + t*2, h := height + t*2
      dx := width + t, dy := height + t, x -= t, y -= t
      
      WinSet, Region, 0-0 %w%-0 %w%-%h% 0-%h% 0-0 %t%-%t% %dx%-%t% %dx%-%dy% %t%-%dy% %t%-%t%
      WinSet, Transparent, 0xFF
      Gui, Show, NA x%x% y%y% w%w% h%h%
   }
   
   __Delete()  {
      Gui, % this.hGui &quot;: Destroy&quot;
   }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2018-02-19T17:56:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=123781#p123781</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Зона курсора]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=123778#p123778" />
			<content type="html"><![CDATA[<p>Возможно ли запретить курсору заходить на заданную зону?<br />Иль наоборот ограничить его перемещение зоной?</p><p>Mousemove конечно хорош, но он дерганый.</p>]]></content>
			<author>
				<name><![CDATA[shahlik002]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=37352</uri>
			</author>
			<updated>2018-02-18T22:18:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=123778#p123778</id>
		</entry>
</feed>
