Jump to content

[SOLVED] Taskbar icons coordinates


Recommended Posts

Cannot find example how to locate taskbar icon coordinates or position by window handle.

I want to use PixelChecksum to check only rectangle area over specified taskbar item.

Please help.

What I already have found and succesfully run for whole taskbar area:

$taskbar = WinGetHandle("[Class:Shell_TrayWnd]")
$taskbarPos = WinGetPos($taskbar)
$tasklistPos = ControlGetPos($taskbar, "", "[CLASS:MSTaskListWClass; INSTANCE:1]") 

$iOldCheckSum = PixelChecksum($taskbarPos[0] + $tasklistPos[0], $taskbarPos[1] + $tasklistPos[1], $taskbarPos[0] + $tasklistPos[2], $taskbarPos[1] + $tasklistPos[3]);


I know also that I can pass window handle as parameter to PixelChecksum, but don't know how to do this with taskbar icon.

 

Also I was able to find something similar but seems outdated: WatchWindows


__
thanks in advance

Edited by newbie2019
Answer found
Link to comment
Share on other sites

16 hours ago, newbie2019 said:

example how to locate taskbar icon coordinates

#include "CUIAutomation2.au3" ; https://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/

Global $pElement, $pCondition, $pElementArray, $iElements, $vValue

; Get taskbar handle
$hCtrl = ControlGetHandle("[Class:Shell_TrayWnd]", "", "MSTaskListWClass1")

; Get UIAutomation object
$oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation)

; Get taskbar element
$oUIAutomation.ElementFromHandle($hCtrl, $pElement)
$oElement = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)

; Get condition (ControlType = Button)
$oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition)
$oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition)

; Find all buttons
$oElement.FindAll($TreeScope_Children, $oCondition, $pElementArray)
$oElementArray = ObjCreateInterface($pElementArray, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray)
$oElementArray.Length($iElements)

; Get array of buttons
Global $aElements[$iElements]
For $i = 0 To $iElements - 1
  $oElementArray.GetElement($i, $pElement)
  $aElements[$i] = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
Next

; Get name and position for each button
$tRect = DllStructCreate("long Left;long Top;long Right;long Bottom")
For $i = 0 To UBound($aElements) - 1
  $aElements[$i].GetCurrentPropertyValue($UIA_NamePropertyId, $vValue)
  ConsoleWrite("Name:" & $vValue)
  $aElements[$i].CurrentBoundingRectangle($tRect)
  ConsoleWrite(" L:" & $tRect.Left & " T:" & $tRect.Top & " R:" & $tRect.Right & " B:" & $tRect.Bottom & @CRLF)
Next

 

Link to comment
Share on other sites

On 10/16/2019 at 2:26 PM, InnI said:
#include "CUIAutomation2.au3" ; https://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/

Global $pElement, $pCondition, $pElementArray, $iElements, $vValue

; Get taskbar handle
$hCtrl = ControlGetHandle("[Class:Shell_TrayWnd]", "", "MSTaskListWClass1")

; Get UIAutomation object
$oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation)

; Get taskbar element
$oUIAutomation.ElementFromHandle($hCtrl, $pElement)
$oElement = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)

; Get condition (ControlType = Button)
$oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition)
$oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition)

; Find all buttons
$oElement.FindAll($TreeScope_Children, $oCondition, $pElementArray)
$oElementArray = ObjCreateInterface($pElementArray, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray)
$oElementArray.Length($iElements)

; Get array of buttons
Global $aElements[$iElements]
For $i = 0 To $iElements - 1
  $oElementArray.GetElement($i, $pElement)
  $aElements[$i] = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
Next

; Get name and position for each button
$tRect = DllStructCreate("long Left;long Top;long Right;long Bottom")
For $i = 0 To UBound($aElements) - 1
  $aElements[$i].GetCurrentPropertyValue($UIA_NamePropertyId, $vValue)
  ConsoleWrite("Name:" & $vValue)
  $aElements[$i].CurrentBoundingRectangle($tRect)
  ConsoleWrite(" L:" & $tRect.Left & " T:" & $tRect.Top & " R:" & $tRect.Right & " B:" & $tRect.Bottom & @CRLF)
Next

 

Thank you very much, will try when will have time.

Link to comment
Share on other sites

On 10/16/2019 at 2:26 PM, InnI said:
#include "CUIAutomation2.au3" ; https://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/

Global $pElement, $pCondition, $pElementArray, $iElements, $vValue

; Get taskbar handle
$hCtrl = ControlGetHandle("[Class:Shell_TrayWnd]", "", "MSTaskListWClass1")

; Get UIAutomation object
$oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation)

; Get taskbar element
$oUIAutomation.ElementFromHandle($hCtrl, $pElement)
$oElement = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)

; Get condition (ControlType = Button)
$oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition)
$oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition)

; Find all buttons
$oElement.FindAll($TreeScope_Children, $oCondition, $pElementArray)
$oElementArray = ObjCreateInterface($pElementArray, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray)
$oElementArray.Length($iElements)

; Get array of buttons
Global $aElements[$iElements]
For $i = 0 To $iElements - 1
  $oElementArray.GetElement($i, $pElement)
  $aElements[$i] = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
Next

; Get name and position for each button
$tRect = DllStructCreate("long Left;long Top;long Right;long Bottom")
For $i = 0 To UBound($aElements) - 1
  $aElements[$i].GetCurrentPropertyValue($UIA_NamePropertyId, $vValue)
  ConsoleWrite("Name:" & $vValue)
  $aElements[$i].CurrentBoundingRectangle($tRect)
  ConsoleWrite(" L:" & $tRect.Left & " T:" & $tRect.Top & " R:" & $tRect.Right & " B:" & $tRect.Bottom & @CRLF)
Next

 

Thank you again, it works perfectly!

Edited by newbie2019
Link to comment
Share on other sites

  • 3 years later...
On 10/16/2019 at 1:26 PM, InnI said:
#include "CUIAutomation2.au3" ; https://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/

Global $pElement, $pCondition, $pElementArray, $iElements, $vValue

; Get taskbar handle
$hCtrl = ControlGetHandle("[Class:Shell_TrayWnd]", "", "MSTaskListWClass1")

; Get UIAutomation object
$oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation)

; Get taskbar element
$oUIAutomation.ElementFromHandle($hCtrl, $pElement)
$oElement = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)

; Get condition (ControlType = Button)
$oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition)
$oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition)

; Find all buttons
$oElement.FindAll($TreeScope_Children, $oCondition, $pElementArray)
$oElementArray = ObjCreateInterface($pElementArray, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray)
$oElementArray.Length($iElements)

; Get array of buttons
Global $aElements[$iElements]
For $i = 0 To $iElements - 1
  $oElementArray.GetElement($i, $pElement)
  $aElements[$i] = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
Next

; Get name and position for each button
$tRect = DllStructCreate("long Left;long Top;long Right;long Bottom")
For $i = 0 To UBound($aElements) - 1
  $aElements[$i].GetCurrentPropertyValue($UIA_NamePropertyId, $vValue)
  ConsoleWrite("Name:" & $vValue)
  $aElements[$i].CurrentBoundingRectangle($tRect)
  ConsoleWrite(" L:" & $tRect.Left & " T:" & $tRect.Top & " R:" & $tRect.Right & " B:" & $tRect.Bottom & @CRLF)
Next

Any idea how to get the icon position on each monitor for same app?

Let's assume I have 3 monitors and thus 3 taskbars and I want to get all 3 coordinates of the icons in the taskbars.

 

Found this C# code from here:

void button1_Click(int sender, EventArgs *e)
{

    IUIAutomation* pUIAutomation = NULL;
    HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);

    HWND hWndTray = FindWindow(L"Shell_TrayWnd", nullptr);
    HWND hWndTrayNotify = FindWindowEx(hWndTray, 0, L"TrayNotifyWnd", nullptr);
    HWND hWndSysPager = FindWindowEx(hWndTrayNotify, 0, L"SysPager", nullptr);
    HWND hWndToolbar = FindWindowEx(hWndSysPager, 0, L"ToolbarWindow32", nullptr);

    HWND hWndRebar = FindWindowEx(hWndTray, 0, L"ReBarWindow32", nullptr);
    HWND hWndMSTaskSwWClass = FindWindowEx(hWndRebar, 0, L"MSTaskSwWClass", nullptr);
    HWND hWndMSTaskListWClass = FindWindowEx(hWndMSTaskSwWClass, 0, L"MSTaskListWClass", nullptr);

    // Taskbar
    IUIAutomationElement* windowElement = NULL;
    hr = pUIAutomation->ElementFromHandle(hWndMSTaskListWClass, &windowElement );

    if (windowElement != nullptr)
    {
        IUIAutomationElementArray *elementArray = nullptr;
        IUIAutomationCondition *condition = pUIAutomation->CreateTrueCondition();
        elementArray = windowElement->FindAll(TreeScope::TreeScope_Descendants | TreeScope::TreeScope_Children, condition);
        if (elementArray != nullptr)
        {
            std::wcout << L"Taskbar" << std::endl;
            int nNbItems = elementArray->Length;
            for (int nItem = 0; nItem <= nNbItems - 1; nItem++)
            {
                IUIAutomationElement *element = elementArray->GetElement(nItem);
                std::wstring sName = element->CurrentName;
                std::wstring sAutomationId = element->CurrentAutomationId;
                tagRECT *rect = element->CurrentBoundingRectangle;
                std::wcout << L"\tName : " << sName << L" - AutomationId : " << sAutomationId << L"  - Rect(" << rect->left << L", " << rect->top << L", " << rect->right << L", " << rect->bottom << std::endl;
            }
        }
    }

    // Tray icons
    IUIAutomationElement *windowElementTray = pUIAutomation->ElementFromHandle(hWndToolbar);
    if (windowElementTray != nullptr)
    {
        IUIAutomationElementArray *elementArray = nullptr;
        IUIAutomationCondition *condition = pUIAutomation->CreateTrueCondition();
        elementArray = windowElementTray->FindAll(TreeScope::TreeScope_Descendants | TreeScope::TreeScope_Children, condition);
        if (elementArray != nullptr)
        {
            std::wcout << L"Tray Icons" << std::endl;
            int nNbItems = elementArray->Length;
            for (int nItem = 0; nItem <= nNbItems - 1; nItem++)
            {
                IUIAutomationElement *element = elementArray->GetElement(nItem);
                std::wstring sName = element->CurrentName;
                std::wstring sAutomationId = element->CurrentAutomationId;
                tagRECT *rect = element->CurrentBoundingRectangle;
                std::wcout << L"\tName : " << sName << L" - AutomationId : " << sAutomationId << L"  - Rect(" << rect->left << L", " << rect->top << L", " << rect->right << L", " << rect->bottom << std::endl;
            }
        }
    }

}

 

Maybe @LarsJ or @junkew can help to translate it to Autoit... 😊

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

10 hours ago, UEZ said:

Any idea how to get the icon position on each monitor for same app?

This code works for first (primary?) monitor with taskbar whose class is Shell_TrayWnd.

Try this code for second monitor with taskbar whose class is Shell_SecondaryTrayWnd

; Get taskbar handle
$hCtrl = ControlGetHandle("[Class:Shell_SecondaryTrayWnd]", "", "MSTaskListWClass1")
Link to comment
Share on other sites

What if 3+ monitors?

With Control Viewer (new) I can see that each taskbar has is own handle.

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

3 minutes ago, UEZ said:

With Control Viewer (new) I can see that each taskbar has is own handle.

I don't have a multi-monitor system. I think you need to find these handles and use them in the code.
That is, your question should be how to find these handles.

Link to comment
Share on other sites

Here is a sample code. It might not be the best as I have  not used UIA a lot. I took example from this page and I used UIA spy.

#include "Includes\UIA_Constants.au3" ; Can be copied from UIASpy Includes folder


Example()

Func Example()
    ; Create UI Automation object
    Local $oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtag_IUIAutomation)
    If Not IsObj($oUIAutomation) Then Return ConsoleWrite("$oUIAutomation ERR" & @CRLF)
    ConsoleWrite("$oUIAutomation OK" & @CRLF)

    ; Get Desktop element
    Local $pDesktop, $oDesktop
    $oUIAutomation.GetRootElement($pDesktop)
    $oDesktop = ObjCreateInterface($pDesktop, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement)
    If Not IsObj($oDesktop) Then Return ConsoleWrite("$oDesktop ERR" & @CRLF)
    ConsoleWrite("$oDesktop OK" & @CRLF)


    ; --- Find window/control ---

    ConsoleWrite("--- Find window/control ---" & @CRLF)

    Local $pCondition0
    $oUIAutomation.CreatePropertyCondition($UIA_NamePropertyId, "Running applications", $pCondition0)
    If Not $pCondition0 Then Return ConsoleWrite("$pCondition0 ERR" & @CRLF)
    ConsoleWrite("$pCondition0 OK" & @CRLF)

    Local $pTaskbars, $oTaskbars
    $oDesktop.FindAll(BitOR($TreeScope_Descendants, $TreeScope_Children), $pCondition0, $pTaskbars) ;BitOR($TreeScope_Descendants,$TreeScope_Children)
    $oTaskbars = ObjCreateInterface($pTaskbars, $sIID_IUIAutomationElementArray, $dtag_IUIAutomationElementArray)
    If Not IsObj($oTaskbars) Then Return ConsoleWrite("$oTaskbars ERR" & @CRLF)
    ConsoleWrite("$oTaskbars OK" & @CRLF)

    Local $iNumberOfTaskbars
    $oTaskbars.length($iNumberOfTaskbars)
    ConsoleWrite("Number of taskbars:" & $iNumberOfTaskbars & @CRLF)


    ; Get array of buttons
    Local $aElements[$iNumberOfTaskbars], $pElement, $vValue
    For $i = 0 To $iNumberOfTaskbars - 1
        $oTaskbars.GetElement($i, $pElement)
        $aElements[$i] = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement)
    Next

    ; Get name and position for each button
    $tRect = DllStructCreate("long Left;long Top;long Right;long Bottom")
    Local $pConditionButtons, $pButtonOfInterest, $oButtonOfInterest
    ;following line needs to be modifed or changed with block of code
    $oUIAutomation.CreatePropertyCondition($UIA_NamePropertyId, "UIASpy.exe - 1 running window", $pConditionButtons)
    For $i = 0 To UBound($aElements) - 1
        $aElements[$i].GetCurrentPropertyValue($UIA_NamePropertyId, $vValue)
        ConsoleWrite("Name:" & $vValue & @CRLF)
        ;parent control bbox
        $aElements[$i].CurrentBoundingRectangle($tRect)
        ConsoleWrite(" L:" & $tRect.Left & " T:" & $tRect.Top & " R:" & $tRect.Right & " B:" & $tRect.Bottom & @CRLF)

        $aElements[$i].FindFirst($TreeScope_Children,$pConditionButtons,$pButtonOfInterest)
        $oButtonOfInterest=ObjCreateInterface($pButtonOfInterest,$sIID_IUIAutomationElement, $dtag_IUIAutomationElement)
        ;specific button bbox
        $oButtonOfInterest.CurrentBoundingRectangle($tRect)
        ConsoleWrite(" L:" & $tRect.Left & " T:" & $tRect.Top & " R:" & $tRect.Right & " B:" & $tRect.Bottom & @CRLF)
    Next

EndFunc   ;==>Example

 

Link to comment
Share on other sites

Using UIA spy I found that each taskbar contains container with name "Running applications". Using that it is possible to get all containers with that text by using FindAll. Then by going through each container I look for a specific window using some condition. In your case you will probably have to change that to something more advanced.

Link to comment
Share on other sites

1 hour ago, ahmet said:

Here is a sample code.

added:

;specific button bbox
        If Not IsObj($oButtonOfInterest) Then ContinueLoop
        $oButtonOfInterest.CurrentBoundingRectangle($tRect)

so it don't crash. The results are:

2 monitors:
--- Find window/control ---
$pCondition0 OK
$oTaskbars OK
Number of taskbars:2
Name:Running applications
 L:144 T:824 R:1640 B:864
Name:Running applications
 L:2192 T:1040 R:3901 B:1080
 
 1 monitor:
--- Find window/control ---
$pCondition0 OK
$oTaskbars OK
Number of taskbars:1
Name:Running applications
 L:96 T:824 R:1640 B:864

..hope it helps.

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

@ahmet thanks for the code but it detects only 2 taskbars although I have 3 - seems that the primary monitor isn't found. Further, the code runs over 23 seconds!

@argumentum thanks, I got the crash, too.

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

12 hours ago, InnI said:

how to find these handles

@UEZ Try this code. If "other monitors taskbar count = 1" then write class of taskbar on the third monitor.

; first monitor
$hCtrl = ControlGetHandle("[Class:Shell_TrayWnd]", "", "MSTaskListWClass1")
ConsoleWrite($hCtrl & @CRLF)

; other monitors
$ahWnd = WinList("[Class:Shell_SecondaryTrayWnd]")
ConsoleWrite("Other monitors taskbar count = " & $ahWnd[0][0] & @CRLF)
Global $ahCtrl[$ahWnd[0][0]]
For $i = 1 To $ahWnd[0][0]
  $ahCtrl[$i - 1] = ControlGetHandle($ahWnd[$i][1], "", "MSTaskListWClass1")
Next

; handles
For $i = 0 To UBound($ahCtrl) - 1
  ConsoleWrite($ahCtrl[$i] & @CRLF)
Next
Link to comment
Share on other sites

@InnI looks good

0x00020046
Other monitors taskbar count = 2
0x0002007E
0x0002006E

but the handle differs from the ControlViewer handles because your script searches for controls rather than taskbar handles. I've no real experience with IUI stuff and I don't know if it is good to go with control handles rather than taskbar handles.

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

@UEZ hopefully this will work

#include "CUIAutomation2.au3" ; https://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/

; Search taskbars
$ahWnd = WinList("[REGEXPCLASS:Shell_(Secondary)?TrayWnd]")
ConsoleWrite("Found taskbars " & $ahWnd[0][0] & @CRLF)

; Search controls
Global $ahCtrl[$ahWnd[0][0]]
For $i = 1 To $ahWnd[0][0]
  $ahCtrl[$i - 1] = ControlGetHandle($ahWnd[$i][1], "", "MSTaskListWClass1")
Next

; Get UIAutomation object
$oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation)
If Not IsObj($oUIAutomation) Then Exit ConsoleWrite("Error create UIA object" & @CRLF)

; Create 2D array of buttons [name,left,top,right,bottom]
Global $aBtnInfo[0][5], $Count, $pElement, $pCondition, $pElementArray, $iButtons, $vValue
$tRect = DllStructCreate("long Left;long Top;long Right;long Bottom")
For $n = 0 To UBound($ahCtrl) - 1
  ; Get taskbar element
  $oUIAutomation.ElementFromHandle($ahCtrl[$n], $pElement)
  $oElement = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
  ; Get condition (ControlType = Button)
  $oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition)
  $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition)
  ; Find all buttons
  $oElement.FindAll($TreeScope_Children, $oCondition, $pElementArray)
  $oElementArray = ObjCreateInterface($pElementArray, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray)
  $oElementArray.Length($iButtons)
  ReDim $aBtnInfo[UBound($aBtnInfo) + $iButtons][5]
  ; Get name and position for each button
  For $i = 0 To $iButtons - 1
    $oElementArray.GetElement($i, $pElement)
    $oButton = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
    $oButton.GetCurrentPropertyValue($UIA_NamePropertyId, $vValue)
    $oButton.CurrentBoundingRectangle($tRect)
    $aBtnInfo[$i + $Count][0] = $vValue
    $aBtnInfo[$i + $Count][1] = $tRect.Left
    $aBtnInfo[$i + $Count][2] = $tRect.Top
    $aBtnInfo[$i + $Count][3] = $tRect.Right
    $aBtnInfo[$i + $Count][4] = $tRect.Bottom
  Next
  $Count += $iButtons
Next

#include <Array.au3>
_ArrayDisplay($aBtnInfo)
Link to comment
Share on other sites

@InnI thanks - looks very promising.

Is it possible to check with IUI on which monitor the taskbar is? Just to avoid any workarounds...

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

42 minutes ago, UEZ said:

Is it possible to check with IUI on which monitor the taskbar is?

I am not familiar with the methods of the IUIAutomation interface for working with monitors.

Edited by InnI
Link to comment
Share on other sites

Have this snippet lying around.

#include <Array.au3>
#include <WinAPIGdi.au3>

$aData = _Enum_Monitors()
_ArrayDisplay($aData)

Func _Enum_Monitors()
    Local $aData = _WinAPI_EnumDisplayMonitors()
    If Not @error Then
        If IsArray($aData) Then
            ReDim $aData[$aData[0][0] + 1][5 + 4]
            For $i = 1 To $aData[0][0]
                Local $aPos = _WinAPI_GetPosFromRect($aData[$i][1])
                If Not @error Then
                    For $j = 0 To 3
                        $aData[$i][$j + 1] = $aPos[$j]
                    Next
                EndIf
                Local $aData_Sub = _WinAPI_GetMonitorInfo($aData[$i][0])
                If Not @error Then
                    If IsArray($aData_Sub) Then
                        $aData[$i][5] = DllStructGetData($aData_Sub[0], 1) & ', ' & DllStructGetData($aData_Sub[0], 2) & ', ' & DllStructGetData($aData_Sub[0], 3) & ', ' & DllStructGetData($aData_Sub[0], 4) ; Rectangle
                        $aData[$i][6] = DllStructGetData($aData_Sub[1], 1) & ', ' & DllStructGetData($aData_Sub[1], 2) & ', ' & DllStructGetData($aData_Sub[1], 3) & ', ' & DllStructGetData($aData_Sub[1], 4) ; Work area
                        $aData[$i][7] = $aData_Sub[2] ; Primary
                        $aData[$i][8] = $aData_Sub[3] ; Device name
                    EndIf
                EndIf
            Next
        EndIf
    EndIf
    If Not IsArray($aData) Then Return SetError(1)
    ; _ArrayTranspose($aData)
    ; _ArrayDisplay($aData)
    Return $aData
EndFunc   ;==>_Enum_Monitors

 

Link to comment
Share on other sites

I'm using 

Local $tPos = _WinAPI_GetMousePos()
            Local $hMonitor = _WinAPI_MonitorFromPoint($tPos)
            Local $aData = _WinAPI_GetMonitorInfo($hMonitor)

to get the information of the current monitor but I thought that there is also a class in the IUI to get the monitor of the taskbar. However, it shouldn't be a challenge to get the icon position on which monitor it is.

Thanks you all!

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...