<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Инвертирование цвета окна с magnification + UIACCESS]]></title>
		<link>http://forum.script-coding.com/viewtopic.php?id=17661</link>
		<atom:link href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=17661&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Инвертирование цвета окна с magnification + UIACCESS».]]></description>
		<lastBuildDate>Sun, 12 Mar 2023 02:51:54 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[AHK: Инвертирование цвета окна с magnification + UIACCESS]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=157098#p157098</link>
			<description><![CDATA[<p>Для Win 8+.<br />Инвертировать/снять инвертирование - активировать окно и нажать f11.<br /></p><div class="codebox"><pre><code>Gui, +HWNDhGui +AlwaysOnTop
DllCall(&quot;GetWindowBand&quot;, &quot;ptr&quot;, hGui, &quot;uint*&quot;, band)
Gui, Destroy
hGui := &quot;&quot;
if (band = 1)
{
   If (A_PtrSize = 8)
      RunWait &quot;C:\Program Files\AutoHotkey\AutoHotkeyU64_UIA.exe&quot; &quot;%A_ScriptFullPath%&quot;
   Else If A_IsUnicode
      RunWait &quot;C:\Program Files\AutoHotkey\AutoHotkeyU32_UIA.exe&quot; &quot;%A_ScriptFullPath%&quot;
   Else
      RunWait &quot;C:\Program Files\AutoHotkey\AutoHotkeyA32_UIA.exe&quot; &quot;%A_ScriptFullPath%&quot;
}
#SingleInstance Force
#MaxThreadsPerHotkey 2
DetectHiddenWindows, On
SetBatchLines -1
SetWinDelay -1
OnExit, Uninitialize
return

f11::
hTarget := WinExist(&quot;A&quot;)
if (hTarget = hTargetPrev)
{
   hTargetPrev := &quot;&quot;
   count--
   return
}
count++
hTargetPrev := hTarget
if (hGui = &quot;&quot;)
{
   DllCall(&quot;LoadLibrary&quot;, &quot;str&quot;, &quot;magnification.dll&quot;)
   DllCall(&quot;magnification.dll\MagInitialize&quot;)
   Matrix := &quot;-1|0|0|0|0|&quot;
           . &quot;0|-1|0|0|0|&quot;
           . &quot;0|0|-1|0|0|&quot;
           . &quot;0|0|0|1|0|&quot;
           . &quot;1|1|1|0|1&quot;
   VarSetCapacity(MAGCOLOREFFECT, 100, 0)
   Loop, Parse, Matrix, |
      NumPut(A_LoopField, MAGCOLOREFFECT, (A_Index - 1) * 4, &quot;float&quot;)
   loop 2
   {
      if (A_Index = 2)
         Gui, %A_Index%: +AlwaysOnTop   ; needed for ZBID_UIACCESS
      Gui, %A_Index%: +HWNDhGui%A_Index% -DPIScale +toolwindow -Caption +E0x02000000 +E0x00080000 +E0x20 ;  WS_EX_COMPOSITED := E0x02000000  WS_EX_LAYERED := E0x00080000  WS_EX_CLICKTHROUGH := E0x20
      hChildMagnifier%A_Index% := DllCall(&quot;CreateWindowEx&quot;, &quot;uint&quot;, 0, &quot;str&quot;, &quot;Magnifier&quot;, &quot;str&quot;, &quot;MagnifierWindow&quot;, &quot;uint&quot;, WS_CHILD := 0x40000000, &quot;int&quot;, 0, &quot;int&quot;, 0, &quot;int&quot;, 0, &quot;int&quot;, 0, &quot;ptr&quot;, hGui%A_Index%, &quot;uint&quot;, 0, &quot;ptr&quot;, DllCall(&quot;GetWindowLong&quot; (A_PtrSize=8 ? &quot;Ptr&quot; : &quot;&quot;), &quot;ptr&quot;, hGui%A_Index%, &quot;int&quot;, GWL_HINSTANCE := -6 , &quot;ptr&quot;), &quot;uint&quot;, 0, &quot;ptr&quot;)
      DllCall(&quot;magnification.dll\MagSetColorEffect&quot;, &quot;ptr&quot;, hChildMagnifier%A_Index%, &quot;ptr&quot;, &amp;MAGCOLOREFFECT)
   }
}
Gui, 2: Show, NA   ; needed for removing flickering
hGui := hGui1
hChildMagnifier := hChildMagnifier1
loop
{
   if (count != 1)   ; target window changed
   {
      if (count = 2)
         count--
      WinHide, ahk_id %hGui%
      return
   }
   VarSetCapacity(WINDOWINFO, 60, 0)
   if (DllCall(&quot;GetWindowInfo&quot;, &quot;ptr&quot;, hTarget, &quot;ptr&quot;, &amp;WINDOWINFO) = 0) and (A_LastError = 1400)   ; destroyed
   {
      count--
      WinHide, ahk_id %hGui%
      return
   }
   if (NumGet(WINDOWINFO, 36, &quot;uint&quot;) &amp; 0x20000000) or !(NumGet(WINDOWINFO, 36, &quot;uint&quot;) &amp; 0x10000000)  ; minimized or not visible
   {
      if (wPrev != 0)
      {
         WinHide, ahk_id %hGui%
         wPrev := 0
      }
      sleep 10
      continue
   }
   x := NumGet(WINDOWINFO, 20, &quot;int&quot;)
   y := NumGet(WINDOWINFO, 8, &quot;int&quot;)
   w := NumGet(WINDOWINFO, 28, &quot;int&quot;) - x
   h := NumGet(WINDOWINFO, 32, &quot;int&quot;) - y
   if (hGui = hGui1) and ((NumGet(WINDOWINFO, 44, &quot;uint&quot;) = 1) or (DllCall(&quot;GetAncestor&quot;, &quot;ptr&quot;, WinExist(&quot;A&quot;), &quot;uint&quot;, GA_ROOTOWNER := 3, &quot;ptr&quot;) = hTarget))   ; activated
   {
      hGui := hGui2
      hChildMagnifier := hChildMagnifier2
      WinMove, ahk_id %hGui%,, x, y, w, h
      WinMove, ahk_id %hChildMagnifier%,, 0, 0, w, h
      WinShow, ahk_id %hChildMagnifier%
      WinShow, ahk_id %hGui%
      hideGui := hGui1
   }
   else if (hGui = hGui2) and (NumGet(WINDOWINFO, 44, &quot;uint&quot;) != 1) and ((hr := DllCall(&quot;GetAncestor&quot;, &quot;ptr&quot;, WinExist(&quot;A&quot;), &quot;uint&quot;, GA_ROOTOWNER := 3, &quot;ptr&quot;)) != hTarget) and hr   ; deactivated
   {
      hGui := hGui1
      hChildMagnifier := hChildMagnifier1
      WinMove, ahk_id %hGui%,, x, y, w, h
      WinMove, ahk_id %hChildMagnifier%,, 0, 0, w, h
      WinShow, ahk_id %hChildMagnifier%
      DllCall(&quot;SetWindowPos&quot;, &quot;ptr&quot;, hGui, &quot;ptr&quot;, hTarget, &quot;int&quot;, 0, &quot;int&quot;, 0, &quot;int&quot;, 0, &quot;int&quot;, 0, &quot;uint&quot;, 0x0040|0x0010|0x001|0x002)
      DllCall(&quot;SetWindowPos&quot;, &quot;ptr&quot;, hTarget, &quot;ptr&quot;, 1, &quot;int&quot;, 0, &quot;int&quot;, 0, &quot;int&quot;, 0, &quot;int&quot;, 0, &quot;uint&quot;, 0x0040|0x0010|0x001|0x002)   ; some windows can not be z-positioned before setting them to bottom
      DllCall(&quot;SetWindowPos&quot;, &quot;ptr&quot;, hTarget, &quot;ptr&quot;, hGui, &quot;int&quot;, 0, &quot;int&quot;, 0, &quot;int&quot;, 0, &quot;int&quot;, 0, &quot;uint&quot;, 0x0040|0x0010|0x001|0x002)
      hideGui := hGui2 
   }
   else if (x != xPrev) or (y != yPrev) or (w != wPrev) or (h != hPrev)   ; location changed
   {
      WinMove, ahk_id %hGui%,, x, y, w, h
      WinMove, ahk_id %hChildMagnifier%,, 0, 0, w, h
      WinShow, ahk_id %hChildMagnifier%
      WinShow, ahk_id %hGui%
   }
   if (A_PtrSize = 8)
   {
      VarSetCapacity(RECT, 16, 0)
      NumPut(x, RECT, 0, &quot;int&quot;)
      NumPut(y, RECT, 4, &quot;int&quot;)
      NumPut(w, RECT, 8, &quot;int&quot;)
      NumPut(h, RECT, 12, &quot;int&quot;)
      DllCall(&quot;magnification.dll\MagSetWindowSource&quot;, &quot;ptr&quot;, hChildMagnifier, &quot;ptr&quot;, &amp;RECT)
   }
   else
      DllCall(&quot;magnification.dll\MagSetWindowSource&quot;, &quot;ptr&quot;, hChildMagnifier, &quot;int&quot;, x, &quot;int&quot;, y, &quot;int&quot;, w, &quot;int&quot;, h)
   xPrev := x, yPrev := y, wPrev := w, hPrev := h
   if hideGui
   {
      WinHide, ahk_id %hideGui%
      hideGui := &quot;&quot;
   }
}
return

Uninitialize:
if (hGui != &quot;&quot;)
   DllCall(&quot;magnification.dll\MagUninitialize&quot;)
ExitApp</code></pre></div><p><a href="http://forum.script-coding.com/viewtopic.php?id=16562">Тема для обсуждения</a></p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Sun, 12 Mar 2023 02:51:54 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=157098#p157098</guid>
		</item>
	</channel>
</rss>
