Need to check a radio button in another program. Sending mouse click has no effect so I'm trying to learn this new method but having no success. What am I missing here?
Form Declarations:
Private Sub:
Form Declarations:
VB.NET:
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As IntPtr, ByVal hWnd2 As IntPtr, ByVal lpsz1 As String, ByVal lpsz2 As String) As IntPtr
Declare Function SetActiveWindow Lib "user32.dll" (ByVal hwnd As IntPtr) As IntPtr
Declare Function SendNotifyMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As IntPtr, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Const WM_LBUTTONDOWN As Long = &H201
Const WM_LBUTTONUP As Long = &H202
Const BM_SETCHECK As Long = &HF1
Const BST_CHECKED As Long = 1
Dim FHandle, hOne, hTwo, hThree As IntPtr
Private Sub:
VB.NET:
FHandle = IntPtr.Zero
Do While True
FHandle = FindWindow("UIW_WINDOW", "Cost of Goods on Hand Full Report")
If FHandle <> IntPtr.Zero Then Exit Do
System.Threading.Thread.Sleep(100)
Loop
FHandle = FindWindow("UIW_WINDOW", "Cost of Goods on Hand Full Report")
hOne = FindWindowEx(FHandle, IntPtr.Zero, "CLIENT", "")
hTwo = FindWindowEx(hOne, IntPtr.Zero, "Button", "End")
hThree = FindWindowEx(hTwo, IntPtr.Zero, "Button", "01/09/2011")
SetActiveWindow(hThree)
SendNotifyMessage(hThree, BM_SETCHECK, BST_CHECKED, IntPtr.Zero)