Link to home
Start Free TrialLog in
Avatar of Armandito
Armandito

asked on

Controlling other programs thru vb5

I want to read and then change the url a web page in an iexplorer window.  For example, if the vb5 program reads that ie4 is at www.disney.com, I want the vb5 program to change it and take me to www.mtv.com
In other words, I want to modify an external program's properties and manipulate its methods.  I know a little about api calls.
Avatar of Armandito
Armandito

ASKER

Edited text of question
You can do it very easily. goto menu project -> reference then select the application name you want to control if application name is not there you can't control that app. for example controlling MS word you need Microsoft word 8.0 object library.
 if it is present then select it and press OK.
now you can useobjects define in library. i will give you example of word. add this code in command click event.

Dim WordApp As Word.Application
set WordApp=new Word.Application
WordApp.Activate
WordApp.Documents.Open "DocName"
WordApp.Documents.Close
WordApp.Quit

This code will start MSWord then open document given in paramtere to open method. then close that document and quit word. you can do other stuff also with that document
ASKER CERTIFIED SOLUTION
Avatar of Mirkwood
Mirkwood

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Mirkwood.  
I tried the code, and it almost worked.  I had to tweak it a bit, though.  The RTrim function wasn't having any effect on editval, for some reason.  I replaced RTrim with a small routine that returns the what it should.  In the end, the program does put text2.text in the url address window.
The shortcoming of your answer is in that the browser does not take you there.  In other words, the program does detect if I am at www.disney.com, and the program changes the address to www.mtv.com, but it does not open www.mtv.com.  It just changes the text of the url window.  So your answer was great, but only half of what I need.
I tried for a few hours last night to make the program send a message that simulates an ENTER keypress (after having changed the url text).  I tried to use some of the API functions, but it didn't work.  Maybe I'm doing it wrong.  
I need more help.
Thanks!
Armandito
Thanks Mirkwood.  
I tried the code, and it almost worked.  I had to tweak it a bit, though.  The RTrim function wasn't having any effect on editval, for some reason.  I replaced RTrim with a small routine that returns the what it should.  In the end, the program does put text2.text in the url address window.
The shortcoming of your answer is in that the browser does not take you there.  In other words, the program does detect if I am at www.disney.com, and the program changes the address to www.mtv.com, but it does not open www.mtv.com.  It just changes the text of the url window.  So your answer was great, but only half of what I need.
I tried for a few hours last night to make the program send a message that simulates an ENTER keypress (after having changed the url text).  I tried to use some of the API functions, but it didn't work.  Maybe I'm doing it wrong.  
I need more help.
Thanks!
Armandito
Do a setfocus before the sendkey

Declare Function SetFocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long

prevHwnd  = SetFocus (hwndedit)
Sendkeys here
SetFocus (prevHwnd)