Jump to content

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 post
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 post
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 post
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 post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By TheAutomator
      This is Iconizer:


      This program is made to replace the free / pro version of folder maker.
      (I bundled a few icon packs with it too).

      How it works:

      Icons are copied to the selected folder, the folder icon is changed to that icon and the icon inside the folder is made hidden and read-only.
      By copying the icon to the folder itself you can now move it to another computer and the icon will stay!
      (A new icon will override the old one).

      I wrote a little installer for it to add or remove this program from/to the context menu of any folder, harddrives are also accepted:



      It runs from the contextmenu but also accepts command-line arguments if you wish.
      Just opening it without any parameters wil launch the 'Iconarchive' website.
      Let me know what you think, any tips, bugs or nice ideas are welcome 
      I'm not sure if I can upload the icons because they were extracted from the .ICL file of foldermaker..
      Kind regards! TheAutomator.
      test.bat Icon.ico Iconize.au3 Installer.au3
    • By Miliardsto
      I have the following code. You can see there are $color_normal and $color_trans
      In my case normal is too dark . And color trans is to much violet.
      If you run it you will see how its looks. I want gui with listView have the same color like taskbar in windows 10.
      How to achieve that?
       
       
      #include <Date.au3> #include <MsgBoxConstants.au3> #include <GuiListBox.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> HotKeySet("{ESC}", "Terminate") $color_normal = "0x" & StringLeft(StringRight(RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent", "AccentPalette"), 24), 6) $color_trans = "0x" & StringLeft(StringRight(RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent", "AccentPalette"), 16), 6) $trans = RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "EnableTransparency") ConsoleWrite("Transpart = " & $trans & @CRLF) ConsoleWrite("Color normal = " & $color_normal & @CRLF) ConsoleWrite("Color trans = " & $color_trans & @CRLF) ConsoleWrite(_Get_taskbar_color()); It return AARRGGBB $taskbarColor = _Get_taskbar_color() Global $gui = GUICreate("Test", 150, 58,@DesktopWidth-300,@DesktopHeight-58,$WS_POPUP,BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) Global $idListview = GUICtrlCreateListView("", 0, 0, 150, 58,BitOR($LBS_NOTIFY,$LBS_SORT), 0) ;_GuiCtrlMakeTrans(-1,100) ; Add column _GUICtrlListView_AddColumn($idListview, "Msgs", 100) GUICtrlSetFont(-1, 7, 400, 0, "Segoe UI") GUICtrlSetColor(-1, 0x470C4F) GUICtrlSetBkColor($idListview, 0x310638) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Terminate() Exit EndFunc Func _Get_taskbar_color() If RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "ColorPrevalence") Then If RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "EnableTransparency") Then Return "0xD9" & StringLeft(StringRight(RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent", "AccentPalette"), 16), 6) Else Return "0xFF" & StringLeft(StringRight(RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent", "AccentPalette"), 24), 6) EndIf Else If RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "EnableTransparency") Then Return "0xD9000000" Else Return "0xFF000000" EndIf EndIf EndFunc  
    • By KaFu
      ICU - Icon Configuration Utility

      Current Version: v6 (2018-Sep-16)
      Restore your desktop when the icons get "rearranged".
      Melba23 and I found we were working on very similar ideas to restore the Desktop icons to their normal place if they became "rearranged" (
      ). Vista seems to like this doing on occasion just for fun - but we all know some apps and games which change the display resolution or move icons around. This annoys "tidy" people who like their desktops arranged "just so" - I am particularly thinking of this desktop when I say that!
      We combined efforts and here is the result of our labors.
      Operation is easy - press "Save" to store a particular configuration and "Restore" to reset the icons to the saved positions in the selected configuration file. "Delete" allows you to remove unwanted configuration files from the list. There is a command line option so that the restoration can be run via HotKeys if required (that is why the script warns that it should be compiled for full functionality). You can decide what to do with any icons that have been added since you last saved the configuration file - the default is to put them in the top-left corner, but you can also banish them way off-screen or, more sensibly, specify a location for them.
      A new feature as of ICU v3.4 is the optional Desktop Contextmenu Integration (DCI) for Win7 (Win7 only because Microsoft implemented an easy way to do this through the registry as of this release).
      Version 3.3 should fix the empty save file bug
      Version 3.4 Win7: Admin rights no longer needed for DCI
      Version 5.0 Win8 compatibility for DCI
      The source and executable can be downloaded from my site: http://www.funk.eu
      Kudos to Ascend4nt, Melba23, Prog@ndy, & Valik for parts of the code.
      Please let me know if you found some piece of code in the source for which I forgot to mention a credit.
      Enjoy, let me know what you think of ICU and with Best Regards
    • By mar3011
      Hey, I have a problem I tried to look for it but it didn't solve the problem, I can't add an icon to the exe, I already know there were such topics I tried to all add exclusion C: \ Users \ Marcin \ AppData \ Local \ AutoIt v3 \ aut472.tm.exe to antivirus but after compilation, the name of the file changes, I uninstalled the anti-virus, but it didn't works, except that when I add the example icons from AutoIT it works, I downloaded icons using Firefox Developer Edition also don't works, just the downloaded graphics don't works also. Is there any solution to this problem?  
    • By Errious
      Hello,
       
      is it possible to use an autoit script to show a live preview from a minimized program?
      I searched for this and found many different little tools but none of them offered this Option so far.
      You may ask why someone should use this, for me it should be a live preview from different clients of a game, when minimized the game itself is not using much resources but with multiple clients running its to heavy for my rig so i try to find a way to still observe what is happening ingame on this minimized clients.
      Would be nice if somebody leads me into the right direction where i can / should begin with, cause i am not sure how this script should look like but maybe someone already tried this (my forum search was not successfull)?
       
      Regards
×
×
  • Create New...