Sendkeys and sendmessage without bringwindowtotop

Hey, I'm making an app to control another, and need to send stuff to an edit on the target app, without having to bring the target window to the top. Same with sendkeys, need to send them without having to bring the window to the top..ideas?
IncendiumAsked:
Who is Participating?
 
Lukasz LachConnect With a Mentor Commented:
use FindWindow to get the main window, than FindWindowEx to get the child window (in your case, the edit) and with the given handle simple SetWindowText:

H1 := FindWindow('class', 'caption');
H2 := FindWindowEx(H1, 0, 'class', 'caption');
SetWindowText(H2, 'Text');

When you don't know any of caption or class place nil there...
0
 
IncendiumAuthor Commented:
Doesn't work...main window is alphaworld, editbox is names Edit, in var what should h1 and h2 be?i have them as hwnd at the mo.
0
 
Lukasz LachCommented:
procedure TForm1.Button1Click(Sender: TObject);
var
        H1, H2: HWND;
        buffer: array[0..1024] of Char;
begin
        H1 := FindWindow('alphaworld', nil);
        H2 := FindWindowEx(H1, 0, 'Edit', nil);
        buffer := 'Hello';
        SendMessage(H2, WM_SETTEXT, 0, Integer(@buffer));
end;

Now works, sorry, forgot that SetWindowText won't work wit that :-)
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
nestoruaCommented:
HI,
Are both applications are done by you, or the target is any app with tedit on it?
Sincerely,
Nestorua.
0
 
IncendiumAuthor Commented:
The target isn't done by me, and the target editbox is called edit
0
 
Lukasz LachCommented:
Incendium: my code works on Notepad, so should work on your app too. Check if H1 or H2 are not 0 after FindWindow, mabye you name it incorrectly :-)
0
 
CleanupPingCommented:
Incendium:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
kacorretiredCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:
       to accept anAKiN's answer
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Merry Christmas and happy new year!

kacor
EE Cleanup Volunteer
0
 
snehanshuCommented:
Hey Janos,
  Looks like a time-zone overlap!
  To me, it shows this Q was asked on March 1 :-)
  Merry Christmas!
...S
0
All Courses

From novice to tech pro — start learning today.