|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
VBScript - Switching to specific IE7 tab
We currently have a login page in our local intranet that requires 5 textboxes filled in just to authenticate ppl as valid users.
This is a very secure server ![]() Being lazy, I wrote out a vbs script to log me in with a single click This portion works great, except for one thing... when I'm using IE7 and have several tabs open, my script won't give focus to the proper tab ![]() btw, I have a shortcut to this script from my quick launch toolbar The following works to give focus to the IE window ONLY if the desired tab is selected. Code:
Dim tabnumber,Found
tabnumber = 0
set shell = CreateObject("WScript.Shell")
Set objShell = CreateObject("Shell.Application")
Set objShellWindows = objShell.Windows
If objShellWindows.Count = 0 Then
Wscript.Echo "No browser windows are open at Yahoo"
Wscript.Quit
End If
Found = False
For i = 0 to objShellWindows.Count - 1
Set objIE = objShellWindows.Item(i)
strURL = objIE.LocationURL
If InStr(strURL, "http://www.yahoo.com") Then
Found = True
tabnumber = i
End If
Next
If Found Then
Wscript.Echo "You Already have a window open at Yahoo"
set objIE = objshellwindows.Item(tabnumber)
shell.AppActivate objIE.locationName
shell.sendkeys "% x" 'Maximize window
Else
Wscript.Echo "No browser windows are open at Yahoo"
End If
So my question is: How can I give focus to the proper tab on IE7 Any help is greatly appreciated ![]()
__________________
................... ASCII and ye shall receive .................. Knowledge is the only resource on earth that multiplies when shared Support the Shemzilla Project Powered by C# |
|
#2
|
||||
|
||||
|
what about shell.sendkeys with CTRL+Tab?
|
|
#3
|
||||
|
||||
|
Quote:
To my knowledge, the scripting model does not provide a way to interact with tabs directly. You have to remember that the current scripting model was developed before IE7. I've gone through the entire IE program with COM browsers and haven't been able to turn up an reliable way of doing this. ![]() Why not work with new windows instead of tabs?
__________________
Click the image if at any point you don't like my decision.Scripting problems? Windows questions? Ask the Windows Guru! |
|
#4
|
||||
|
||||
|
Quote:
well, you know the selected tab since its URL will be the window's URL - so change the tabs in loop until the window URL changes back to the first, and you know how many there are.. ![]() |
|
#5
|
||||
|
||||
|
Quote:
|
|
#6
|
||||
|
||||
|
Quote:
![]() |
|
#7
|
||||
|
||||
|
Thanks both for the feedback.
I'm at a training all week long and can only check the forums in the evenings at the hotel. Shadow, the script I posted will go thru the windows collection to see if it can find the given URL; therefore, it's probably be very close to give the tab focus. Is there any (command) I'm missing to give it focus then? Both your help is greatly appreciated. |
|
#8
|
||||
|
||||
|
Quote:
|
|
#9
|
||||
|
||||
|
Thanks Shadow, will give this a try and keep you all posted
![]() |
|
#10
|
||||
|