Link to home
Start Free TrialLog in
Avatar of Lostie
Lostie

asked on

Better alternative to appactivate? (nice easy points for the experts!)

Hi Experts,

Before I outline the problem, I should point out that I'm using Attachmate Extra! basic, which is a cut-down version of Microsoft VB. Feel free to post any VB solutions though, I *may* be able to adapt and use them.

Right, I'm using Internet Explorer's DOM to automate some tasks on various websites, one of which is to do a google search. Code so far:

Dim IE as Object
Set IE=CreateObject("Internetexplorer.Application")
IE.visible=true
IE.navigate("http://www.google.co.uk/")
call IEwait
Appactivate "Google - Microsoft Internet Explorer"
x=ShowWindow(IE.hwnd, 3) '### Maximise window ###

Is there a way to use the IE.hwnd object to perform something like appactivate on it? I've already got it maximised using the IE.hwnd object as you can see above, but maximising does not bring it into focus hence the need for appactivate. I need to use this code on other websites whose windows will have changing titles instead of always being "Google - Microsoft Internet Explorer" - which is why I'd much rather use a better solution than appactivate. Anyone?
ASKER CERTIFIED SOLUTION
Avatar of Brian Mulder
Brian Mulder
Flag of Netherlands image

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
Avatar of Lostie
Lostie

ASKER

setfocus() didn't do what I wanted, but setforegroundwindow worked perfectly. Thanks again :-)
you're welcome, thanks for the grade :)
hmm... thanks,

Cd& is right and i'm trying to let his wisdom guide me and get those high point questions down it's not working yet :)

thanks Lostie and Lunchy too
I also had this problem - but as I was doing it in VBScript I couldnt use this above solution.
My solution uses AppActivate - but before it I change the title of the IE to a specific string:

  Set ie = WScript.Createobject("internetExplorer.application", "event_")
  ie.visible = true
  ie.document.title = "tmp123"
  WshShell.AppActivate("tmp123")