Tinkerer Posted December 15, 2023 Posted December 15, 2023 Hi all, Have come across multiple questions in the Forums about how to detect a flashing Icon in the Taskbar. Ultimately didn't look like there was a clear consensus on this, so wanted to share a relatively straightfoward way I did this in a recent project using Exorcista's UI Automation Library. Essentially, it looks like there's a property called "ItemStatus" that gets set to "Requesting attention" when a button in the taskbar flashes. So, after downloading Exorcista's UI Automation Library we can just do something like this (assumes we are making test script in same folder as Exorcista's example scripts): #include-once #include <../UIAutomation_Extended.au3> $UI_activation_parameters = "Start Portion of Button Title" ;Starting Portion of String for Taskbar Button's UIA Name Property (can find this with Microsoft Acessibility Insights or other UIA Spy-type Tools -- for this case, let's assume the full button UIA Name is something like "Start Portion of Button Title Full Button Name" -- rename this variable as necessary) ;Scan for flashing every 5 seconds while (1) Sleep(5000) $flashing_status_array = _IsTaskBarItemFlashingMainHandle($UI_activation_parameters) ;Index 0 is flashing status, Index 1 is full UIA Name if flashing found ConsoleWrite("Current Button Flashing Status:" & $flashing_status_array[0] & @TAB & "Full Button UIA Name (if flashing found):" & $flashing_status_array[1] & @CRLF) wend ;Function to see if a given item in the taskbar is flashing (ie, has property ItemStatus of "Requesting attention") Func _IsTaskBarItemFlashingMainHandle($UI_activation_parameters) ;via UIA Regex Dim $flashing_status[2] $flashing_status[0]=0 $flashing_status[1]="" Local $oUIA_Interface = _UIA_InitInterface() Local $oRootElement = _UIA_GetRootElement($oUIA_Interface) Local $oWindowElement = _UIA_Ext_FindWindowByRegexTitle($oUIA_Interface, $oRootElement, "Taskbar.*") ;gets us to the Taskbar Local $oActivationButton = _UIA_Ext_FindElementByRegexProperty($oUIA_Interface, $oWindowElement, $UI_activation_parameters, $UIA_NamePropertyId) ;Gets us actual button on the Taskbar ;$UIA_ItemStatusPropertyId $item_status_property_id="" $item_status_property_id = _UIA_GetCurrentPropertyValue($oActivationButton, $UIA_ItemStatusPropertyId) ;ConsoleWrite(@CRLF & $item_status_property_id) If $item_status_property_id<>"" Then ;Essentially a status property exists and presume this is due to window flashing/requesting attention $flashing_status[0]=1 $flashing_status[1]=_UIA_GetCurrentPropertyValue($oActivationButton, $UIA_NamePropertyId) Return $flashing_status Else Return $flashing_status EndIf EndFunc Hope this helps.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now