<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Инвертирование цвета окна с magnification + UIACCESS]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=16562&amp;type=atom" />
	<updated>2021-08-30T00:26:26Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=16562</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Инвертирование цвета окна с magnification + UIACCESS]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149396#p149396" />
			<content type="html"><![CDATA[<p>А, теперь понял. Ну сейчас действительно уже не грузит.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-08-30T00:26:26Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149396#p149396</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Инвертирование цвета окна с magnification + UIACCESS]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149395#p149395" />
			<content type="html"><![CDATA[<p>Так оно может и не менять расположения.<br />Например при проигрывании видео в плеере.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2021-08-30T00:19:25Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149395#p149395</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Инвертирование цвета окна с magnification + UIACCESS]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149394#p149394" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>Ну а как узнать, что нужно менять область?</p></blockquote></div><p>Когда целевое окно меняет расположение.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-08-30T00:18:35Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149394#p149394</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Инвертирование цвета окна с magnification + UIACCESS]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149393#p149393" />
			<content type="html"><![CDATA[<p>Ну а как узнать, что нужно менять область?<br />Без колбека вообще процессор не подгружает.<br />Я чувствовал, что какой-то затык в коде. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2021-08-30T00:17:35Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149393#p149393</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Инвертирование цвета окна с magnification + UIACCESS]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149392#p149392" />
			<content type="html"><![CDATA[<p>Почему? По идее MagSetWindowSource должна вызываться, только когда область нужно менять.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-08-30T00:14:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149392#p149392</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Инвертирование цвета окна с magnification + UIACCESS]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149391#p149391" />
			<content type="html"><![CDATA[<p>Не, без него никак, но зато можно обойтись без callback.<br />Поправил первый пост.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2021-08-30T00:11:18Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149391#p149391</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Инвертирование цвета окна с magnification + UIACCESS]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149389#p149389" />
			<content type="html"><![CDATA[<p>Как я понимаю, загрузка из-за этого цикла:<br /></p><div class="codebox"><pre><code>loop
{
   if (A_PtrSize = 8)
   {
      VarSetCapacity(RECT, 16, 0)
      NumPut(0, RECT, 0, &quot;int&quot;)
      NumPut(0, RECT, 4, &quot;int&quot;)
      NumPut(A_ScreenWidth, RECT, 8, &quot;int&quot;)
      NumPut(A_ScreenHeight, RECT, 12, &quot;int&quot;)
      DllCall(&quot;magnification.dll\MagSetWindowSource&quot;, &quot;ptr&quot;, hChildMagnifier, &quot;ptr&quot;, &amp;RECT)
   }
}</code></pre></div><p>А без него никак?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-08-30T00:06:40Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149389#p149389</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Инвертирование цвета окна с magnification + UIACCESS]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149387#p149387" />
			<content type="html"><![CDATA[<p>Он и не должен выключаться.<br />Это просто пример загрузки процессора при инвертировании экрана целиком.<br /></p><div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>С окном из кода не пробовал, но в принципе так:</p></blockquote></div><p>Так не подходит, так-как не перекрываются созданные дочерние окна.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2021-08-29T23:59:46Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149387#p149387</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Инвертирование цвета окна с magnification + UIACCESS]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149386#p149386" />
			<content type="html"><![CDATA[<p>Так у меня на весь экран получается, и не выключается по F11, и загрузка ещё больше почему-то.<br /></p><div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>Пример можешь привести?</p></blockquote></div><p>С окном из кода не пробовал, но в принципе так:<br /></p><div class="codebox"><pre><code>Gui, New, +hwndhGui
Gui, Show, w300 h300
Run notepad,,, PID
WinWait, ahk_pid %PID%
DllCall(&quot;SetWindowLong&quot; . (A_PtrSize = 4 ? &quot;&quot; : &quot;Ptr&quot;), &quot;Ptr&quot;, hGui, &quot;Int&quot;, GWLP_HWNDPARENT := -8, &quot;Ptr&quot;, WinExist())
WinActivate, ahk_id %hGui%</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-08-29T23:55:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149386#p149386</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Инвертирование цвета окна с magnification + UIACCESS]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149384#p149384" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>Этот код у меня вызывает перманентное мелькание, если активное окно изначально развёрнуто в полный экран.</p></blockquote></div><p>Я такого не обнаружил, но пока тестировал получил мелькание при перезапуске скрипта.<br />Вроде поправил.<br /></p><div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Вместо цикла я бы использовал хук, будет быстрее реагировать на изменение размеров окна, и меньше грузить процессор (сейчас на 10-15%).</p></blockquote></div><p>Можно и хук использовать, только процессор это не разгрузит, а запарок будет больше, так как надо отслеживать не только изменения, но и z-order, чтобы менять гуи.<br />Так-как первый гуи (ZBID_DESKTOP) создается для случаев, когда целевое окно перекрывается другими окнами, второй же создается для случаев когда целевое окно активно и в нем могут создаваться дополнительные дочерние окна, дабы избежать мельканий создаем гуи с ZBID_UIACCESS.<br />Вот загрузка процессора без отслеживания измененя размеров:<br /></p><div class="codebox"><pre><code>if !RegExMatch(DllCall(&quot;GetCommandLine&quot;, &quot;str&quot;), &quot; /restart(?!\S)&quot;)
{
   if A_Is64bitOS
      RunWait &quot;C:\Program Files\AutoHotkey\AutoHotkeyU64_UIA.exe&quot; /restart &quot;%A_ScriptFullPath%&quot;
   else
      RunWait &quot;C:\Program Files\AutoHotkey\AutoHotkeyU32_UIA.exe&quot; /restart &quot;%A_ScriptFullPath%&quot;
}
Global hPic
#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
   {
      Gui, %A_Index%: +HWNDhGui%A_Index% -DPIScale +toolwindow -Caption +E0x02000000 +E0x00080000 +E0x20 ;  WS_EX_COMPOSITED := E0x02000000  WS_EX_LAYERED := E0x00080000
      Gui, %A_Index%: Margin, 0,0
      Gui, %A_Index%: Add, text, w1 h1 0xE hwndhPic   ; SS_BITMAP
      if (A_Index  = 2)
      {
         Gui, %A_Index%: +AlwaysOnTop
         Gui, %A_Index%: Show, NA
      }
      hChildMagnifier%A_Index% := DllCall(&quot;CreateWindowInBand&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;, 1, &quot;int&quot;, 1, &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;uint&quot;, A_Index, &quot;ptr&quot;)   ; ZBID_DESKTOP ZBID_UIACCESS
      DllCall(&quot;magnification.dll\MagSetColorEffect&quot;, &quot;ptr&quot;, hChildMagnifier%A_Index%, &quot;ptr&quot;, &amp;MAGCOLOREFFECT)
      DllCall(&quot;magnification.dll\MagSetImageScalingCallback&quot;, &quot;ptr&quot;, hChildMagnifier%A_Index%, &quot;ptr&quot;, RegisterCallback(&quot;MagImageScalingCallback&quot;))
   }
}
hGui := hGui2
hChildMagnifier := hChildMagnifier2
WinMove, ahk_id %hGui%,, 0, 0, A_ScreenWidth, A_ScreenHeight
WinMove, ahk_id %hChildMagnifier%,, 0, 0, A_ScreenWidth, A_ScreenHeight
WinShow ahk_id %hGui%
WinShow, ahk_id %hChildMagnifier%
loop
{
   if (A_PtrSize = 8)
   {
      VarSetCapacity(RECT, 16, 0)
      NumPut(0, RECT, 0, &quot;int&quot;)
      NumPut(0, RECT, 4, &quot;int&quot;)
      NumPut(A_ScreenWidth, RECT, 8, &quot;int&quot;)
      NumPut(A_ScreenHeight, RECT, 12, &quot;int&quot;)
      DllCall(&quot;magnification.dll\MagSetWindowSource&quot;, &quot;ptr&quot;, hChildMagnifier, &quot;ptr&quot;, &amp;RECT)
   }
}
return

MagImageScalingCallback(hwnd, srcdata, srcheader, destdata, destheader, unclipped, clipped, dirty)
{
   Static CBM_INIT := 6, DIB_RGB_COLORS := 0, STM_SETIMAGE := 0x172, IMAGE_BITMAP := 0x0, _ := VarSetCapacity(BITMAPV5HEADER, 124, 0), __ := VarSetCapacity(BITMAPINFO, 44, 0)
   if (A_PtrSize = 8)
   {
      bV5Width := NumGet(srcheader + 0, 0, &quot;uint&quot;)
      bV5Height := NumGet(srcheader + 0, 4, &quot;uint&quot;) 
   }
   else
   {
      bV5Width := srcheader
      bV5Height := destdata
   }
   NumPut(124, BITMAPV5HEADER, 0, &quot;uint&quot;)		;	DWORD		bV5Size;
   NumPut(bV5Width, BITMAPV5HEADER, 4, &quot;uint&quot;)		;	LONG		bV5Width;
   NumPut(bV5Height, BITMAPV5HEADER, 8, &quot;uint&quot;)		;	LONG		bV5Height;
   NumPut(1, BITMAPV5HEADER, 12, &quot;short&quot;)		;	WORD		bV5Planes;
   NumPut(32, BITMAPV5HEADER, 14, &quot;short&quot;)		;	WORD		bV5BitCount;

   NumPut(44, BITMAPINFO, 0, &quot;uint&quot;)			;	DWORD		biSize;
   NumPut(bV5Width, BITMAPINFO, 4, &quot;uint&quot;)  		;	LONG		biWidth;
   NumPut(-bV5Height, BITMAPINFO, 8, &quot;uint&quot;)  		;	LONG		biHeight;
   NumPut(1, BITMAPINFO, 12, &quot;short&quot;)  			;	WORD		biPlanes;
   NumPut(32, BITMAPINFO, 14, &quot;short&quot;) 			;	WORD		biBitCount;
   hDC := DllCall(&quot;GetDC&quot;, &quot;ptr&quot;, hwnd, &quot;ptr&quot;)
   hBMP := DllCall(&quot;CreateDIBitmap&quot;, &quot;ptr&quot;, hDC, &quot;ptr&quot;, &amp;BITMAPV5HEADER, &quot;uint&quot;, CBM_INIT, &quot;ptr&quot;,  srcdata, &quot;ptr&quot;, &amp;BITMAPINFO, &quot;uint&quot;, DIB_RGB_COLORS, &quot;ptr&quot;) 
   SendMessage, STM_SETIMAGE, IMAGE_BITMAP, hBMP,, ahk_id %hPic% 
   DllCall(&quot;DeleteObject&quot;, &quot;ptr&quot;, ErrorLevel)
   DllCall(&quot;DeleteDC&quot;, &quot;ptr&quot;, hDC)
   DllCall(&quot;DeleteObject&quot;, &quot;ptr&quot;, hBMP)
   return
}

Uninitialize:
if (hGui != &quot;&quot;)
   DllCall(&quot;magnification.dll\MagUninitialize&quot;)
ExitApp</code></pre></div><div class="quotebox"><blockquote><p>И вместо CreateWindowInBand не проще сделать целевое окно окном-владельцем?</p></blockquote></div><p>Пример можешь привести?</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2021-08-29T21:52:29Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149384#p149384</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Инвертирование цвета окна с magnification + UIACCESS]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149380#p149380" />
			<content type="html"><![CDATA[<p>Этот код у меня вызывает перманентное мелькание, если активное окно изначально развёрнуто в полный экран. Вместо цикла я бы использовал хук, будет быстрее реагировать на изменение размеров окна, и меньше грузить процессор (сейчас на 10-15%).<br />И вместо CreateWindowInBand не проще сделать целевое окно окном-владельцем?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-08-29T19:17:07Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149380#p149380</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Инвертирование цвета окна с magnification + UIACCESS]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149379#p149379" />
			<content type="html"><![CDATA[<p>Тема для обсуждения &quot;Инвертирование цвета окна с magnification + UIACCESS&quot;.<br /><a href="http://forum.script-coding.com/viewtopic.php?id=17661">http://forum.script-coding.com/viewtopic.php?id=17661</a></p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2021-08-29T15:50:09Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149379#p149379</id>
		</entry>
</feed>
