as I do to create a function in vbs that when clicking enter it switches two windows ie alt + tab

Asked

Viewed 382 times

0

that’s the code I’m using

Set objShell = CreateObject("WScript.Shell")

set Window = CreateObject("InternetExplorer.Application")

Window.RegisterAsBrowser = True
Window.MenuBar = True
Window.ToolBar = True
Window.AddressBar = True
Window.StatusBar = True
Window.FullScreen = False
Window.Resizable = True
Window.Visible = True
Window.Width = 850
Window.Height = 720




Window.Navigate("www.microsoft.com")

wscript.sleep 5000

Window.Navigate2 "www.globo.com",navflags

'while 1<>2

if objShell.SendKeys "{ENTER}" then
    wscript.sleep 2000
    objShell.SendKeys "^{TAB}"

end if

'wend

Making a mistake in the if. Can someone tell me what I’m doing wrong?

  • I don’t think the Sendkey method returns anything to be used in the IF as you are doing. Remove the IF out which should work.

  • how do I run {TAB} only when clicking enter?

  • you need to capture the event that occurs when the user presses the enter key. Within this routine, you run the TAB. However, it is necessary to see if there is how to do this via VBS.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.