<?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="http://forum.script-coding.com/extern.php?action=feed&amp;tid=17657&amp;type=atom" />
	<updated>2023-03-12T02:32:28Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=17657</id>
		<entry>
			<title type="html"><![CDATA[AHK: Тест гуи в портретном режиме монитора]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=157094#p157094" />
			<content type="html"><![CDATA[<p>Понадобилось написать гуи для портретного режима монитора.<br />Переворачивать монитор взад-вперед неохота - написал скрипт.<br />По f11 идет переключение режимов.<br />При нажатии esc переходит в режим альбома.<br /></p><div class="codebox"><pre><code>#SingleInstance, Force
OnExit, RemoveHook
Global prevX, prevY
VarSetCapacity(DEVMODE, 220, 0)
NumPut(220, DEVMODE, 68, &quot;short&quot;)   ; dmSize
DllCall(&quot;EnumDisplaySettingsW&quot;, &quot;ptr&quot;, 0, &quot;int&quot;, -1, &quot;ptr&quot;, &amp;DEVMODE)
width := NumGet(DEVMODE, 172, &quot;uint&quot;)
height := NumGet(DEVMODE, 176, &quot;uint&quot;)

f11::
if !hHookMouse
{
   NumPut(width, DEVMODE, 176, &quot;int&quot;)
   NumPut(height, DEVMODE, 172, &quot;int&quot;)
   NumPut(DMDO_90 := 1, DEVMODE, 84, &quot;int&quot;)   ; dmDisplayOrientation
   DllCall(&quot;ChangeDisplaySettingsW&quot;, &quot;ptr&quot;, &amp;DEVMODE, &quot;uint&quot;, 0)
   hHookMouse := DllCall(&quot;SetWindowsHookEx&quot;, &quot;int&quot;, WH_MOUSE_LL := 14, &quot;ptr&quot;, RegisterCallback(&quot;WH_MOUSE_LL&quot;, &quot;Fast&quot;), &quot;ptr&quot;, DllCall(&quot;GetModuleHandle&quot;, &quot;uint&quot;, 0, &quot;ptr&quot;), &quot;uint&quot;, 0, &quot;ptr&quot;)
}
else
   GoSub, RemoveHook
return

esc::
GoSub, RemoveHook
return

RemoveHook:
if hHookMouse
{
   DllCall(&quot;UnhookWindowsHookEx&quot;, &quot;ptr&quot;, hHookMouse)
   NumPut(width, DEVMODE, 172, &quot;int&quot;)
   NumPut(height, DEVMODE, 176, &quot;int&quot;)
   NumPut(DMDO_DEFAULT := 0, DEVMODE, 84, &quot;int&quot;)   ; dmDisplayOrientation
   DllCall(&quot;ChangeDisplaySettingsW&quot;, &quot;ptr&quot;, &amp;DEVMODE, &quot;uint&quot;, 0)
   prevX := prevY := hHookMouse := &quot;&quot;
}
if A_ExitReason
   ExitApp
return

WH_MOUSE_LL(nCode, wParam, lParam)
{
   Critical
   if !nCode &amp;&amp; (wParam = 0x200)   ; WM_MOUSEMOVE
   {
      x := NumGet(lParam+0, 0, &quot;int&quot;) ; x-coord
      y := NumGet(lParam+0, 4, &quot;int&quot;) ; y-coord
      if (prevX = &quot;&quot;)
         prevX := x
      if (prevY = &quot;&quot;)
         prevY := y
      newX := prevX - y + prevY
      newY := prevY + x - prevX
      DllCall(&quot;SetCursorPos&quot;, &quot;int&quot;, newX, &quot;int&quot;, newY)
      VarSetCapacity(lpPoint, 8)
      DllCall(&quot;GetCursorPos&quot;, &quot;ptr&quot;, &amp;lpPoint)
      prevX := NumGet(lpPoint, 0, &quot;int&quot;)
      prevY := NumGet(lpPoint, 4, &quot;int&quot;)
      NumPut(newX, lParam+0, 0, &quot;int&quot;)
      NumPut(newY, lParam+0, 4, &quot;int&quot;)
      DllCall(&quot;CallNextHookEx&quot;, &quot;ptr&quot;, 0, &quot;int&quot;, nCode, &quot;int&quot;, wParam, &quot;ptr&quot;, lParam)
      return 1
   }
   else
      return DllCall(&quot;CallNextHookEx&quot;, &quot;ptr&quot;, 0, &quot;int&quot;, nCode, &quot;int&quot;, wParam, &quot;ptr&quot;, lParam) 
}</code></pre></div><p><a href="http://forum.script-coding.com/viewtopic.php?id=16647">Тема для обсуждения</a></p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2023-03-12T02:32:28Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=157094#p157094</id>
		</entry>
</feed>
