?
Solved

DELPI 5 + NEED HELP GUYS Sendin command to anotha applicaton

Posted on 2003-03-07
9
Medium Priority
?
237 Views
Last Modified: 2008-03-17
Guys, is it possible to send a command to anotha application? in Delphi...how?
and is it possible to trace changes in anotha application?
0
Comment
Question by:Kaspy
[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
9 Comments
 
LVL 3

Expert Comment

by:sfock
ID: 8090180
yes there are severeal possibilities to send commands to other applications.
You can make a api sendMessage if you have the handle of the other application
You can implement a COM interface in the other application.
You can open a TCP/IP or UDP socket on the other connection
a.s.f.
to determine what will be right fitting it would be nessesary to know what you are planning to do.

tracing changes in another application? I am not sure what you mean ...

0
 

Expert Comment

by:fadi980
ID: 8090442
you can exchange commands or data between two or more applications by using windows messages, but that should be prepared in the two applications, I mean if u send a message from one application to another, the recpient application should accept capturing messages...
or u can build a connection socket, and make a connection channel between the two aplications through the socket.
0
 

Author Comment

by:Kaspy
ID: 8092879
Hhmmm...guys thx again for ur attention....
i tried Postmessage ....but i constantly recieve error...
I can't prepare anotha application to recieve my commands...:( umm...i try to explain a bit more....like if i click on otha application n type anytin n press enter:) ...this leads to exucution or failure of the command...and i'm askin how can i make my program to do this?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:Kaspy
ID: 8092890
and by tracin..i meant...like if i finally sent command and it worked...program responds...n can my program get that respond somehow?
0
 

Author Comment

by:Kaspy
ID: 8092919
sendmessage(findwindow(nil,'name', "CTRL+N",0,0));
i get error here....tried without ""..tried everything:) doesn't work:(
0
 
LVL 3

Accepted Solution

by:
sfock earned 200 total points
ID: 8093343
well you are completly out of syntax:
1. " is not a valid character for quoting in object pascal you can use ' only
2. find window is declared as
HWND FindWindow(

    LPCTSTR lpClassName,     // pointer to class name
    LPCTSTR lpWindowName      // pointer to window name
   );    
 

Parameters

lpClassName

Points to a null-terminated string that specifies the class name or is an atom that identifies the class-name string. If this parameter is an atom, it must be a global atom created by a previous call to the GlobalAddAtom function. The atom, a 16-bit value, must be placed in the low-order word of lpClassName; the high-order word must be zero.

lpWindowName

Points to a null-terminated string that specifies the window name (the window's title). If this parameter is NULL, all window names match.

you try to pass 4 parameters into it

3. SendMessage is defined as
LRESULT SendMessage(

    HWND hWnd,     // handle of destination window
    UINT Msg,     // message to send
    WPARAM wParam,     // first message parameter
    LPARAM lParam      // second message parameter
   );    
 

Parameters

hWnd

Identifies the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows.

Msg

Specifies the message to be sent.

wParam

Specifies additional message-specific information.

lParam

Specifies additional message-specific information.

you pass only one parameter

To change the Capion of another application you could do the following:
var
  hWindow , hControl: Thandle;
  str: PChar;
begin
  hWindow := findwindow(nil,'NameOfTheForm');
  sendmessage(hWindow, WM_SETTEXT,0,Integer(StrPCopy(str,'my new Caption')));
end;

If you want to set any text in a control of this window, you need the Handle of the control, not of the form.

The easiest way to retrieve them is if you prepare the "other" application with reacting to custom user messages wich may return the needed control handle.

belonging the tracing : SendMessage gives you a result dependent on the message you sent.

in my example the SDK help says it returnes :
"The return value is TRUE if the text is set. It is FALSE (for an edit control), LB_ERRSPACE (for a list box), or CB_ERRSPACE (for a combo box) if insufficient space is available to set the text in the edit control. It is CB_ERR if this message is sent to a combo box without an edit control."

0
 

Expert Comment

by:CleanupPing
ID: 9447281
Kaspy:
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 3

Expert Comment

by:sfock
ID: 9449339
i do care ;-)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
In this post we will learn different types of Android Layout and some basics of an Android App.
Six Sigma Control Plans
Progress
Suggested Courses

752 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