Question VBS SendKey in Edge

Mar 24, 2020
1
0
10
I'm trying to perfect a VBS script I made for use on an active webpage in Edge. The script is designed to allow me to automate a reservation completion at exactly 7:00. Then I get the choicest spot on hard to get spots. One quarter second late and I lose. I open Edge at bedtime. I sign in, go the reservation page and tab to the field next to the field that needs an Enter at about 6:57. During the night the every minute Tab/shift-Tab keeps me signed in. My final shift-Tab puts me at the important field at 6:57 for Enter. Then some more carefully placed clicks at 6:59:54. Most of this code works really well. If I get to the last nine lines without the script straying, it finishes perfectly. But usually in the middle of the night the Tabs shift and then my 6:57 "Enter" goes to the wrong place. I assume things happen to Windows in the middle of the night that can throw this off. Any ideas for this? Is there a way I can name the field I want the {Tab} and +{Tab} sent to?

Set WshShell = WScript.CreateObject("WScript.Shell")
Wscript.Sleep 20000 'Allow 20 seconds for browser focus

while ((Hour(now) <> 6) Or (Minute(now) <> 57)) 'toggle back and forth 2
'text boxes until 6:57. Keeps signed in status.
Wscript.Sleep 60000 'Check every 60 seconds
WshShell.SendKeys "{TAB}"
Wscript.Sleep 1550
WshShell.SendKeys "+{TAB}"

wend

Wscript.Sleep 5000 'wait 5 seconds

WshShell.SendKeys "+{TAB}" 'highlights "not a robot" checkbox.
Wscript.Sleep 5000 'wait 5 seconds
while ((Hour(now) <> 6) Or (Minute(now) <> 59) Or (Second(now) <> 54))
wscript.Sleep 1000 'Check every second
wend
Wscript.Sleep 1000
WshShell.SendKeys "{ENTER}" 'Robot checked
Wscript.Sleep 3070'Send another ENTER after 2520 milliseconds
WshShell.SendKeys "{ENTER}" 'Book Now