Jump to content
Sign in to follow this  
starlitsky

Have any way to catch the TrayTip on Windows 10? The WinExists() can't detect it.

Recommended Posts

I use the WinExists() try to catch the error message from the system, my OS is Windows 10.

I use Autoit Window Info can see the TrayTip's title and some information, but TrayTip seems not the window... so I can't use WinExists() to catch it.

Have any function can catch the TrayTip on win10?

Share this post


Link to post
Share on other sites
35 minutes ago, Danp2 said:

Google search can be your friend. ;)

Here's one example --

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

Global $PID = ProcessExists("winword.exe")
MsgBox(0, "check", $PID)
Example()

Func Example()
    Local $hGUI = GUICreate('Test 2018', Default, Default)
    GUISetState(@SW_SHOW, $hGUI)

    GUIRegisterMsg(_WinAPI_RegisterWindowMessage('SHELLHOOK'), 'WM_SHELLHOOK')
    _WinAPI_RegisterShellHookWindow($hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    _WinAPI_DeregisterShellHookWindow($hGUI)
    GUIDelete($hGUI)
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 = "新通知" and $iPID = $PID Then
        ConsoleWrite($lParam & "Notification shows!" & @CRLF)
    EndIf
EndFunc   ;==>WM_SHELLHOOK

Maybe my modify have some error, this code can work for anyone? Or it occurs a problem just with Chinese? 

The GUI window has shown, but even the notification appears, GUI just show nothing.

Share this post


Link to post
Share on other sites

Maybe my modify have some error, this code can work for anyone? Or it occurs a problem just with Chinese? 

The GUI window has shown, but even the notification appears, GUI just show nothing.

Global $PID = ProcessExists("winword.exe")
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 = "新通知" And $iPID = $PID Then
        ConsoleWrite($lParam & "Notification shows!" & @CRLF)
    EndIf
EndFunc   ;==>WM_SHELLHOOK

 

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...