Link to home
Start Free TrialLog in
Avatar of Galilea
Galilea

asked on

Please, urgent : sending text to another windows application

How can i send a string of text to another windows application such as Word (i.e. Matlab). I want that everytime I
press a button a certain string, i.e. "String (return)" appears on the word screen. Anyway, some information
on the subject will be greatly appreciated 'cause it is like walking in the dark. Thank you.

jhance, I pin this question because I would greatly appreciate some help and want to get rid of all my question points. I promise you that after this I will disappear forever. All in all, thank you very much for your help, Experts Exchange has really been of great help to me, and has always guided me in the right direction.  
Avatar of ShaunWilde
ShaunWilde

if you can get a handle to the window you could use SetWindowText - however that is only suitable to plain edit boxes - other windows eg word has an automation interface that you could use whether that could be DDE or COM - a good place to put text would be in to the clipboard and then you can use the paste option of the application involved to place it into your window - do yu have aparticular target in mind?
Avatar of Galilea

ASKER

The target is the command window itself. I just want the text to appear on the Matlab window and a return to be implemented. Can you give me some guidance on how to use the clipboard, I wil try SetWindowText and let you know how it goes. Thank you.
ASKER CERTIFIED SOLUTION
Avatar of ShaunWilde
ShaunWilde

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Galilea

ASKER

ShaunWilde,

Thank you very much. How can I call the paste command on the other application so that it appears? Is there any way to do this? How can I send a "Return" keystroke?
you could send a Ctrl+V key stroke to a window if you have its handle
Avatar of Galilea

ASKER

Why can't I use
GetClipboardData(CF_OEMTEXT)?

Wouldn't I be able to produce the return keystroke as well?

How can I send a Ctrl+V stroke?
Avatar of Galilea

ASKER

I can get its hadle using:
::FindWindow(NULL, "Matlab").
using SendMessage (or PostMessage) you could use WM_COMMAND and the ID of the paste command (can be got from the resources of matlab) or you could use WM_CHAR and build up the keystroke -