Thread: Effecting outside programs (such as IE)

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    19

    Effecting outside programs (such as IE)

    How in C++ can you make a program that effects an outside sources, in this case my browser's address bar. What I'm looking for it to do is punch in an address which contains dates at the end and the program will cycle through all the dates and every 5 seconds update the browser at the next page.

    (by effects outside sources I mean it can type in data into another program)

    Note: If you post any code, please assume namespace std
    Last edited by turck3; 02-25-2008 at 02:31 PM.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Perhaps you could use shellexecute() to get the browser to display a page at a time.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    19
    That doesn't exactly help me much, I am a bit new to c++ so I really havn't done a whole lot beyond using classes... so something that is this low level to the operating system may require some example code.. I can write the body of my program but I may need someone to give me the bit that throws the characters (or strings) I want into the selected field.

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So make a search in google for "ShellExecute MSDN", and see if that helps.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Dec 2007
    Posts
    19
    will do, thanks

  6. #6
    Registered User
    Join Date
    Dec 2007
    Posts
    19
    That didn't help much, 5 pages of google got me nowhere, most of its help to other people and what is in tutorial form either goes way over my head or doesn't cover anything near what I want. It covers how to open files and close them and open find dialogues, but nowhere do I see how to output text into another program.

    I learn best by example, preferably with an explanation of what things are in the example.

    For the record: I am a begginner, and this is probably way out of my league, but I need it for a program that will greatly help with my everyday life. I havn't learned much farther than classes and vectors/maps/matrixes, and I don't program especially often.
    Last edited by turck3; 02-25-2008 at 04:37 PM.

  7. #7
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    Sounds like a job for javascript.

    Todd
    Mainframe assembler programmer by trade. C coder when I can.

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So, my suggestion was to actually NOT control what IE/Firefox/Opera or whatever other browser you like to use, but instead start a new one each time. This resolves the major headache of explaining to you, somehting that I with 20 years of programming experience would find a daunting task, and I doubt that you would understand after less than 50 posts. I don't actually know the EXACT answer, but the process of communicating with another application would involve finding the ID of the window of the browser, then sending the right messages to simulate that the user presses various buttons, moves the mouse around and such things. It is not a "quick 15 lines of code", but rather a major undertaking.

    Hence I suggested something that I think you would be capable of doing - much like someone asking "How do I build a Formula 1 racing car" with no car-building experience would probably be told to try to build a slightly less advanced form of car, such as a go-cart, first, before attempting something quite advanced.

    If you actually want to do what you suggest, I propose that you search the web for applications that are capable of doing "application control" for test/Q&A purpose and such. There are scripting applications that are capable of doing automated operations of other applications, and this would be the right solution if you are a beginner. Of course, these are probably not free [but you can't have everything ].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #9
    Registered User
    Join Date
    Dec 2007
    Posts
    19
    Ahhh now I see what you're getting at, OK, I figured out how to open a window:

    ShellExecute(NULL, "open", "www.google.com", "", "", SW_SHOW);

    Now how do I close it?
    Last edited by turck3; 02-25-2008 at 07:58 PM.

  10. #10
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    turck: this could be a good time for you to learn about libraries, I would look into libcurl if you are feeling adventurous.

    Closing it you would need to get the process handle and tell windows to close it, never done it before though.

  11. #11
    Registered User
    Join Date
    Dec 2007
    Posts
    19
    I'm looking around the web and It seems like create process has some sort of difference that allows you to close it later with CloseHandle.. im looking into this now.
    Last edited by turck3; 02-25-2008 at 08:34 PM.

  12. #12
    Registered User
    Join Date
    Dec 2007
    Posts
    19
    CreateProcess is a ***** so instead I was wondering if anyone could help me more than just pointing me in a direction eh? I'm looking to open an internet page and then just close it after some time (I have the timing bit, and I can open it with ShellExecute [but not anything else])

    This is a 5 second bit of code here, of this I am certain, won't one of you just give me the commands to open http://www.google.com and close it? That's not asking for much, and if you're already gonna post you might as well.

  13. #13
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    sendmessage() wm_quit wm_close

    3 things I found while googling, good luck !

  14. #14
    Registered User
    Join Date
    Dec 2007
    Posts
    19
    Alright, I'm still rather stuck, that involves using createprocess which is way over my head... could someone just write this for me.. I've been trying to do this for hours.. its getting a little tedious when it seems everyone either knows what their doing or can figure it out in 5 minutes...

  15. #15
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Avoid create process. Windows API is a pain.
    Use ShellExecute like you've done to open the window.
    You can use FindWindow to find the actual window later and send WM_CLOSE through SendMessage.
    Alternatively, you can use ShellExecuteEx, which can be a pain to get working right, and thus have it give you a handle to the process it starts. Then you could enumerate windows. And get the process's main window (somehow I think). And close the process (TerminateProcess), and so on.

    Complicated.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Starting programs
    By Molokai in forum C Programming
    Replies: 1
    Last Post: 04-16-2009, 10:10 AM
  2. Recommend upgrade path for C programs
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-22-2007, 07:32 AM
  3. Problem using java programs within C code
    By lemania in forum Linux Programming
    Replies: 1
    Last Post: 05-08-2005, 02:02 AM
  4. POSIX/DOS programs?
    By nickname_changed in forum C++ Programming
    Replies: 1
    Last Post: 02-28-2003, 05:42 AM
  5. executing c++ programs on the web
    By gulti01 in forum C++ Programming
    Replies: 4
    Last Post: 08-12-2002, 03:12 AM