SendWindowMessage Method Example

If Notepad is running, this example displays the About dialog box (in Notepad) by sending a WM_COMMAND message to Notepad. The SendWindowMessage method is used to send the WM_COMMAND message (111 is the hexidecimal value for WM_COMMAND), with the parameters 11 and 0. The Spy utility was used to determine the wParam and lParam values.

For Each myTask In Tasks
    If InStr(myTask.Name, "Notepad") > 0 Then
        myTask.Activate
        myTask.SendWindowMessage &h111, 11, 0
    End If
Next myTask