I suggest you try to refer to the example below may help you to focus existing IE window and click the button on a webpage.
Sample VBScript:
Set shell = WScript.CreateObject("WScript.shell")
Dim objInstances, objIE, IE
Set objInstances = WScript.CreateObject("Shell.Application").windows
If objInstances.Count > 0 Then
For Each objIE In objInstances
If InStr(objIE.LocationURL,"https://Your_site_URL_here...") > 0 then '/// Modify the URL on this line...
Set IE = objIE
End if
Next
End If
shell.AppActivate ("Internet Explorer")
Wait IE, 2000
IE.document.getElementById("btn1").Click
Wait IE, 2000
'IE.Quit
Sub Wait(IE, ms)
Do
WScript.Sleep ms
Loop While IE.ReadyState < 4 And IE.Busy
End Sub
Further, you can try to understand the code example try to modify it based on your own requirements.
Thanks for your understanding.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…