Ron at OGP
August 23rd, 2001, 09:12 AM
Hello,
This is probably a very simple solution... but of course it isn't simple if you don't know it. :)
I'm currently using the API Declare function PostMessage() to click existing Buttons on another application. I'm doing this by getting their Parent Window Handle and then the Button Handle with that by using FindWindowEx()
Here's a sample of how I'm doing this... maybe it will help someone out.
' Excerpt from function
MyWind3 = FindWindowEx(MyWind2, 0, vbNullString, "MyWindow") '
If MyWind3 <> 0 then 'Could be...
'looking for the Ok button
MYWind4 = FindWindowEx(MyWind3, 0, vbNullString, "OK")
If MyWind4 <> 0 then 'Found it
ClickButtonWithHwnd (MyWind4)
End If
End If
' End Excerpt
public Sub ClickButtonWithHwnd(byval Hwnd as Long)
' Quite a few API declarations are here... sorry for not including them.
Dim Button as Long
Dim ParentHwnd as Long
Dim tmpHwnd as Long
Dim X as Integer
Button = GetDlgCtrlID(Hwnd)
ParentHwnd = GetParent(Hwnd)
tmpHwnd = GetActiveWindow
X = SetForegroundWindow(ParentHwnd)
'This Type of command I know works...
X = PostMessage(ParentHwnd, WM_COMMAND, Button, BN_CLICKED * &H10000 + Hwnd)
X = SetForegroundWindow(tmpHwnd)
End Sub
Anyways, I now want to put some text into a textbox on another application's window by using the same method and PostMessage. I don't know the Message type for Textboxes and MSDN seems to have a type for all controls except for that one.
Does anyone have a complete list of these Message Types and better yet can anyone provide me with an example of how to do a text writing using the PostMessage function?
Thanks everyone!
Ron D.
This request or reply is sponsered by:
Coffee -- the breakfast of champions!
This is probably a very simple solution... but of course it isn't simple if you don't know it. :)
I'm currently using the API Declare function PostMessage() to click existing Buttons on another application. I'm doing this by getting their Parent Window Handle and then the Button Handle with that by using FindWindowEx()
Here's a sample of how I'm doing this... maybe it will help someone out.
' Excerpt from function
MyWind3 = FindWindowEx(MyWind2, 0, vbNullString, "MyWindow") '
If MyWind3 <> 0 then 'Could be...
'looking for the Ok button
MYWind4 = FindWindowEx(MyWind3, 0, vbNullString, "OK")
If MyWind4 <> 0 then 'Found it
ClickButtonWithHwnd (MyWind4)
End If
End If
' End Excerpt
public Sub ClickButtonWithHwnd(byval Hwnd as Long)
' Quite a few API declarations are here... sorry for not including them.
Dim Button as Long
Dim ParentHwnd as Long
Dim tmpHwnd as Long
Dim X as Integer
Button = GetDlgCtrlID(Hwnd)
ParentHwnd = GetParent(Hwnd)
tmpHwnd = GetActiveWindow
X = SetForegroundWindow(ParentHwnd)
'This Type of command I know works...
X = PostMessage(ParentHwnd, WM_COMMAND, Button, BN_CLICKED * &H10000 + Hwnd)
X = SetForegroundWindow(tmpHwnd)
End Sub
Anyways, I now want to put some text into a textbox on another application's window by using the same method and PostMessage. I don't know the Message type for Textboxes and MSDN seems to have a type for all controls except for that one.
Does anyone have a complete list of these Message Types and better yet can anyone provide me with an example of how to do a text writing using the PostMessage function?
Thanks everyone!
Ron D.
This request or reply is sponsered by:
Coffee -- the breakfast of champions!