<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Обновление определенной вкладки в браузере Mozilla.]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=16824&amp;type=atom" />
	<updated>2021-12-15T21:05:48Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=16824</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Обновление определенной вкладки в браузере Mozilla.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151211#p151211" />
			<content type="html"><![CDATA[<p><strong>Michael</strong></p><p>Если можно вкладку отделить как в хроме, можно так ещё попробовать:</p><div class="codebox"><pre><code>#SingleInstance Force
#NoEnv

Key = Перезагрузить	; Кнопку, что нужно нажать на странице.
Wait := 5000		; Время для таймера. 3600000 = 1 час (60*60*1000)
Return

F6:: Reload

F2::	; Обновление вкладки по таймеру (перейти на нужную отделить от основных, нажать клавишу).
If !(SW := !SW){
 SetTimer, F5, Off
 I=
 Tool(&quot;Обновление вкладки выключено:`n&quot; Title)
 Return
}
WinGetTitle, Title, A
ID := WinExist(&quot;A&quot;)
Tool(ID &quot;`t&quot; Title)
SetTimer, F5, % Wait

F5:
if B
 B.accDoDefaultAction(0)
Else
 B := Button(Key, Title)
; B := Button(Key, ID)
If (B = 1){
 SetTimer, F5, Off 
 SW := !SW
 Tool(&quot;Не удалось получить accessible-object.&quot;, 15000,0,0)
 Return
}
If (B = 2){
 SetTimer, F5, Off
 SW := !SW
 Tool(&quot;Ошибка! Такой клавиши нет!`n&quot; Key, 15000,0,0)
 Return
}
I++
Tool(&quot;Обновили: &quot; I, 2500,0,0)
Return

;-----------------------------------------
;[teadrinker] 12.12.2019	http://forum.script-coding.com/viewtopic.php?id=15091
Button(key_name, wind := &quot;A&quot;){
ListLines, Off
;SendMessage, WM_GETOBJECT := 0x003D, 0, 1, WinExist(wind)
If !accNow := AccObjectFromWindow(WinExist(wind))
 Return	1	; Не удалось получить accessible-object.
If !AccElem := SearchElement(accNow, {Role: ROLE_SYSTEM_PUSHBUTTON := 0x2B, Name: key_name})
 Return 2	; Кнопка не найдена.
AccElem.accDoDefaultAction(0)
Return AccElem 
}

;-------------------------------------------------------------------------------------------------------

SearchElement(parentElement, params){
 ListLines, Off
 found := true
 for k, v in params {
  Try (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){
 ListLines, Off
 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;, Str, &quot;oleacc&quot;, Ptr)
    
 VarSetCapacity(IID, 16), idObject &amp;= 0xFFFFFFFF
 DllCall(&quot;ole32\CLSIDFromString&quot;, Str, idObject = OBJID_NATIVEOM ? IID_IDispatch : IID_IAccessible, Ptr, &amp;IID)
 If DllCall(&quot;oleacc\AccessibleObjectFromWindow&quot;, Ptr, hWnd, UInt, idObject, Ptr, &amp;IID, PtrP, pAcc) = 0
  Return ComObject(VT_DISPATCH, pAcc, F_OWNVALUE)
}

AccChildren(Acc){
 ListLines, Off
 Static VT_DISPATCH := 9
 Loop 1{
  If ComObjType(Acc, &quot;Name&quot;) != &quot;IAccessible&quot;{
   Error := &quot;Invalid IAccessible Object&quot;
   Break
  }
  cChildren := Acc.accChildCount, 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){
 ListLines, Off
 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)
}


;-----------------------------------------
Tool(Text, Wait := 1000, X := &quot;&quot;, Y := &quot;&quot;){
 SetTimer, T_Off, Off
 ToolTip, % Text, %X%, %Y%
 SetTimer, T_Off, % Wait
 Return
}

~Esc::
T_Off:
SetTimer, T_Off, Off
ToolTip
Return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2021-12-15T21:05:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151211#p151211</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Обновление определенной вкладки в браузере Mozilla.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151209#p151209" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Код завершается, когда доходит до первого Return. Этого не происходит в следующих случаях:<br /></p><ul><li><p>Где-то в коде есть директива <em>#Persistent</em></p></li><li><p>В коде есть горячая клавиша</p></li><li><p>В коде есть GUI</p></li><li><p>В коде есть функция <em>OnMessage()</em></p></li></ul></blockquote></div><p>Большое спасибо! Получилось:<br /></p><div class="codebox"><pre><code>#Persistent
setTimer, Start, % 1 * 1 * 1 * 1800000

Start:
FF_ActivateTabByName(&quot;Мои сообщения&quot;)
Sleep, 200
Send, {F5}
return

FF_ActivateTabByName(tabName) {
   static ROLE_SYSTEM_PAGETAB     := 0x25
        , ROLE_SYSTEM_PAGETABLIST := 0x3C
   if !hFF := WinExist(&quot;ahk_class MozillaWindowClass&quot;)
      throw &quot;Firefox window not found&quot;
   if !AccFF := AccObjectFromWindow(hFF)
      throw &quot;Failed to get accessible object from FF&quot;
   if !AccTabList := SearchElement(AccFF, {Role: ROLE_SYSTEM_PAGETABLIST})
      throw &quot;Failed to get accessible object from tablist&quot;
   for k, v in AccChildren(AccTabList) {
      if (v.accRole(0) = ROLE_SYSTEM_PAGETAB &amp;&amp; v.accName(0) = tabName &amp;&amp; found := v)
         break
   }
   if !found
      throw &quot;Page not found&quot;
   WinActivate
   found.accDoDefaultAction(0)
}

SearchElement(parentElement, params)
{ ; params — object like {Role: ROLE_SYSTEM_PUSHBUTTON := 0x2B, Name: &quot;5&quot;}
   found := true
   for k, v in params {
      try {
         if (k = &quot;State&quot;)
            (!(parentElement.accState(0)    &amp; v) &amp;&amp; found := false)
         else if (k ~= &quot;^(Name|Value)$&quot;)
            (!(parentElement[&quot;acc&quot; . k](0) ~= v) &amp;&amp; found := false)
         else if (k = &quot;ChildCount&quot;)
            (parentElement[&quot;acc&quot; . k]      != 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, AccObject := 0
   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
      AccObject := ComObject(VT_DISPATCH, pAcc, F_OWNVALUE)
   Return AccObject
}

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
      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>]]></content>
			<author>
				<name><![CDATA[Michael]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41356</uri>
			</author>
			<updated>2021-12-15T20:44:32Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151209#p151209</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Обновление определенной вкладки в браузере Mozilla.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151208#p151208" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>Malcev<br />В двух словах: есть сайт, страница которого если будет просто открыта без активности - будет &quot;офлайн статус&quot; либо периодически даже разлогинивается.</p></blockquote></div><p>Можно посылать WinhttpRequest с нужными кукисами.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2021-12-15T19:36:08Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151208#p151208</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Обновление определенной вкладки в браузере Mozilla.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151207#p151207" />
			<content type="html"><![CDATA[<p>Код завершается, когда доходит до первого Return. Этого не происходит в следующих случаях:<br /></p><ul><li><p>Где-то в коде есть директива <em>#Persistent</em></p></li><li><p>В коде есть горячая клавиша</p></li><li><p>В коде есть GUI</p></li><li><p>В коде есть функция <em>OnMessage()</em></p></li></ul>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-12-15T18:49:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151207#p151207</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Обновление определенной вкладки в браузере Mozilla.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151206#p151206" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong><br />Выполняет код только единожды, а не каждую секунду. Но я вроде где-то на верном пути...)<br /></p><div class="codebox"><pre><code>setTimer, Start, % 1 * 1 * 1 * 1000

Start:
FF_ActivateTabByName(&quot;Мои сообщения&quot;)
Sleep, 200
Send, {F5}
return

FF_ActivateTabByName(tabName) {
   static ROLE_SYSTEM_PAGETAB     := 0x25
        , ROLE_SYSTEM_PAGETABLIST := 0x3C
   if !hFF := WinExist(&quot;ahk_class MozillaWindowClass&quot;)
      throw &quot;Firefox window not found&quot;
   if !AccFF := AccObjectFromWindow(hFF)
      throw &quot;Failed to get accessible object from FF&quot;
   if !AccTabList := SearchElement(AccFF, {Role: ROLE_SYSTEM_PAGETABLIST})
      throw &quot;Failed to get accessible object from tablist&quot;
   for k, v in AccChildren(AccTabList) {
      if (v.accRole(0) = ROLE_SYSTEM_PAGETAB &amp;&amp; v.accName(0) = tabName &amp;&amp; found := v)
         break
   }
   if !found
      throw &quot;Page not found&quot;
   WinActivate
   found.accDoDefaultAction(0)
}

SearchElement(parentElement, params)
{ ; params — object like {Role: ROLE_SYSTEM_PUSHBUTTON := 0x2B, Name: &quot;5&quot;}
   found := true
   for k, v in params {
      try {
         if (k = &quot;State&quot;)
            (!(parentElement.accState(0)    &amp; v) &amp;&amp; found := false)
         else if (k ~= &quot;^(Name|Value)$&quot;)
            (!(parentElement[&quot;acc&quot; . k](0) ~= v) &amp;&amp; found := false)
         else if (k = &quot;ChildCount&quot;)
            (parentElement[&quot;acc&quot; . k]      != 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, AccObject := 0
   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
      AccObject := ComObject(VT_DISPATCH, pAcc, F_OWNVALUE)
   Return AccObject
}

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
      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>]]></content>
			<author>
				<name><![CDATA[Michael]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41356</uri>
			</author>
			<updated>2021-12-15T18:42:19Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151206#p151206</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Обновление определенной вкладки в браузере Mozilla.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151205#p151205" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Michael пишет:</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-12-15T18:40:22Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151205#p151205</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Обновление определенной вкладки в браузере Mozilla.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151204#p151204" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Читайте про функции в справке.</p></blockquote></div><p>Получилось вот так (разворачивает окно браузера, открывает нужную вкладку и обновляет страницу при нажатии F8):<br /></p><div class="codebox"><pre><code>F8::
FF_ActivateTabByName(&quot;Мои сообщения&quot;)
Sleep, 200
Send, {F5}
return

FF_ActivateTabByName(tabName) {
   static ROLE_SYSTEM_PAGETAB     := 0x25
        , ROLE_SYSTEM_PAGETABLIST := 0x3C
   if !hFF := WinExist(&quot;ahk_class MozillaWindowClass&quot;)
      throw &quot;Firefox window not found&quot;
   if !AccFF := AccObjectFromWindow(hFF)
      throw &quot;Failed to get accessible object from FF&quot;
   if !AccTabList := SearchElement(AccFF, {Role: ROLE_SYSTEM_PAGETABLIST})
      throw &quot;Failed to get accessible object from tablist&quot;
   for k, v in AccChildren(AccTabList) {
      if (v.accRole(0) = ROLE_SYSTEM_PAGETAB &amp;&amp; v.accName(0) = tabName &amp;&amp; found := v)
         break
   }
   if !found
      throw &quot;Page not found&quot;
   WinActivate
   found.accDoDefaultAction(0)
}

SearchElement(parentElement, params)
{ ; params — object like {Role: ROLE_SYSTEM_PUSHBUTTON := 0x2B, Name: &quot;5&quot;}
   found := true
   for k, v in params {
      try {
         if (k = &quot;State&quot;)
            (!(parentElement.accState(0)    &amp; v) &amp;&amp; found := false)
         else if (k ~= &quot;^(Name|Value)$&quot;)
            (!(parentElement[&quot;acc&quot; . k](0) ~= v) &amp;&amp; found := false)
         else if (k = &quot;ChildCount&quot;)
            (parentElement[&quot;acc&quot; . k]      != 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, AccObject := 0
   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
      AccObject := ComObject(VT_DISPATCH, pAcc, F_OWNVALUE)
   Return AccObject
}

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
      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><p>Если не нужно запускать по таймеру, то как сделать вызов данной функции раз в час, допустим?</p><p><strong>Malcev</strong><br />В двух словах: есть сайт, страница которого если будет просто открыта без активности - будет &quot;офлайн статус&quot; либо периодически даже разлогинивается.<br />Самый просто способ (и рабочий, проверено), это прожимать просто обновление страницы, хотя бы раз в 30 или 60 минут. Вкладок у меня много, поэтому нужен поиск среди них.</p>]]></content>
			<author>
				<name><![CDATA[Michael]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41356</uri>
			</author>
			<updated>2021-12-15T18:31:35Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151204#p151204</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Обновление определенной вкладки в браузере Mozilla.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151198#p151198" />
			<content type="html"><![CDATA[<p><strong>Michael</strong>, а зачем вам вообще все это надо?</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2021-12-15T15:28:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151198#p151198</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Обновление определенной вкладки в браузере Mozilla.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151196#p151196" />
			<content type="html"><![CDATA[<p>Вам не нужно по таймеру запускать весь мой код целиком, вам нужно только вызывать функцию.<br /></p><div class="codebox"><pre><code>FF_ActivateTabByName(&quot;Мои сообщения&quot;)</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-12-15T14:55:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151196#p151196</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Обновление определенной вкладки в браузере Mozilla.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151195#p151195" />
			<content type="html"><![CDATA[<p>Потому что у меня вот такая &quot;хрень&quot; получилась:<br /></p><div class="codebox"><pre><code>setTimer, FF_ActivateTabByName, % 1 * 1 * 1 * 1000 ; hour * minutes * seconds * ms
return

F8::
FF_ActivateTabByName()
return

FF_ActivateTabByName()
{
FF_ActivateTabByName(&quot;Мои сообщения&quot;)

FF_ActivateTabByName(tabName) {
   static ROLE_SYSTEM_PAGETAB     := 0x25
        , ROLE_SYSTEM_PAGETABLIST := 0x3C
   if !hFF := WinExist(&quot;ahk_class MozillaWindowClass&quot;)
      throw &quot;Firefox window not found&quot;
   if !AccFF := AccObjectFromWindow(hFF)
      throw &quot;Failed to get accessible object from FF&quot;
   if !AccTabList := SearchElement(AccFF, {Role: ROLE_SYSTEM_PAGETABLIST})
      throw &quot;Failed to get accessible object from tablist&quot;
   for k, v in AccChildren(AccTabList) {
      if (v.accRole(0) = ROLE_SYSTEM_PAGETAB &amp;&amp; v.accName(0) = tabName &amp;&amp; found := v)
         break
   }
   if !found
      throw &quot;Page not found&quot;
   WinActivate
   found.accDoDefaultAction(0)
}

SearchElement(parentElement, params)
{ ; params — object like {Role: ROLE_SYSTEM_PUSHBUTTON := 0x2B, Name: &quot;5&quot;}
   found := true
   for k, v in params {
      try {
         if (k = &quot;State&quot;)
            (!(parentElement.accState(0)    &amp; v) &amp;&amp; found := false)
         else if (k ~= &quot;^(Name|Value)$&quot;)
            (!(parentElement[&quot;acc&quot; . k](0) ~= v) &amp;&amp; found := false)
         else if (k = &quot;ChildCount&quot;)
            (parentElement[&quot;acc&quot; . k]      != 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, AccObject := 0
   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
      AccObject := ComObject(VT_DISPATCH, pAcc, F_OWNVALUE)
   Return AccObject
}

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
      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)
}
Send, {F5}
}</code></pre></div><p>Выдает ошибку: <br /></p><div class="codebox"><pre><code>==&gt; Functions cannot contain functions.
     Specifically: FF_ActivateTabByName(tabName)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Michael]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41356</uri>
			</author>
			<updated>2021-12-15T14:36:33Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151195#p151195</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Обновление определенной вкладки в браузере Mozilla.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151193#p151193" />
			<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-12-15T14:26:06Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151193#p151193</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Обновление определенной вкладки в браузере Mozilla.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151191#p151191" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong><br />Да, переключает на нужную вкладку, но не могу сюда же прикрутить то, что изначально было нужно, посыл нажатия ф5, и таймер на час..</p>]]></content>
			<author>
				<name><![CDATA[Michael]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41356</uri>
			</author>
			<updated>2021-12-15T14:22:32Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151191#p151191</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Обновление определенной вкладки в браузере Mozilla.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151188#p151188" />
			<content type="html"><![CDATA[<p>Переключиться на вкладку в FF по заголовку можно так:<br /></p><div class="codebox"><pre><code>FF_ActivateTabByName(&quot;Мои сообщения&quot;)

FF_ActivateTabByName(tabName) {
   static ROLE_SYSTEM_PAGETAB     := 0x25
        , ROLE_SYSTEM_PAGETABLIST := 0x3C
   if !hFF := WinExist(&quot;ahk_class MozillaWindowClass&quot;)
      throw &quot;Firefox window not found&quot;
   if !AccFF := AccObjectFromWindow(hFF)
      throw &quot;Failed to get accessible object from FF&quot;
   if !AccTabList := SearchElement(AccFF, {Role: ROLE_SYSTEM_PAGETABLIST})
      throw &quot;Failed to get accessible object from tablist&quot;
   for k, v in AccChildren(AccTabList) {
      if (v.accRole(0) = ROLE_SYSTEM_PAGETAB &amp;&amp; v.accName(0) = tabName &amp;&amp; found := v)
         break
   }
   if !found
      throw &quot;Page not found&quot;
   WinActivate
   found.accDoDefaultAction(0)
}

SearchElement(parentElement, params)
{ ; params — object like {Role: ROLE_SYSTEM_PUSHBUTTON := 0x2B, Name: &quot;5&quot;}
   found := true
   for k, v in params {
      try {
         if (k = &quot;State&quot;)
            (!(parentElement.accState(0)    &amp; v) &amp;&amp; found := false)
         else if (k ~= &quot;^(Name|Value)$&quot;)
            (!(parentElement[&quot;acc&quot; . k](0) ~= v) &amp;&amp; found := false)
         else if (k = &quot;ChildCount&quot;)
            (parentElement[&quot;acc&quot; . k]      != 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, AccObject := 0
   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
      AccObject := ComObject(VT_DISPATCH, pAcc, F_OWNVALUE)
   Return AccObject
}

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
      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>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-12-15T11:03:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151188#p151188</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Обновление определенной вкладки в браузере Mozilla.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151187#p151187" />
			<content type="html"><![CDATA[<p>Selenium или webdriver.<br />Все это уже перенесено на автохотки.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2021-12-15T08:28:08Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151187#p151187</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Обновление определенной вкладки в браузере Mozilla.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151185#p151185" />
			<content type="html"><![CDATA[<p><strong>Phoenixxx_Czar</strong><br />Первый раз находит и обновляет нужную страницу - далее обновляет рандомные страницы в браузере, не пойму почему <img src="//forum.script-coding.com/img/smilies/sad.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[Michael]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41356</uri>
			</author>
			<updated>2021-12-14T23:00:36Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151185#p151185</id>
		</entry>
</feed>
