Use these declarations and the code below (untested):
\\\
Private Declare Auto Function FindWindow Lib "user32.dll" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String _
) As IntPtr
Private Declare Auto Function FindWindowEx Lib "user32.dll" ( _
ByVal hwndParent As IntPtr, _
ByVal hwndChildAfter As IntPtr, _
ByVal lpszClass As String, _
ByVal lpszWindow As String _
) As IntPtr
..
..
..
Dim hWnd As IntPtr = FindWindow(vbNullString, "FSM")
If hWnd.Equals(IntPtr.Zero) Then
Return
End If
Dim hWndButton As IntPtr = _
FindWindowEx(hWnd, IntPtr.Zero, "BUTTON", "Button 1")
If hWndButton.Equals(IntPtr.Zero) Then
Return
End If
....
///
Note that "BUTTON" must be replaced by the Win32 window class name of the
control. This is typically "BUTTON" for C-based applications, but the class
name can differ for applications written in Classic Visual Basic and .NET.
You can use the Spy++ utility which comes with VS.NET to grab the control's
class name. The last parameter of 'FindWindowEx' expects the button's
caption. Make sure you don't forget the leading "&" character if the
caption contains an accelerator key.
--
\\\
Private Declare Auto Function FindWindow Lib "user32.dll" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String _
) As IntPtr
Private Declare Auto Function FindWindowEx Lib "user32.dll" ( _
ByVal hwndParent As IntPtr, _
ByVal hwndChildAfter As IntPtr, _
ByVal lpszClass As String, _
ByVal lpszWindow As String _
) As IntPtr
..
..
..
Dim hWnd As IntPtr = FindWindow(vbNullString, "FSM")
If hWnd.Equals(IntPtr.Zero) Then
Return
End If
Dim hWndButton As IntPtr = _
FindWindowEx(hWnd, IntPtr.Zero, "BUTTON", "Button 1")
If hWndButton.Equals(IntPtr.Zero) Then
Return
End If
....
///
Note that "BUTTON" must be replaced by the Win32 window class name of the
control. This is typically "BUTTON" for C-based applications, but the class
name can differ for applications written in Classic Visual Basic and .NET.
You can use the Spy++ utility which comes with VS.NET to grab the control's
class name. The last parameter of 'FindWindowEx' expects the button's
caption. Make sure you don't forget the leading "&" character if the
caption contains an accelerator key.
--