How can I insert the text from an Edit control into any window where the mouse pointer is, without using the clipboard and/or window handle.
I am using Delphi 7.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
GetCursorPosto find out where the cursor is.WindowFromPointto find the window under the cursor.EM_REPLACESELmessage to replace the selection in that window. If nothing is selected then the text will be inserted at the caret.Note: Be prepared for this to fail more commonly than it succeeds. Many applications don’t used windowed edit controls. For a more robust solution you should look into UI Automation.
You asked for some code. Here’s what it would look like:
If the window underneath the cursor is not an edit window, this will, probably, be benign.