Jump to content

How to trap tray notifications in Windows 10 ?

Recommended Posts


I want to trap a tray notification from Bluestacks/WhatsApp.


Here is my code

Func _Exit()
    If IsDeclared("@exitCode") Then MsgBox(262144, Default, "Exit", 3)
EndFunc   ;==>_Exit
If Not HotKeySet("{ESC}", "_Exit") Then Exit MsgBox(16 + 262144, Default, "Script cancelled due to HotKey ESC already defined. ", 5)
MsgBox(262144, Default, "Start", 1)
While Sleep(1000)
    Beep(500, 100)
    ; next line has german string "Neue Benachrichtigung". change it if not running german version of windows
    If WinExists("[class:Windows.UI.Core.CoreWindow;title:Neue Benachrichtigung]") Then ExitLoop
Beep(1000, 1000)
MsgBox(262144, Default, "Window found", 0)

The code does not show the "Window found" message even when the tray notify message appears.

When I omit the ";title:Neue Benachrichtigung" the "found" message appears at once even when there is no notification window.

Do you know of another method to read the notification Windows of other applications?




Edited by Exit

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post

Link to post
Share on other sites

I think You can do this if just want to know it exist a notification of bluestack.


#include <GUIConstantsEx.au3>
#include <WinAPIEx.au3>

Global $BlueStackPID = ProcessExists("Bluestacks.exe") ;the corrcet process name I dont know what it is. :S


Func Example()
    Local $hGUI = GUICreate('An(other) example by guinness - 2013', Default, Default)
    GUISetState(@SW_SHOW, $hGUI)

    GUIRegisterMsg(_WinAPI_RegisterWindowMessage('SHELLHOOK'), 'WM_SHELLHOOK')

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE

EndFunc   ;==>Example

Func WM_SHELLHOOK($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg
    Local $sTitle = WinGetTitle($lParam)
    Local $iPID=0
     $iPID = _WinAPI_GetWindowThreadProcessId($hWnd, $iPID)
    If $wParam = $HSHELL_REDRAW And $sTitle = "Notificación nueva" and $iPID = $BlueStackPID Then
        ConsoleWrite("BlueStack Notification!!!" & @CRLF)

EndFunc   ;==>WM_SHELLHOOK


If you want to check the text "whatsapp"   you must combine with  this.




  • Like 1

Share this post

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