• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 238
  • Last Modified:

DELPI 5 + NEED HELP GUYS Sendin command to anotha applicaton

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
Kaspy
Asked:
Kaspy
1 Solution
 
sfockCommented:
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
 
fadi980Commented:
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
 
KaspyAuthor Commented:
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
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.

 
KaspyAuthor Commented:
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
 
KaspyAuthor Commented:
sendmessage(findwindow(nil,'name', "CTRL+N",0,0));
i get error here....tried without ""..tried everything:) doesn't work:(
0
 
sfockCommented:
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
 
CleanupPingCommented:
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
 
sfockCommented:
i do care ;-)
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now