Hello wonderfull people of DaniWeb

i need a little question answered can i manipulate another aplication?

here is what i want to do

Put a message on the screen if a program is detected as running i know how to detect it but i dont know how to send a text to it i have heard of a few way but wasnt sure

i know this is a kinda newbi question

i am only learning it and i havent touched on this yet but want to make something

many thanks
Matthew

Recommended Answers

All 7 Replies

It depends a lot on the app you're working with.

You can send keys to an app and act that way, however, its not always possible to be sure of the starting point.

Some apps have API calls defined which you can use to tell them things.

All i know is the Application was developed with Delphi

so if i can find the API call im might have a chance ?

thanks for you quick reply
it must have a API call as it has a browser in the middle of the application

i dont know if it can be done in C# or its a matter for unmanaged code i know a little about delphi if it needs to be done in that

Nothing means it has to have an API you can use, in fact, .net is one of the few things that gives you a better chance, but, not of controlling the app already running (unless you launch it)

The browser in the middle may have an API you can call as it is almost certainly an instance of IE (TWebbrowser) but, you cant necessarily get at it.

Why not just "send keys" what you want, and cut and paste etc

yeah its a ie browser so if i try to call the Twebbrowser hmm i will try that thanks for your advise as that is what i wanted to block really

here is my delphi code but need a little help

uses ActiveX;

procedure WBFindDialog(AWebBrowser: TWebbrowser) ;
const
  CGID_WebBrowser: TGUID = '{is this my Target?}';
  HTMLID_FIND = 1;

var
  CmdTarget : IOleCommandTarget;
  vaIn, vaOut: OleVariant;
  PtrGUID: PGUID;
begin
  New(PtrGUID) ;
  PtrGUID^ := CGID_WebBrowser;
  if AWebBrowser.Document <> nil then
    try
      AWebBrowser.Document.QueryInterface(IOleCommandTarget, CmdTarget) ;
      if CmdTarget <> nil then
        try
          CmdTarget.Exec(PtrGUID, HTMLID_FIND, 0, vaIn, vaOut) ;
        finally
          CmdTarget._Release;
        end;
    except
    end;
  Dispose(PtrGUID) ;
end;

procedure TForm1.FormCreate(Sender: TObject) ;
begin
  WebBrowser1.Navigate('http://www.web.com) ; 
end;

procedure TForm1.Button1Click(Sender: TObject) ;
begin
  WBFindDialog(WebBrowser1) ;
end;

Err, if its YOUR delphi app, why not just write some hooks for your c# app to call in to? Also why mix 2, if you want a delphi app why not combine what you now nee with what you have? and ask in a delphi forum?

i didnt think i could in C# can i use the same sort of code in c#?

and no its not my app im trying to hook into or i would just change the source of the app and edit my new code into it that would make things too easy

i was told that i couldnt do that in c# hence the delphi.

im new to programming in c# so i dont know too much in c# hence the stupid questions

Of course you can, people were doing that long before .net came around

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.