Jump to content

Recommended Posts

Posted
Hello,
 
We have a project requirement to capture system tray popup bubble text using AutoIt script. Script is ready for clicking system tray icon but, unable to capture bubble text.
 
Any inputs/suggestions would be appreciated.
 
Thanks in advance...
 
Regards,
Matti
Posted

I posted this a while back that should help.

Just replace @ScriptName with the program name you're looking for.

#include <GuiToolBar.au3>

Opt("TrayIconDebug", 1)
HotKeySet("p", "My_Tooltip")
For $Loop = 1 To 1000000
    $a = Sqrt($Loop)
    ; the following line is used to slow the script down enough to be able to press the hotkey
    sleep(10)
Next
Func My_Tooltip()
    $Text = Get_SysTray_IconText(@ScriptName)
    If $Text = "" Then
        MsgBox(0, "", "Icon not found")
    Else
        ToolTip($Text, 20, 20)
    EndIf
EndFunc   ;==>My_Tooltip

Func Get_SysTray_IconText($sScriptName = @ScriptName) ; http://www.autoitscript.com/forum/topic/157933-hinttray-tip-how-to-get-text/?p=1145366

    ; Find systray handle for "User Promoted Notification Area"
    Local $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]')
    If @error Then
        MsgBox(16, "Error", "System tray not found")
        Exit
    EndIf
    ; Find systray handle for "Overflow Notification Area" i.e. hidden icons
    Local $hSysTray_Handle_Hidden = ControlGetHandle('[Class:NotifyIconOverflowWindow]', '', '[Class:ToolbarWindow32;Instance:1]')
    If @error Then
        MsgBox(16, "Error", "System tray not found")
        Exit
    EndIf

    ; Get systray item count
    Local $iSysTray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle)
    If $iSysTray_ButCount = 0 Then
        MsgBox(16, "Error", "No items found in system tray")
        Exit
    EndIf

    Local $sSysTray_ButtonText = ""
    ; Look for wanted tooltip
    For $iSysTray_ButtonNumber = 0 To $iSysTray_ButCount - 1
        $sSysTray_ButtonText = _GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSysTray_ButtonNumber)
        If StringInStr($sSysTray_ButtonText, $sScriptName) Then Return $sSysTray_ButtonText
    Next

    Local $iSysTray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle_Hidden)
    If $iSysTray_ButCount = 0 Then
        MsgBox(16, "Error", "No items found in system tray")
        Exit
    EndIf
    Local $sSysTray_ButtonText = ""

    ; Look for wanted tooltip
    For $iSysTray_ButtonNumber = 0 To $iSysTray_ButCount - 1
        $sSysTray_ButtonText = _GUICtrlToolbar_GetButtonText($hSysTray_Handle_Hidden, $iSysTray_ButtonNumber)
        If StringInStr($sSysTray_ButtonText, $sScriptName) Then Return $sSysTray_ButtonText
    Next

    Return ""

EndFunc   ;==>Get_SysTray_IconText

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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
×
×
  • Create New...