?
Solved

Sendkeys and sendmessage without bringwindowtotop

Posted on 2003-02-28
10
Medium Priority
?
473 Views
Last Modified: 2010-04-04
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?
0
Comment
Question by:Incendium
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 5

Accepted Solution

by:
Lukasz Lach earned 300 total points
ID: 8045203
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
 

Author Comment

by:Incendium
ID: 8045227
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
 
LVL 5

Expert Comment

by:Lukasz Lach
ID: 8045264
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:nestorua
ID: 8047692
HI,
Are both applications are done by you, or the target is any app with tedit on it?
Sincerely,
Nestorua.
0
 

Author Comment

by:Incendium
ID: 8047738
The target isn't done by me, and the target editbox is called edit
0
 
LVL 5

Expert Comment

by:Lukasz Lach
ID: 8047753
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
 

Expert Comment

by:CleanupPing
ID: 9317012
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
 
LVL 10

Expert Comment

by:kacor
ID: 9992718
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
 
LVL 5

Expert Comment

by:snehanshu
ID: 9999550
Hey Janos,
  Looks like a time-zone overlap!
  To me, it shows this Q was asked on March 1 :-)
  Merry Christmas!
...S
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month10 days, 7 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question