<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Как ускорить вычисление цвета]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=15266</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=15266&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Как ускорить вычисление цвета».]]></description>
		<lastBuildDate>Fri, 22 May 2020 14:04:01 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Как ускорить вычисление цвета]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=139666#p139666</link>
			<description><![CDATA[<p>А в чём вопрос? <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Fri, 22 May 2020 14:04:01 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=139666#p139666</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как ускорить вычисление цвета]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=139665#p139665</link>
			<description><![CDATA[<p><a href="https://prnt.sc/slrunf">https://prnt.sc/slrunf</a> - это скрин результата за 20 замеров код под спойлером.<br />Первый клик 48ms.<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><div class="codebox"><pre><code>#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
;SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance, Force
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetBatchLines, -1
SendMode, Input

F1::

Loop,
{
	color := &quot;0xCE2636&quot;
	while(color == &quot;0xCE2636&quot;)
	{
		MouseGetPos, xm, ym
		PixelGetColor, color, xm, ym, Fast RGB
	}
	Send, {LButton}
}
return

F2::
ExitApp</code></pre></div></div></div><p><a href="https://prnt.sc/sls08i">https://prnt.sc/sls08i</a> - это скрин результата за 20 замеров код под спойлером.<br />Первый клик 16ms.<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><div class="codebox"><pre><code>#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
;SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance, Force
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetBatchLines, -1
SendMode, Input

F1::
MouseGetPos, xm, ym
Loop,
{
	color := &quot;0xCE2636&quot;
	while(color == &quot;0xCE2636&quot;)
	{
		PixelGetColor, color, xm, ym, Fast RGB
	}
	Send, {LButton}
}
return

F2::
ExitApp</code></pre></div></div></div><p>Разница в том что из цикла достал MouseGetPos.<br />Оба раза запускал после перезагрузки пк, в автозапуске пусто. Все закрыто, только 1 вкладка в хроме.</p><p>UPD:<br /><a href="https://prnt.sc/sls9s8">https://prnt.sc/sls9s8</a> - это скрин результата за 20 замеров но уже с настройкой монитора в 25 Гц, используя 2-ой вариант.<br />Первый клик 90ms.<br />Предыдущие разы монитор был в 59 Гц.</p>]]></description>
			<author><![CDATA[null@example.com (romzes96)]]></author>
			<pubDate>Fri, 22 May 2020 13:42:51 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=139665#p139665</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как ускорить вычисление цвета]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=139571#p139571</link>
			<description><![CDATA[<div class="codebox"><pre><code>js =
(
   if (!window._ahk_mobs_) {
      window._ahk_mobs_ = true;
      const event = new MouseEvent(&#039;mousedown&#039;, { bubbles: true });
      new MutationObserver(mutArr =&gt; {
         if (mutArr[0].target.classList.contains(&#039;view-go&#039;))
            mutArr[0].target.dispatchEvent(event);
      }).observe(document.querySelector(&#039;.view-splash&#039;), {
         attributes: true, 
         attributeFilter: [&#039;class&#039;]
      });
   };
)</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sat, 16 May 2020 12:41:30 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=139571#p139571</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как ускорить вычисление цвета]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=139570#p139570</link>
			<description><![CDATA[<p>Значит код страницы изменился. Смотрите, соответствуют ли названия классов элементов указанным в скрипте.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sat, 16 May 2020 12:28:55 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=139570#p139570</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как ускорить вычисление цвета]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=139568#p139568</link>
			<description><![CDATA[<p><strong>teadrinker</strong></p><p>Не знаю почему, но код перестал работать.</p>]]></description>
			<author><![CDATA[null@example.com (Murka)]]></author>
			<pubDate>Sat, 16 May 2020 11:23:10 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=139568#p139568</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как ускорить вычисление цвета]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=138712#p138712</link>
			<description><![CDATA[<p>AHK только загружает javascript на страницу. Немного подправил.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Mon, 30 Mar 2020 12:02:00 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=138712#p138712</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как ускорить вычисление цвета]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=138711#p138711</link>
			<description><![CDATA[<p><strong>teadrinker</strong></p><p>Всё отлично работает, только я не понимаю почему значка ahk нет.</p>]]></description>
			<author><![CDATA[null@example.com (Murka)]]></author>
			<pubDate>Mon, 30 Mar 2020 11:52:32 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=138711#p138711</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как ускорить вычисление цвета]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=138710#p138710</link>
			<description><![CDATA[<p>Если цель максимально увеличить скорость выполнения, то наверное стоит попробовать запускать код на разных броузерах, так как обработка JS у каждого разная.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Mon, 30 Mar 2020 11:44:54 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=138710#p138710</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как ускорить вычисление цвета]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=138709#p138709</link>
			<description><![CDATA[<p>Инжектить можно, но реализации JS могут отличаться немного, надо проверять, все ли объекты будут работать.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Mon, 30 Mar 2020 11:38:36 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=138709#p138709</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как ускорить вычисление цвета]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=138707#p138707</link>
			<description><![CDATA[<p>Кстати, броузер в принципе не важен.<br />Можно и в фаерфоксе через адресную строку js инжектить.<br /></p><div class="quotebox"><blockquote><p>Set up a Bookmark with the location: javascript:%s and set the keyword for that bookmark as: javascript<br />Now you can run Javascript from the address bar in the format: javascript alert(&#039;Hello World&#039;) which is very similar to the old javascript:alert(&#039;Hello World&#039;) method - it&#039;s just that the colon needs to be replaced by a space</p></blockquote></div>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Mon, 30 Mar 2020 11:31:56 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=138707#p138707</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как ускорить вычисление цвета]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=138704#p138704</link>
			<description><![CDATA[<p>Если задача автоматизировать клик, когда меняется цвет, можно так:<br /></p><div class="codebox"><pre><code>/*
для сайта
https://www.humanbenchmark.com/tests/reactiontime
*/
SetBatchLines, -1
js =
(
   if (!window._ahk_mobs_) {
      window._ahk_mobs_ = true;
      new MutationObserver(mutArr =&gt; {
         if (mutArr[0].target.classList[2] === &#039;view-go&#039;) {
            const event = new MouseEvent(&#039;mousedown&#039;, { bubbles: true });
            mutArr[0].target.dispatchEvent(event);
         }
      }).observe(document.querySelector(&#039;.reaction-time-test&#039;), {
         attributes: true, 
         attributeFilter: [&#039;class&#039;]
      });
   };
)
RunJsFromChromeAddressBar(js)

RunJsFromChromeAddressBar(js, exe := &quot;chrome.exe&quot;) {
   static WM_GETOBJECT := 0x3D
        , ROLE_SYSTEM_TEXT := 0x2A
        , STATE_SYSTEM_FOCUSABLE := 0x100000
        , SELFLAG_TAKEFOCUS := 0x1
        , AccAddrBar, window
   if !AccAddrBar {
      window := &quot;ahk_class Chrome_WidgetWin_1 ahk_exe &quot; . exe
      SendMessage, WM_GETOBJECT, 0, 1, Chrome_RenderWidgetHostHWND1, % window
      AccChrome := AccObjectFromWindow( WinExist(window) )
      AccAddrBar := SearchElement(AccChrome, {Role: ROLE_SYSTEM_TEXT, State: STATE_SYSTEM_FOCUSABLE})
   }
   AccAddrBar.accValue(0) := &quot;javascript:&quot; . js
   AccAddrBar.accSelect(SELFLAG_TAKEFOCUS, 0)
   ControlSend,, {Enter}, % window, Chrome Legacy Window
}

SearchElement(parentElement, params)
{
   found := true
   for k, v in params {
      try {
         if (k = &quot;ChildCount&quot;)
            (parentElement.accChildCount != v &amp;&amp; found := false)
         else if (k = &quot;State&quot;)
            (!(parentElement.accState(0) &amp; v) &amp;&amp; found := false)
         else
            (parentElement[&quot;acc&quot; . k](0) != v &amp;&amp; found := false)
      }
      catch 
         found := false
   } until !found
   if found
      Return parentElement
   
   for k, v in AccChildren(parentElement)
      if obj := SearchElement(v, params)
         Return obj
}

AccObjectFromWindow(hWnd, idObject = 0) {
   static IID_IDispatch   := &quot;{00020400-0000-0000-C000-000000000046}&quot;
        , IID_IAccessible := &quot;{618736E0-3C3D-11CF-810C-00AA00389B71}&quot;
        , OBJID_NATIVEOM  := 0xFFFFFFF0, VT_DISPATCH := 9, F_OWNVALUE := 1
        , h := DllCall(&quot;LoadLibrary&quot;, &quot;Str&quot;, &quot;oleacc&quot;, &quot;Ptr&quot;)
        
   VarSetCapacity(IID, 16), idObject &amp;= 0xFFFFFFFF
   DllCall(&quot;ole32\CLSIDFromString&quot;, &quot;Str&quot;, idObject = OBJID_NATIVEOM ? IID_IDispatch : IID_IAccessible, &quot;Ptr&quot;, &amp;IID)
   if DllCall(&quot;oleacc\AccessibleObjectFromWindow&quot;, &quot;Ptr&quot;, hWnd, &quot;UInt&quot;, idObject, &quot;Ptr&quot;, &amp;IID, &quot;PtrP&quot;, pAcc) = 0
      Return ComObject(VT_DISPATCH, pAcc, F_OWNVALUE)
}

AccChildren(Acc) {
   static VT_DISPATCH := 9
   Loop 1  {
      if ComObjType(Acc, &quot;Name&quot;) != &quot;IAccessible&quot;  {
         error := &quot;Invalid IAccessible Object&quot;
         break
      }
      try cChildren := Acc.accChildCount
      catch
         Return &quot;&quot;
      Children := []
      VarSetCapacity(varChildren, cChildren*(8 + A_PtrSize*2), 0)
      res := DllCall(&quot;oleacc\AccessibleChildren&quot;, &quot;Ptr&quot;, ComObjValue(Acc), &quot;Int&quot;, 0
                                                , &quot;Int&quot;, cChildren, &quot;Ptr&quot;, &amp;varChildren, &quot;IntP&quot;, cChildren)
      if (res != 0) {
         error := &quot;AccessibleChildren DllCall Failed&quot;
         break
      }
      Loop % cChildren  {
         i := (A_Index - 1)*(A_PtrSize*2 + 8)
         child := NumGet(varChildren, i + 8)
         Children.Push( (b := NumGet(varChildren, i) = VT_DISPATCH) ? AccQuery(child) : child )
         ( b &amp;&amp; ObjRelease(child) )
      }
   }
   if error
      ErrorLevel := error
   else
      Return Children.MaxIndex() ? Children : &quot;&quot;
}

AccQuery(Acc) {
   static IAccessible := &quot;{618736e0-3c3d-11cf-810c-00aa00389b71}&quot;, VT_DISPATCH := 9, F_OWNVALUE := 1
   try Return ComObject(VT_DISPATCH, ComObjQuery(Acc, IAccessible), F_OWNVALUE)
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Mon, 30 Mar 2020 11:14:22 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=138704#p138704</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как ускорить вычисление цвета]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=138702#p138702</link>
			<description><![CDATA[<p>Можно заинжектить JS скрипт, повесить нужное вам событие и посылать клик - наверняка будет быстрее.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Mon, 30 Mar 2020 10:49:49 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=138702#p138702</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как ускорить вычисление цвета]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=138699#p138699</link>
			<description><![CDATA[<p>Уверен, скрипт о мониторе ничего не знает.</p>]]></description>
			<author><![CDATA[null@example.com (ypppu)]]></author>
			<pubDate>Mon, 30 Mar 2020 09:25:44 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=138699#p138699</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как ускорить вычисление цвета]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=138698#p138698</link>
			<description><![CDATA[<p>Возможно, скорость реакции зависит от герцовки монитора.</p>]]></description>
			<author><![CDATA[null@example.com (Murka)]]></author>
			<pubDate>Mon, 30 Mar 2020 09:13:54 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=138698#p138698</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как ускорить вычисление цвета]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=138697#p138697</link>
			<description><![CDATA[<p><strong>teadrinker</strong></p><p>Google Chrome.</p>]]></description>
			<author><![CDATA[null@example.com (Murka)]]></author>
			<pubDate>Mon, 30 Mar 2020 09:09:14 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=138697#p138697</guid>
		</item>
	</channel>
</rss>
