Jump to content

how to create Msgbox when a particular window gets activated


Recommended Posts

Hello. You can do something like this.

 

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

HotKeySet("{ESC}", "_Exit")
Global $hGUI=0
Example()

Func Example()
     $hGUI = GUICreate('DummyGUI') ; Create a Dummy GUI.

    GUIRegisterMsg(_WinAPI_RegisterWindowMessage('SHELLHOOK'), 'WM_SHELLHOOK') ; Define a window message and assign to the WM_SHELLHOOK function.
    _WinAPI_RegisterShellHookWindow($hGUI) ; Register the shell hook message to our GUI.

    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 = ""
    Local $iPID = 0
    Local $sMessageBoxText = ""
    Switch $wParam

        Case $HSHELL_WINDOWCREATED
            $sTitle = WinGetTitle($lParam)
            $iPID = WinGetProcess($lParam)
            $sMessageBoxText = ControlGetText($lParam, "","Static2")
            If $sTitle = "dps" Then
;~            ControlClick($lParam,"","Button1");Click automatically In Ok Button
                MsgBox(0, "", "MessageBox Window Detected" & @CRLF & "MessageBox Text: " & $sMessageBoxText)
            EndIf


    EndSwitch
EndFunc   ;==>WM_SHELLHOOK

Func _Exit()
    _WinAPI_DeregisterShellHookWindow($hGUI)
    GUIDelete($hGUI)
    Exit
EndFunc   ;==>_Exit

Saludos

Link to comment
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
 Share

×
×
  • Create New...