Program Control, HELP appreciated.

This is a discussion on Program Control, HELP appreciated. within the Windows Programming forums, part of the Platform Specific Boards category; I am trying to start writing a program to control another program ( in a sense). e.g. i have one ...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    55

    Arrow Program Control, HELP appreciated.

    I am trying to start writing a program to control another program ( in a sense).

    e.g. i have one internet explorer window open, and my program has a button on it saying HOME, clicking it makes my internet explorer window go to it's homepage (so it thinks the user has pressed the home button on IE).

    Now im not sure how legal this is, but please, ANY help would be appreciated as to how i would go about STARTING to write this program (internet explorer was just an example).

    I have intermediate to advanced knowledge of C++.

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Every program will have its individual way of being controlled. It might expose a cross-process scripting interface. It might have a special command line interface. It might have a published set of messages it reacts to (Winamp did that). Or it might expose nothing, and you have to simulate mouse clicks and key presses to get it to do what you want.

    This is really special-case programming, and there is no general answer.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,544
    First you need one of the many "winspy" programs which allow you to trace which messages are sent to which application. Use this to figure out which event IE sends to itself in response to the home button being pressed. This you can then use in your application.

    Then use the win32 SendMessage() API to send that message to IE.
    Use some other win32 API calls to find out the appropriate handles to IE.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Oct 2006
    Posts
    55

    Arrow

    ah Ok. so:

    Code:
    	LRESULT SendMessage(HWND hWnd,
    			    UINT Msg,
    			    WPARAM wParam,
    			    LPARAM lParam);
    where it says hWnd would i have to find the handle to the HOME button?
    and where it says Msg would i put WM_LBUTTON?

    Also, how do i work out the handle of the button?(would it be via spy++?) And in what form would the handle appear?

    EDIT: possibly this should be moved to the Windows Programming section of the forums
    Last edited by Astra; 12-31-2006 at 04:13 PM.

  6. #6
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Internet explorer exports a lot of interfaces that can be used directly without workaround with sending messages to the buttons (buttons can be removed by the user for example)

    Maybe you should start with reading this http://msdn.microsoft.com/library/de...new_70_sdk.asp
    and this http://msdn.microsoft.com/library/de...node_entry.asp
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,544
    > where it says hWnd would i have to find the handle to the HOME button?
    No, it would be the window of IE itself, or some sub-window of IE which contain the home button.
    First you find the window containing IE itself, then possibly enumerate all the sub-windows of IE until you get to the one containing the HOME button.

    A better method (which I know nothing about) would be to use the Object Linking and Embedding (OLE) interface, which is specifically designed for inter-application communication.
    Here is an initial search to get you started.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  8. #8
    Registered User
    Join Date
    Oct 2006
    Posts
    55
    Thankyou.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  2. very weird .h problem
    By royuco77 in forum C++ Programming
    Replies: 1
    Last Post: 09-11-2005, 07:55 AM
  3. insufficient memory for tsr
    By manmohan in forum C Programming
    Replies: 8
    Last Post: 01-02-2004, 08:48 AM
  4. Replies: 2
    Last Post: 05-10-2002, 04:16 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21