|
-
Sep 27th, 2005, 06:16 PM
#1
Thread Starter
Addicted Member
How do you send text to another window
How do you send text to another window, that is not apart of your program.
like say send some text to an open notepad window....
-
Sep 27th, 2005, 06:25 PM
#2
Re: How do you send text to another window
Assuming you have no control over the other program, you will have to use API calls.
Using Spy++ will allow you to get information about the window which you want to send the text to. Then you will need FindWindowEx and one other....hmmm, can't recall, might be FindWindow, but you should be able to find lots of references to both in the API forum. I believe they are pretty well documented in MSDN, as well. Not hard to use, either.
My usual boring signature: Nothing
 
-
Sep 27th, 2005, 06:26 PM
#3
Re: How do you send text to another window
Check out the API section of this Forum.. tons of info in that section, plenty of examples.. using the SendMessage API, as well as Enumerating the windows in order to find the correct window handle.... etc etc
-
Sep 27th, 2005, 06:30 PM
#4
Re: How do you send text to another window
Oh yeah, SendMessage, that's a good one, too.
Spy++ is pretty useful to avoid some enumerating of windows that aren't useful, but even with that, you will have to walk through some windows to get to the one you want in most cases.
My usual boring signature: Nothing
 
-
Sep 28th, 2005, 08:46 AM
#5
Thread Starter
Addicted Member
Re: How do you send text to another window
ok thanks guys, but what exactly is API?
-
Sep 28th, 2005, 12:53 PM
#6
Re: How do you send text to another window
Application Programing Interface.
This is a set of operating systems functions you can call from within a program.
Hmmmm, actually, that last statement is not quite complete, but it is close enough in this case.
My usual boring signature: Nothing
 
-
Sep 28th, 2005, 01:23 PM
#7
Re: How do you send text to another window
Yes, all it really is is calling functions using the user32.dll (mostly), and is pretty simple once you know what you're doing.... here's an example of sendmessage...
VB Code:
'function declaration... this is only one function of many.. used to send messages to window (hwnd)
Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
ByVal hwnd As IntPtr, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As String) As Int32
'constant defined in module containing the function..
Public Const WM_SETTEXT As Long = &HC
'function call...
Dim MessageString
MessageString = "Ths is the text I sent!"
SendMessage(hWnd, WM_SETTEXT, 0, MessageString)
'hwnd is handle of control on other app, set_text is a constant needed for
'function, telling it to set the text of the hWnd (like an edit box or text box),
'Message String is just the string you want to send to it
This sends the string "This is the text I sent!" to the handle of the control that is in the other application... Much more in the API section....
Last edited by gigemboy; Sep 28th, 2005 at 01:28 PM.
-
Sep 28th, 2005, 11:28 PM
#8
Thread Starter
Addicted Member
Re: How do you send text to another window
Public Const WM_SETTEXT As Long = &HC
what does this mean exactly and what section of the code do you put this function?
Last edited by Hiroshi; Sep 30th, 2005 at 09:52 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|