<?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="https://forum.script-coding.com/extern.php?action=feed&amp;tid=16517&amp;type=atom" />
	<updated>2021-08-07T12:37:31Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=16517</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Перемещение ярлыков на панели задач]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149199#p149199" />
			<content type="html"><![CDATA[<p>Он должен переносить.<br />Но если есть закрепленные окна, то он будет перемещать после них.<br />Если надо, чтоб перед ними, то можно сделать проще, посмотреть координаты кнопки нажатой вкладки и переместить с помощью MouseClickDrag.<br />Кстати, мой код не работает с uwp окнами, так как ITaskbarList api они не поддерживают.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2021-08-07T12:37:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149199#p149199</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Перемещение ярлыков на панели задач]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149198#p149198" />
			<content type="html"><![CDATA[<p><strong>Malcev</strong><br />Ваш пример неплох, однако он не перемещает в самый левый край. Так и должно быть?</p>]]></content>
			<author>
				<name><![CDATA[Clannad5]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39853</uri>
			</author>
			<updated>2021-08-07T09:39:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149198#p149198</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Перемещение ярлыков на панели задач]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149194#p149194" />
			<content type="html"><![CDATA[<p>А вот так должен перемещать вкладку активного окна влево:<br /></p><div class="codebox"><pre><code>setbatchlines -1
tbl := ComObjCreate(CLSID_TaskbarList := &quot;{56FDF344-FD6D-11d0-958A-006097C9A090}&quot;, IID_ITaskbarList := &quot;{56FDF342-FD6D-11d0-958A-006097C9A090}&quot;)
DllCall(NumGet(NumGet(tbl+0)+3*A_PtrSize), &quot;ptr&quot;, tbl)   ; ITaskbarList::HrInit
WinGet, hShell_TrayWnd, id, ahk_class Shell_TrayWnd
ControlGet, hTaskbar, hwnd,, MSTaskListWClass1, ahk_id %hShell_TrayWnd%
oAcc := Acc_Get(&quot;Object&quot;, 4, 0, &quot;ahk_id&quot; hTaskbar)

f11::
oAccArray := [], oTaskbar := {}, pressedCurrent := &quot;&quot;
loop % oAcc.accChildCount
{
   if (oAcc.accState(A_Index) != 0) and !(oAcc.accState(A_Index) &amp; 0x00008000)   ; visible
   {
      oAccArray.Push(A_Index)
      if (oAcc.accState(A_Index) &amp; 0x00000008)   ; pressed
         pressedCurrent := A_Index
   }
}
hWindows := GetAltTabWindows()
for k, v in hWindows
{
   owner := v
   loop
   {
      owner := DllCall(&quot;GetWindow&quot;, &quot;ptr&quot;, owner, &quot;uint&quot;, GW_OWNER := 4)
      if (owner != 0)
      {
         if DllCall(&quot;IsWindowVisible&quot;, &quot;ptr&quot;, owner)
            v := owner
      }
      else
         break
   }
   DllCall(NumGet(NumGet(tbl+0)+6*A_PtrSize), &quot;ptr&quot;, tbl, &quot;ptr&quot;, v)   ; ITaskbarList::ActivateTab
   for k1, v1 in oAccArray
   {
      if (oAcc.accState(v1) &amp; 0x00000008)   ; pressed
      {
         if (v1 = pressedCurrent)
            oTaskbar[0] := v
         else
            oTaskbar[v1] := v
         oAccArray.Delete(k1)
         break
      }
   }
}
if (oAccArray.Count() != 0)
{
   msgbox smth goes wrong
   return
}
for k, v in oTaskbar
   DllCall(NumGet(NumGet(tbl+0)+5*A_PtrSize), &quot;ptr&quot;, tbl, &quot;ptr&quot;, v)   ; ITaskbarList::DeleteTab
sleep 10
for k, v in oTaskbar
   DllCall(NumGet(NumGet(tbl+0)+4*A_PtrSize), &quot;ptr&quot;, tbl, &quot;ptr&quot;, v)   ; ITaskbarList::AddTab
return


GetAltTabWindows() {
   AltTabList := []
   WinGet, list, List
   Loop % list
      if IsAltTabWindow(list%A_Index%)
         AltTabList.Push(list%A_Index%)
   Return AltTabList
}

IsAltTabWindow(hWnd) {
   static GA_ROOTOWNER := 3, WS_EX_APPWINDOW := 0x40000, WS_EX_TOOLWINDOW := 0x80, DWMWA_CLOAKED := 14
   if !DllCall(&quot;IsWindowVisible&quot;, &quot;Ptr&quot;, hWnd)
      Return false
   
   hOwner := DllCall(&quot;GetAncestor&quot;, &quot;Ptr&quot;, hWnd, &quot;UInt&quot;, GA_ROOTOWNER, &quot;Ptr&quot;)
   hPopup := DllCall(&quot;GetLastActivePopup&quot;, &quot;Ptr&quot;, hOwner, &quot;Ptr&quot;)
   if (hOwner = hWnd &amp;&amp; hPopup != hWnd)
      Return false
   
   WinGet, exStyles, ExStyle, ahk_id %hWnd%
   if (exStyles &amp; WS_EX_TOOLWINDOW) &amp;&amp; !(exStyles &amp; WS_EX_APPWINDOW)
      Return false
      
   DllCall(&quot;DwmApi\DwmGetWindowAttribute&quot;, &quot;Ptr&quot;, hWnd, &quot;UInt&quot;, DWMWA_CLOAKED, &quot;UIntP&quot;, cloaked, &quot;UInt&quot;, 4)
   Return !cloaked
}


; http://www.autohotkey.com/board/topic/77303-acc-library-ahk-l-updated-09272012/
; https://dl.dropbox.com/u/47573473/Web%20Server/AHK_L/Acc.ahk
;------------------------------------------------------------------------------
; Acc.ahk Standard Library
; by Sean
; Updated by jethrow:
; 	Modified ComObjEnwrap params from (9,pacc) --&gt; (9,pacc,1)
; 	Changed ComObjUnwrap to ComObjValue in order to avoid AddRef (thanks fincs)
; 	Added Acc_GetRoleText &amp; Acc_GetStateText
; 	Added additional functions - commented below
; 	Removed original Acc_Children function
; last updated 2/25/2010
;------------------------------------------------------------------------------

Acc_Init()
{
	Static	h
	If Not	h
		h:=DllCall(&quot;LoadLibrary&quot;,&quot;Str&quot;,&quot;oleacc&quot;,&quot;Ptr&quot;)
}
Acc_ObjectFromEvent(ByRef _idChild_, hWnd, idObject, idChild)
{
	Acc_Init()
	If	DllCall(&quot;oleacc\AccessibleObjectFromEvent&quot;, &quot;Ptr&quot;, hWnd, &quot;UInt&quot;, idObject, &quot;UInt&quot;, idChild, &quot;Ptr*&quot;, pacc, &quot;Ptr&quot;, VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&amp;varChild)=0
	Return	ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,&quot;UInt&quot;)
}

Acc_ObjectFromPoint(ByRef _idChild_ = &quot;&quot;, x = &quot;&quot;, y = &quot;&quot;)
{
	Acc_Init()
	If	DllCall(&quot;oleacc\AccessibleObjectFromPoint&quot;, &quot;Int64&quot;, x==&quot;&quot;||y==&quot;&quot;?0*DllCall(&quot;GetCursorPos&quot;,&quot;Int64*&quot;,pt)+pt:x&amp;0xFFFFFFFF|y&lt;&lt;32, &quot;Ptr*&quot;, pacc, &quot;Ptr&quot;, VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&amp;varChild)=0
	Return	ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,&quot;UInt&quot;)
}

Acc_ObjectFromWindow(hWnd, idObject = -4)
{
	Acc_Init()
	If	DllCall(&quot;oleacc\AccessibleObjectFromWindow&quot;, &quot;Ptr&quot;, hWnd, &quot;UInt&quot;, idObject&amp;=0xFFFFFFFF, &quot;Ptr&quot;, -VarSetCapacity(IID,16)+NumPut(idObject==0xFFFFFFF0?0x46000000000000C0:0x719B3800AA000C81,NumPut(idObject==0xFFFFFFF0?0x0000000000020400:0x11CF3C3D618736E0,IID,&quot;Int64&quot;),&quot;Int64&quot;), &quot;Ptr*&quot;, pacc)=0
	Return	ComObjEnwrap(9,pacc,1)
}

Acc_WindowFromObject(pacc)
{
	If	DllCall(&quot;oleacc\WindowFromAccessibleObject&quot;, &quot;Ptr&quot;, IsObject(pacc)?ComObjValue(pacc):pacc, &quot;Ptr*&quot;, hWnd)=0
	Return	hWnd
}

Acc_GetRoleText(nRole)
{
	nSize := DllCall(&quot;oleacc\GetRoleText&quot;, &quot;Uint&quot;, nRole, &quot;Ptr&quot;, 0, &quot;Uint&quot;, 0)
	VarSetCapacity(sRole, (A_IsUnicode?2:1)*nSize)
	DllCall(&quot;oleacc\GetRoleText&quot;, &quot;Uint&quot;, nRole, &quot;str&quot;, sRole, &quot;Uint&quot;, nSize+1)
	Return	sRole
}

Acc_GetStateText(nState)
{
	nSize := DllCall(&quot;oleacc\GetStateText&quot;, &quot;Uint&quot;, nState, &quot;Ptr&quot;, 0, &quot;Uint&quot;, 0)
	VarSetCapacity(sState, (A_IsUnicode?2:1)*nSize)
	DllCall(&quot;oleacc\GetStateText&quot;, &quot;Uint&quot;, nState, &quot;str&quot;, sState, &quot;Uint&quot;, nSize+1)
	Return	sState
}

Acc_SetWinEventHook(eventMin, eventMax, pCallback)
{
	Return	DllCall(&quot;SetWinEventHook&quot;, &quot;Uint&quot;, eventMin, &quot;Uint&quot;, eventMax, &quot;Uint&quot;, 0, &quot;Ptr&quot;, pCallback, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0)
}

Acc_UnhookWinEvent(hHook)
{
	Return	DllCall(&quot;UnhookWinEvent&quot;, &quot;Ptr&quot;, hHook)
}
/*	Win Events:
	pCallback := RegisterCallback(&quot;WinEventProc&quot;)
	WinEventProc(hHook, event, hWnd, idObject, idChild, eventThread, eventTime)
	{
		Critical
		Acc := Acc_ObjectFromEvent(_idChild_, hWnd, idObject, idChild)
		; Code Here:
	}
*/

; Written by jethrow
Acc_Role(Acc, ChildId=0) {
	try return ComObjType(Acc,&quot;Name&quot;)=&quot;IAccessible&quot;?Acc_GetRoleText(Acc.accRole(ChildId)):&quot;invalid object&quot;
}
Acc_State(Acc, ChildId=0) {
	try return ComObjType(Acc,&quot;Name&quot;)=&quot;IAccessible&quot;?Acc_GetStateText(Acc.accState(ChildId)):&quot;invalid object&quot;
}
Acc_Location(Acc, ChildId=0, byref Position=&quot;&quot;) { ; adapted from Sean&#039;s code
	try Acc.accLocation(ComObj(0x4003,&amp;x:=0), ComObj(0x4003,&amp;y:=0), ComObj(0x4003,&amp;w:=0), ComObj(0x4003,&amp;h:=0), ChildId)
	catch
		return
	Position := &quot;x&quot; NumGet(x,0,&quot;int&quot;) &quot; y&quot; NumGet(y,0,&quot;int&quot;) &quot; w&quot; NumGet(w,0,&quot;int&quot;) &quot; h&quot; NumGet(h,0,&quot;int&quot;)
	return	{x:NumGet(x,0,&quot;int&quot;), y:NumGet(y,0,&quot;int&quot;), w:NumGet(w,0,&quot;int&quot;), h:NumGet(h,0,&quot;int&quot;)}
}
Acc_Parent(Acc) { 
	try parent:=Acc.accParent
	return parent?Acc_Query(parent):
}
Acc_Child(Acc, ChildId=0) {
	try child:=Acc.accChild(ChildId)
	return child?Acc_Query(child):
}
Acc_Query(Acc) { ; thanks Lexikos - www.autohotkey.com/forum/viewtopic.php?t=81731&amp;p=509530#509530
	try return ComObj(9, ComObjQuery(Acc,&quot;{618736e0-3c3d-11cf-810c-00aa00389b71}&quot;), 1)
}
Acc_Error(p=&quot;&quot;) {
	static setting:=0
	return p=&quot;&quot;?setting:setting:=p
}
Acc_Children(Acc) {
	if ComObjType(Acc,&quot;Name&quot;) != &quot;IAccessible&quot;
		ErrorLevel := &quot;Invalid IAccessible Object&quot;
	else {
		Acc_Init(), cChildren:=Acc.accChildCount, Children:=[]
		if DllCall(&quot;oleacc\AccessibleChildren&quot;, &quot;Ptr&quot;,ComObjValue(Acc), &quot;Int&quot;,0, &quot;Int&quot;,cChildren, &quot;Ptr&quot;,VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&amp;varChildren, &quot;Int*&quot;,cChildren)=0 {
			Loop %cChildren%
				i:=(A_Index-1)*(A_PtrSize*2+8)+8, child:=NumGet(varChildren,i), Children.Insert(NumGet(varChildren,i-8)=9?Acc_Query(child):child), NumGet(varChildren,i-8)=9?ObjRelease(child):
			return Children.MaxIndex()?Children:
		} else
			ErrorLevel := &quot;AccessibleChildren DllCall Failed&quot;
	}
	if Acc_Error()
		throw Exception(ErrorLevel,-1)
}
Acc_ChildrenByRole(Acc, Role) {
	if ComObjType(Acc,&quot;Name&quot;)!=&quot;IAccessible&quot;
		ErrorLevel := &quot;Invalid IAccessible Object&quot;
	else {
		Acc_Init(), cChildren:=Acc.accChildCount, Children:=[]
		if DllCall(&quot;oleacc\AccessibleChildren&quot;, &quot;Ptr&quot;,ComObjValue(Acc), &quot;Int&quot;,0, &quot;Int&quot;,cChildren, &quot;Ptr&quot;,VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&amp;varChildren, &quot;Int*&quot;,cChildren)=0 {
			Loop %cChildren% {
				i:=(A_Index-1)*(A_PtrSize*2+8)+8, child:=NumGet(varChildren,i)
				if NumGet(varChildren,i-8)=9
					AccChild:=Acc_Query(child), ObjRelease(child), Acc_Role(AccChild)=Role?Children.Insert(AccChild):
				else
					Acc_Role(Acc, child)=Role?Children.Insert(child):
			}
			return Children.MaxIndex()?Children:, ErrorLevel:=0
		} else
			ErrorLevel := &quot;AccessibleChildren DllCall Failed&quot;
	}
	if Acc_Error()
		throw Exception(ErrorLevel,-1)
}
Acc_Get(Cmd, ChildPath=&quot;&quot;, ChildID=0, WinTitle=&quot;&quot;, WinText=&quot;&quot;, ExcludeTitle=&quot;&quot;, ExcludeText=&quot;&quot;) {
	static properties := {Action:&quot;DefaultAction&quot;, DoAction:&quot;DoDefaultAction&quot;, Keyboard:&quot;KeyboardShortcut&quot;}
	AccObj :=   IsObject(WinTitle)? WinTitle
			:   Acc_ObjectFromWindow( WinExist(WinTitle, WinText, ExcludeTitle, ExcludeText), 0 )
	if ComObjType(AccObj, &quot;Name&quot;) != &quot;IAccessible&quot;
		ErrorLevel := &quot;Could not access an IAccessible Object&quot;
	else {
		StringReplace, ChildPath, ChildPath, _, %A_Space%, All
		AccError:=Acc_Error(), Acc_Error(true)
		Loop Parse, ChildPath, ., %A_Space%
			try {
				if A_LoopField is digit
					Children:=Acc_Children(AccObj), m2:=A_LoopField ; mimic &quot;m2&quot; output in else-statement
				else
					RegExMatch(A_LoopField, &quot;(\D*)(\d*)&quot;, m), Children:=Acc_ChildrenByRole(AccObj, m1), m2:=(m2?m2:1)
				if Not Children.HasKey(m2)
					throw
				AccObj := Children[m2]
			} catch {
				ErrorLevel:=&quot;Cannot access ChildPath Item #&quot; A_Index &quot; -&gt; &quot; A_LoopField, Acc_Error(AccError)
				if Acc_Error()
					throw Exception(&quot;Cannot access ChildPath Item&quot;, -1, &quot;Item #&quot; A_Index &quot; -&gt; &quot; A_LoopField)
				return
			}
		Acc_Error(AccError)
		StringReplace, Cmd, Cmd, %A_Space%, , All
		properties.HasKey(Cmd)? Cmd:=properties[Cmd]:
		try {
			if (Cmd = &quot;Location&quot;)
				AccObj.accLocation(ComObj(0x4003,&amp;x:=0), ComObj(0x4003,&amp;y:=0), ComObj(0x4003,&amp;w:=0), ComObj(0x4003,&amp;h:=0), ChildId)
			  , ret_val := &quot;x&quot; NumGet(x,0,&quot;int&quot;) &quot; y&quot; NumGet(y,0,&quot;int&quot;) &quot; w&quot; NumGet(w,0,&quot;int&quot;) &quot; h&quot; NumGet(h,0,&quot;int&quot;)
			else if (Cmd = &quot;Object&quot;)
				ret_val := AccObj
			else if Cmd in Role,State
				ret_val := Acc_%Cmd%(AccObj, ChildID+0)
			else if Cmd in ChildCount,Selection,Focus
				ret_val := AccObj[&quot;acc&quot; Cmd]
			else
				ret_val := AccObj[&quot;acc&quot; Cmd](ChildID+0)
		} catch {
			ErrorLevel := &quot;&quot;&quot;&quot; Cmd &quot;&quot;&quot; Cmd Not Implemented&quot;
			if Acc_Error()
				throw Exception(&quot;Cmd Not Implemented&quot;, -1, Cmd)
			return
		}
		return ret_val, ErrorLevel:=0
	}
	if Acc_Error()
		throw Exception(ErrorLevel,-1)
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2021-08-06T20:46:56Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149194#p149194</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Перемещение ярлыков на панели задач]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149193#p149193" />
			<content type="html"><![CDATA[<p>Вот например:<br /></p><div class="codebox"><pre><code>setbatchlines -1
tbl := ComObjCreate(CLSID_TaskbarList := &quot;{56FDF344-FD6D-11d0-958A-006097C9A090}&quot;, IID_ITaskbarList := &quot;{56FDF342-FD6D-11d0-958A-006097C9A090}&quot;)
DllCall(NumGet(NumGet(tbl+0)+3*A_PtrSize), &quot;ptr&quot;, tbl)   ; ITaskbarList::HrInit
WinGet, hShell_TrayWnd, id, ahk_class Shell_TrayWnd
ControlGet, hTaskbar, hwnd,, MSTaskListWClass1, ahk_id %hShell_TrayWnd%
oAcc := Acc_Get(&quot;Object&quot;, 4, 0, &quot;ahk_id&quot; hTaskbar)

f11::
oAccArray := [], oTaskbar := {}
loop % oAcc.accChildCount
{
   if (oAcc.accState(A_Index) != 0) and !(oAcc.accState(A_Index) &amp; 0x00008000)   ; visible
      oAccArray.Push(A_Index)
}
hWindows := GetAltTabWindows()
for k, v in hWindows
{
   DllCall(NumGet(NumGet(tbl+0)+6*A_PtrSize), &quot;ptr&quot;, tbl, &quot;ptr&quot;, v)   ; ITaskbarList::ActivateTab
   for k1, v1 in oAccArray
   {
      if (oAcc.accState(v1) &amp; 0x00000008)   ; pressed
      {
         oTaskbar[v1] := v
         oAccArray.Delete(k1)
         break
      }
   }
}
if (oAccArray.Count() != 0)
{
   msgbox smth goes wrong
   return
}
for k, v in oTaskbar
{
   DllCall(NumGet(NumGet(tbl+0)+5*A_PtrSize), &quot;ptr&quot;, tbl, &quot;ptr&quot;, v)   ; ITaskbarList::DeleteTab
   sleep 1000
}
for k, v in oTaskbar
{
   DllCall(NumGet(NumGet(tbl+0)+4*A_PtrSize), &quot;ptr&quot;, tbl, &quot;ptr&quot;, v)   ; ITaskbarList::AddTab
   sleep 1000
}
return


GetAltTabWindows() {
   AltTabList := []
   WinGet, list, List
   Loop % list
      if IsAltTabWindow(list%A_Index%)
         AltTabList.Push(list%A_Index%)
   Return AltTabList
}

IsAltTabWindow(hWnd) {
   static GA_ROOTOWNER := 3, WS_EX_APPWINDOW := 0x40000, WS_EX_TOOLWINDOW := 0x80, DWMWA_CLOAKED := 14
   if !DllCall(&quot;IsWindowVisible&quot;, &quot;Ptr&quot;, hWnd)
      Return false
   
   hOwner := DllCall(&quot;GetAncestor&quot;, &quot;Ptr&quot;, hWnd, &quot;UInt&quot;, GA_ROOTOWNER, &quot;Ptr&quot;)
   hPopup := DllCall(&quot;GetLastActivePopup&quot;, &quot;Ptr&quot;, hOwner, &quot;Ptr&quot;)
   if (hOwner = hWnd &amp;&amp; hPopup != hWnd)
      Return false
   
   WinGet, exStyles, ExStyle, ahk_id %hWnd%
   if (exStyles &amp; WS_EX_TOOLWINDOW) &amp;&amp; !(exStyles &amp; WS_EX_APPWINDOW)
      Return false
      
   DllCall(&quot;DwmApi\DwmGetWindowAttribute&quot;, &quot;Ptr&quot;, hWnd, &quot;UInt&quot;, DWMWA_CLOAKED, &quot;UIntP&quot;, cloaked, &quot;UInt&quot;, 4)
   Return !cloaked
}


; http://www.autohotkey.com/board/topic/77303-acc-library-ahk-l-updated-09272012/
; https://dl.dropbox.com/u/47573473/Web%20Server/AHK_L/Acc.ahk
;------------------------------------------------------------------------------
; Acc.ahk Standard Library
; by Sean
; Updated by jethrow:
; 	Modified ComObjEnwrap params from (9,pacc) --&gt; (9,pacc,1)
; 	Changed ComObjUnwrap to ComObjValue in order to avoid AddRef (thanks fincs)
; 	Added Acc_GetRoleText &amp; Acc_GetStateText
; 	Added additional functions - commented below
; 	Removed original Acc_Children function
; last updated 2/25/2010
;------------------------------------------------------------------------------

Acc_Init()
{
	Static	h
	If Not	h
		h:=DllCall(&quot;LoadLibrary&quot;,&quot;Str&quot;,&quot;oleacc&quot;,&quot;Ptr&quot;)
}
Acc_ObjectFromEvent(ByRef _idChild_, hWnd, idObject, idChild)
{
	Acc_Init()
	If	DllCall(&quot;oleacc\AccessibleObjectFromEvent&quot;, &quot;Ptr&quot;, hWnd, &quot;UInt&quot;, idObject, &quot;UInt&quot;, idChild, &quot;Ptr*&quot;, pacc, &quot;Ptr&quot;, VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&amp;varChild)=0
	Return	ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,&quot;UInt&quot;)
}

Acc_ObjectFromPoint(ByRef _idChild_ = &quot;&quot;, x = &quot;&quot;, y = &quot;&quot;)
{
	Acc_Init()
	If	DllCall(&quot;oleacc\AccessibleObjectFromPoint&quot;, &quot;Int64&quot;, x==&quot;&quot;||y==&quot;&quot;?0*DllCall(&quot;GetCursorPos&quot;,&quot;Int64*&quot;,pt)+pt:x&amp;0xFFFFFFFF|y&lt;&lt;32, &quot;Ptr*&quot;, pacc, &quot;Ptr&quot;, VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&amp;varChild)=0
	Return	ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,&quot;UInt&quot;)
}

Acc_ObjectFromWindow(hWnd, idObject = -4)
{
	Acc_Init()
	If	DllCall(&quot;oleacc\AccessibleObjectFromWindow&quot;, &quot;Ptr&quot;, hWnd, &quot;UInt&quot;, idObject&amp;=0xFFFFFFFF, &quot;Ptr&quot;, -VarSetCapacity(IID,16)+NumPut(idObject==0xFFFFFFF0?0x46000000000000C0:0x719B3800AA000C81,NumPut(idObject==0xFFFFFFF0?0x0000000000020400:0x11CF3C3D618736E0,IID,&quot;Int64&quot;),&quot;Int64&quot;), &quot;Ptr*&quot;, pacc)=0
	Return	ComObjEnwrap(9,pacc,1)
}

Acc_WindowFromObject(pacc)
{
	If	DllCall(&quot;oleacc\WindowFromAccessibleObject&quot;, &quot;Ptr&quot;, IsObject(pacc)?ComObjValue(pacc):pacc, &quot;Ptr*&quot;, hWnd)=0
	Return	hWnd
}

Acc_GetRoleText(nRole)
{
	nSize := DllCall(&quot;oleacc\GetRoleText&quot;, &quot;Uint&quot;, nRole, &quot;Ptr&quot;, 0, &quot;Uint&quot;, 0)
	VarSetCapacity(sRole, (A_IsUnicode?2:1)*nSize)
	DllCall(&quot;oleacc\GetRoleText&quot;, &quot;Uint&quot;, nRole, &quot;str&quot;, sRole, &quot;Uint&quot;, nSize+1)
	Return	sRole
}

Acc_GetStateText(nState)
{
	nSize := DllCall(&quot;oleacc\GetStateText&quot;, &quot;Uint&quot;, nState, &quot;Ptr&quot;, 0, &quot;Uint&quot;, 0)
	VarSetCapacity(sState, (A_IsUnicode?2:1)*nSize)
	DllCall(&quot;oleacc\GetStateText&quot;, &quot;Uint&quot;, nState, &quot;str&quot;, sState, &quot;Uint&quot;, nSize+1)
	Return	sState
}

Acc_SetWinEventHook(eventMin, eventMax, pCallback)
{
	Return	DllCall(&quot;SetWinEventHook&quot;, &quot;Uint&quot;, eventMin, &quot;Uint&quot;, eventMax, &quot;Uint&quot;, 0, &quot;Ptr&quot;, pCallback, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0)
}

Acc_UnhookWinEvent(hHook)
{
	Return	DllCall(&quot;UnhookWinEvent&quot;, &quot;Ptr&quot;, hHook)
}
/*	Win Events:
	pCallback := RegisterCallback(&quot;WinEventProc&quot;)
	WinEventProc(hHook, event, hWnd, idObject, idChild, eventThread, eventTime)
	{
		Critical
		Acc := Acc_ObjectFromEvent(_idChild_, hWnd, idObject, idChild)
		; Code Here:
	}
*/

; Written by jethrow
Acc_Role(Acc, ChildId=0) {
	try return ComObjType(Acc,&quot;Name&quot;)=&quot;IAccessible&quot;?Acc_GetRoleText(Acc.accRole(ChildId)):&quot;invalid object&quot;
}
Acc_State(Acc, ChildId=0) {
	try return ComObjType(Acc,&quot;Name&quot;)=&quot;IAccessible&quot;?Acc_GetStateText(Acc.accState(ChildId)):&quot;invalid object&quot;
}
Acc_Location(Acc, ChildId=0, byref Position=&quot;&quot;) { ; adapted from Sean&#039;s code
	try Acc.accLocation(ComObj(0x4003,&amp;x:=0), ComObj(0x4003,&amp;y:=0), ComObj(0x4003,&amp;w:=0), ComObj(0x4003,&amp;h:=0), ChildId)
	catch
		return
	Position := &quot;x&quot; NumGet(x,0,&quot;int&quot;) &quot; y&quot; NumGet(y,0,&quot;int&quot;) &quot; w&quot; NumGet(w,0,&quot;int&quot;) &quot; h&quot; NumGet(h,0,&quot;int&quot;)
	return	{x:NumGet(x,0,&quot;int&quot;), y:NumGet(y,0,&quot;int&quot;), w:NumGet(w,0,&quot;int&quot;), h:NumGet(h,0,&quot;int&quot;)}
}
Acc_Parent(Acc) { 
	try parent:=Acc.accParent
	return parent?Acc_Query(parent):
}
Acc_Child(Acc, ChildId=0) {
	try child:=Acc.accChild(ChildId)
	return child?Acc_Query(child):
}
Acc_Query(Acc) { ; thanks Lexikos - www.autohotkey.com/forum/viewtopic.php?t=81731&amp;p=509530#509530
	try return ComObj(9, ComObjQuery(Acc,&quot;{618736e0-3c3d-11cf-810c-00aa00389b71}&quot;), 1)
}
Acc_Error(p=&quot;&quot;) {
	static setting:=0
	return p=&quot;&quot;?setting:setting:=p
}
Acc_Children(Acc) {
	if ComObjType(Acc,&quot;Name&quot;) != &quot;IAccessible&quot;
		ErrorLevel := &quot;Invalid IAccessible Object&quot;
	else {
		Acc_Init(), cChildren:=Acc.accChildCount, Children:=[]
		if DllCall(&quot;oleacc\AccessibleChildren&quot;, &quot;Ptr&quot;,ComObjValue(Acc), &quot;Int&quot;,0, &quot;Int&quot;,cChildren, &quot;Ptr&quot;,VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&amp;varChildren, &quot;Int*&quot;,cChildren)=0 {
			Loop %cChildren%
				i:=(A_Index-1)*(A_PtrSize*2+8)+8, child:=NumGet(varChildren,i), Children.Insert(NumGet(varChildren,i-8)=9?Acc_Query(child):child), NumGet(varChildren,i-8)=9?ObjRelease(child):
			return Children.MaxIndex()?Children:
		} else
			ErrorLevel := &quot;AccessibleChildren DllCall Failed&quot;
	}
	if Acc_Error()
		throw Exception(ErrorLevel,-1)
}
Acc_ChildrenByRole(Acc, Role) {
	if ComObjType(Acc,&quot;Name&quot;)!=&quot;IAccessible&quot;
		ErrorLevel := &quot;Invalid IAccessible Object&quot;
	else {
		Acc_Init(), cChildren:=Acc.accChildCount, Children:=[]
		if DllCall(&quot;oleacc\AccessibleChildren&quot;, &quot;Ptr&quot;,ComObjValue(Acc), &quot;Int&quot;,0, &quot;Int&quot;,cChildren, &quot;Ptr&quot;,VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&amp;varChildren, &quot;Int*&quot;,cChildren)=0 {
			Loop %cChildren% {
				i:=(A_Index-1)*(A_PtrSize*2+8)+8, child:=NumGet(varChildren,i)
				if NumGet(varChildren,i-8)=9
					AccChild:=Acc_Query(child), ObjRelease(child), Acc_Role(AccChild)=Role?Children.Insert(AccChild):
				else
					Acc_Role(Acc, child)=Role?Children.Insert(child):
			}
			return Children.MaxIndex()?Children:, ErrorLevel:=0
		} else
			ErrorLevel := &quot;AccessibleChildren DllCall Failed&quot;
	}
	if Acc_Error()
		throw Exception(ErrorLevel,-1)
}
Acc_Get(Cmd, ChildPath=&quot;&quot;, ChildID=0, WinTitle=&quot;&quot;, WinText=&quot;&quot;, ExcludeTitle=&quot;&quot;, ExcludeText=&quot;&quot;) {
	static properties := {Action:&quot;DefaultAction&quot;, DoAction:&quot;DoDefaultAction&quot;, Keyboard:&quot;KeyboardShortcut&quot;}
	AccObj :=   IsObject(WinTitle)? WinTitle
			:   Acc_ObjectFromWindow( WinExist(WinTitle, WinText, ExcludeTitle, ExcludeText), 0 )
	if ComObjType(AccObj, &quot;Name&quot;) != &quot;IAccessible&quot;
		ErrorLevel := &quot;Could not access an IAccessible Object&quot;
	else {
		StringReplace, ChildPath, ChildPath, _, %A_Space%, All
		AccError:=Acc_Error(), Acc_Error(true)
		Loop Parse, ChildPath, ., %A_Space%
			try {
				if A_LoopField is digit
					Children:=Acc_Children(AccObj), m2:=A_LoopField ; mimic &quot;m2&quot; output in else-statement
				else
					RegExMatch(A_LoopField, &quot;(\D*)(\d*)&quot;, m), Children:=Acc_ChildrenByRole(AccObj, m1), m2:=(m2?m2:1)
				if Not Children.HasKey(m2)
					throw
				AccObj := Children[m2]
			} catch {
				ErrorLevel:=&quot;Cannot access ChildPath Item #&quot; A_Index &quot; -&gt; &quot; A_LoopField, Acc_Error(AccError)
				if Acc_Error()
					throw Exception(&quot;Cannot access ChildPath Item&quot;, -1, &quot;Item #&quot; A_Index &quot; -&gt; &quot; A_LoopField)
				return
			}
		Acc_Error(AccError)
		StringReplace, Cmd, Cmd, %A_Space%, , All
		properties.HasKey(Cmd)? Cmd:=properties[Cmd]:
		try {
			if (Cmd = &quot;Location&quot;)
				AccObj.accLocation(ComObj(0x4003,&amp;x:=0), ComObj(0x4003,&amp;y:=0), ComObj(0x4003,&amp;w:=0), ComObj(0x4003,&amp;h:=0), ChildId)
			  , ret_val := &quot;x&quot; NumGet(x,0,&quot;int&quot;) &quot; y&quot; NumGet(y,0,&quot;int&quot;) &quot; w&quot; NumGet(w,0,&quot;int&quot;) &quot; h&quot; NumGet(h,0,&quot;int&quot;)
			else if (Cmd = &quot;Object&quot;)
				ret_val := AccObj
			else if Cmd in Role,State
				ret_val := Acc_%Cmd%(AccObj, ChildID+0)
			else if Cmd in ChildCount,Selection,Focus
				ret_val := AccObj[&quot;acc&quot; Cmd]
			else
				ret_val := AccObj[&quot;acc&quot; Cmd](ChildID+0)
		} catch {
			ErrorLevel := &quot;&quot;&quot;&quot; Cmd &quot;&quot;&quot; Cmd Not Implemented&quot;
			if Acc_Error()
				throw Exception(&quot;Cmd Not Implemented&quot;, -1, Cmd)
			return
		}
		return ret_val, ErrorLevel:=0
	}
	if Acc_Error()
		throw Exception(ErrorLevel,-1)
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2021-08-06T19:27:35Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149193#p149193</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Перемещение ярлыков на панели задач]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149192#p149192" />
			<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-06T17:57:37Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149192#p149192</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Перемещение ярлыков на панели задач]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149191#p149191" />
			<content type="html"><![CDATA[<p><strong>Malcev</strong></p><p>Мне кажется он имел ввиду, что есть вкладки, которые выгружают память и имеют белый фон, до тех пор, пока ты не развернешь её.</p>]]></content>
			<author>
				<name><![CDATA[Clannad5]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39853</uri>
			</author>
			<updated>2021-08-06T17:54:14Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149191#p149191</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Перемещение ярлыков на панели задач]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149190#p149190" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>ITaskbarList::ActivateTab method (shobjidl_core.h)<br />Activates an item on the taskbar. The window is not actually activated; the window&#039;s item on the taskbar is merely displayed as active.</p></blockquote></div><div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Например, если это «спящая» вкладка, она начнёт загружаться.</p></blockquote></div><p>Не знаю, что такое спящая вкладка.<br />Пример привести можешь?</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2021-08-06T17:52:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149190#p149190</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Перемещение ярлыков на панели задач]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149188#p149188" />
			<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-06T17:48:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149188#p149188</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Перемещение ярлыков на панели задач]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149185#p149185" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Во-первых как-то некрасиво</p></blockquote></div><p>Вам шашечки или ехать? <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /><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-06T17:39:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149185#p149185</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Перемещение ярлыков на панели задач]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149184#p149184" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>Почему?</p></blockquote></div><p>Во-первых как-то некрасиво, во-вторых, мало ли что там во вкладках, может активация на что-то повлияет.</p><div class="quotebox"><cite>Clannad5 пишет:</cite><blockquote><p>ведь я иногда могу держать хотбар сверху, снизу</p></blockquote></div><p>Это не важно. В момент клика до срабатывания метки LButton панель задач может не успевать активизироваться, и полученные координаты будут неверны.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-08-06T17:35:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149184#p149184</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Перемещение ярлыков на панели задач]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149181#p149181" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong><br />Я пробовал через CoordMode, но видимо придётся если только весь экран использовать, а ведь я иногда могу держать хотбар сверху, снизу.</p>]]></content>
			<author>
				<name><![CDATA[Clannad5]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39853</uri>
			</author>
			<updated>2021-08-06T17:00:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149181#p149181</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Перемещение ярлыков на панели задач]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149179#p149179" />
			<content type="html"><![CDATA[<p>Почему?</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2021-08-06T16:20:09Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149179#p149179</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Перемещение ярлыков на панели задач]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149177#p149177" />
			<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-06T16:14:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149177#p149177</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Перемещение ярлыков на панели задач]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149176#p149176" />
			<content type="html"><![CDATA[<p>Придумал как хендлы узнать можно.<br />Получаем список окон, активируем вкладки по этому списку:<br /><a href="https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist-activatetab">https://docs.microsoft.com/en-us/window … ctivatetab</a><br />После чего через iaccessible смотрим позицию активной вкладки и пихаем в массив.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2021-08-06T15:40:29Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149176#p149176</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Перемещение ярлыков на панели задач]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=149171#p149171" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Clannad5 пишет:</cite><blockquote><p>показывает координаты в минусах.</p></blockquote></div><p>Читайте про CoordMode.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-08-06T14:41:03Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=149171#p149171</id>
		</entry>
</feed>
