dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Control another program's flow ...?

  1. #1
    Join Date
    Aug 2009
    Posts
    3

    Control another program's flow ...?

    Hello,

    I'd like to know how if it's possible to write a program to 'control' another program.

    For instance, let's say i'd like to open Word, change the font, and insert some text. Is there any way to 'get a hook' on another running program's resource, and trigger events like keystrokes or a mouse click ?

    Thank you!!

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Control another program's flow ...?

    Welcome to the forum

    yes it is very much possible. I would take an example of Word itself. MS Word exposes an COM Object Library that you can use to automate MS Word application. You can all that you have mentioned and much more.

    If you want to automate some other program that not expose an object library, you will have to rely on SendMessage API. Do a search here and you will numerous examples of how to use SendMessage to control another application.

  3. #3
    Join Date
    Aug 2009
    Posts
    3

    Smile Re: Control another program's flow ...?

    Thanks a lot for your reply..!!. I'll take a look on SendMessage.

  4. #4
    Join Date
    Aug 2009
    Posts
    3

    Re: Control another program's flow ...?

    Sorry to bother here again...

    SendKeys would work great for what i need to do. However i'm having trouble opening a 3rd party program which is minimized to tray.

    I've been testing the MS API... ShowWindow and SetForegroundWindow are both not working.

    I'm using it this way...


    Process[] processes = Process.GetProcessesByName("test");

    foreach (Process p in processes) {

    ShowWindow(p.Handle, 5);
    }


    Also tested with p.MainWindowHandle... any idea?

    Thanks a lot in advance =D

  5. #5
    Join Date
    May 2009
    Location
    Bengaluru, India
    Posts
    435

    Re: Control another program's flow ...?

    There might be some other APIS to do a search which are there in the tray minimized. Just do a search you may get a API related to that ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)