Discussion:
Outputting text in Internet Explorer
(too old to reply)
Jay
2007-08-01 16:49:36 UTC
Permalink
I am trying to write a program that will open an instance of Internet Explorer then will visit different sites that I have already in a database. I am using the code below to open Internet Explorer, but I can not figure what code I need to paste the different links into the address bar. Also, how do I get my program to output text to wherever the current cursor position is? If I could do this, the program would be able to TAB around until it found the right box to enter the text into.

Thanks for all of your help.

WinExec("C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE",SW_MAXIMIZE);
Remy Lebeau (TeamB)
2007-08-01 16:59:16 UTC
Permalink
Post by Jay
I am trying to write a program that will open an instance of
Internet Explorer then will visit different sites that I have
already in a database. I am using the code below to open
Internet Explorer, but I can not figure what code I need to
paste the different links into the address bar.
Rather than running the .exe directly (especially since IEXPLORE.EXE may not
be the user's browser of choice), you should run the actual URL by itself
and let the OS decide how best to handle it:

ShellExecute(NULL, "open", "http://address.com", NULL, NULL,
SW_SHOWMAXIMIZED);
Post by Jay
Also, how do I get my program to output text to wherever
the current cursor position is? If I could do this, the program
would be able to TAB around until it found the right box to
enter the text into.
In the case of IE specifically, you can access the browser's page's
IHTMLDocument2 DOM interface, and then jump directly to the desired edit box
and update it as needed.


Gambit
Jay
2007-08-01 18:48:00 UTC
Permalink
Thanks Gambit,

I used the code that you gave me, and it worked wonderfully. Now I can just pass it the different web addresses that it will need, and it can visit them all. Awesome!

As for the second item you mentioned "In the case of IE specifically, you can access the browser's page's IHTMLDocument2 DOM interface, and then jump directly to the desired edit box and update it as needed." I am totally lost. I'm pretty sure what you said was right, I just have no idea how to do it. A couple of questions:

- What is a DOM interface, and how do I access it?
- How do I find out what the different edit boxes, etc... are called in the DOM interface?

Thanks again for your help!
Remy Lebeau (TeamB)
2007-08-01 19:35:08 UTC
Permalink
Post by Jay
- What is a DOM interface
DOM = Document Object Model
Post by Jay
how do I access it?
How do I find out what the different edit boxes, etc... are called in the
DOM interface?

Please go to http://www.deja.com and search through the newsgroup archives.



Gambit
Jay
2007-08-01 20:15:46 UTC
Permalink
Thanks for all the help. I looked through the databases, but unfortunately, most of everything there looked to be over my head. Maybe I can attack this from a different angle. Is there a way to, once the browser is open, to make my programs output different keystrokes (Tab, Enter, letters and numbers) to make the cursor navigate around the browser?

For example, if I am using my keyboard, and I open www.yahoo.com, the cursor is in the search field, if I press TAB, the focus is on the search button. If I hit the enter key, the search process begins. Is there a way to do this using the "Virtual Keys" in Builder? This way my program would bypass the keyboard, and in essence, become a 'virtual keyboard'?

I'm not sure if that makes any sense or not, but it is the best way I can explain it. Any suggestions?

Thank you
Remy Lebeau (TeamB)
2007-08-01 21:10:16 UTC
Permalink
Post by Jay
Is there a way to, once the browser is open, to make my
programs output different keystrokes (Tab, Enter, letters
and numbers) to make the cursor navigate around the
browser?
Not easily.

The simpliest way to do it is to just blindly issue keystrokes with the
keydb_event() function. But then you lose control over where those
keystrokes get delivered. If you want them to be directed to the browser
window specifically, then you need direct access to the HWND for it so you
can send WM_CHAR and WM_KEYUP/DOWN messages to it. You will have to hunt
for that HWND manually before you can then do anything with it, though.

Another option would be to not run the browser separately. If you use the
TCppWebBrowser component (which is a wrapper around IE's ActiveX control),
then you have direct access to a browser window as you are hosting in your
own application itself, and can thus manipulate it as needed. But then you
are no longer using the user's default browser (which may not be IE).
Post by Jay
I open www.yahoo.com, the cursor is in the search field
Not always. That depends on whether the user has scripting enabled or not.
Even then, I find that many times, it still doesn't work very often. I
usually have to click on the field manually in order to put focus on it.
Post by Jay
If I hit the enter key, the search process begins.
You don't have to focus the search button in order to submit the search
form. Pressing Enter on any of the edit fields will do that. Or, if you
are using the IHTMLDocument2 interface, then you can retreive the
IHTMLFormElement interface for the search form and then call its submit()
method.


Gambit
Jay
2007-08-01 22:28:32 UTC
Permalink
Wow, it seems that I have a lot of work ahead of me. I may try to go the way of creating my own browser, though to be quite honest, it sounds like a very daunting task. Do you know of any place online that may have information on it?

Also, you mentioned keydb_event() function, but I can't seem to find that anywhere in Builder (version 6). The only thing that I found was a separate database engine called keydb, but I couldn't find anywhere to download it, and the companies home page (www.keydb.com)was gone.

Thanks,
Jay
Remy Lebeau (TeamB)
2007-08-02 18:47:05 UTC
Permalink
Post by Jay
you mentioned keydb_event() function, but I can't seem
to find that anywhere in Builder (version 6).
Look in Microsoft's documentation, as it is a Win32 API function, not a VCL
function.


Gambit
Jonathan Benedicto
2007-08-02 19:12:37 UTC
Permalink
Post by Jay
Also, you mentioned keydb_event() function, but I can't seem to find that
anywhere in Builder (version 6). The only thing that I found was a
separate
database engine called keydb, but I couldn't find anywhere to download it,
and the companies home page (www.keydb.com)was gone.
Remy had a typo. He meant keybd_event.

HTH

Jon

Continue reading on narkive:
Loading...