[RESOLVED] [VB6] Switch to another active window.
I need to make a button that will switch the active window to a web browser that will always have the same title. I've been google'ing for it and have searched this forum but cant find an answer anywhere.
Does anyone know a sample of code that will achieve this?
Regards
PsYiOn
Re: [VB6] Switch to another active window.
Ooh any easy one...
AppActivate "{Title}"
Re: [VB6] Switch to another active window.
Or for a fancy version that activates from partial title...
http://www.freevbcode.com/ShowCode.asp?ID=526
Re: [VB6] Switch to another active window.
Thanks for the speedy reply, I used the non fancy version as my window name will never change but i have ran into a problem. If the user does not already have that window open then they get a runtime error. Is there a way to check its open before trying to activate it?
Re: [VB6] Switch to another active window.
Well, you could either use the EnumWindows API to check the window exists first as per the fancy version, or the quick and dirty way would be to catch the error eg...
On Error Goto ErrHandler
AppActive "{Title}"
Exit Sub
ErrHandler:
Msgbox "Doh!"
Re: [VB6] Switch to another active window.
Brilliant works well!! somthing worth noting is the non fancy code also pick up partial titles. I had it look for [VB6] and it found this window fine.
Thanks for the help :)
Re: [RESOLVED] [VB6] Switch to another active window.
Cool! Never knew that! Also, for reference, theres a FindWindow API. Saves the hassle of EnumWindows.