PDA

View Full Version : [SOLVED:] Cannot control the popup window



clif
06-10-2021, 10:17 PM
Sub abc()



Application.ScreenUpdating = False

Shell "wscript.exe ""C:\Users\abc\Desktop\abc.vbs"""




Set objShellApp = CreateObject("Shell.Application")
For Each objWindow In objShellApp.Windows
Debug.Print objWindow.LocationName
If LCase(objWindow.LocationName) = LCase("abc") Then


Debug.Print objWindow.LocationURL
If objWindow.LocationURL = "http://abc.aspx" Then

Set objIe = objWindow
GoTo Label8:



Else


GoTo Label9:
End If


Label9:
End If
Next


Label8:

objIe.document.all("button_Confirm").Click


'popup window appear all code cannot be run








<input name="btn$button_Confirm" id="button_Confirm" style="font-weight: bold;" onclick="return confirm('Checked &amp; Confirmed?');WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;button_Confirm&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" type="submit" value="Check &amp; Confirm (Account)">




abc.vbs



Set wshShell = CreateObject("WScript.Shell")


Do


ret = wshShell.AppActivate("網頁訊息")


Loop Until ret = True


WScript.Sleep 5000
ret = wshShell.AppActivate("網頁訊息")
If ret = True Then
ret = wshSheel.AppActivate("網頁訊息")
WScript.Sleep 1000
wshShell.Sendkeys "{enter}"
End If


WScript.Sleep 500

clif
06-11-2021, 10:22 AM
Anyone can help? Thanks !

SamT
06-11-2021, 02:07 PM
First: Replace "GoTo Label18:" with "Exit For". Then Delete "Else... GoTo Label19:" Both Line-labels will be ignored, but I would delete them for neatness sake

BTW, do not use a colon after "GoTo (Line-label)"


For Each objWindow In objShellApp.Windows
If LCase(objWindow.LocationName) = "abc" Then
If objWindow.LocationURL = "http://abc.aspx" Then
Set objIe = objWindow
Exit For
End If
End If
Next

objIe.document.all("button_Confirm").Click

clif
06-11-2021, 06:40 PM
Thanks how about popup

SamT
06-12-2021, 09:33 AM
The "Pop-Up" says there is an issue with the preceding code

I'm only looking at things I do know about. I've had trouble with using doublequotes in quoted strings so I started doing

Const DQ as String = Chr(34)

Also try

If Not Shell "C:\Users\abc\Desktop\abc.vbs" Then
MsgBox "Can't find or can't run abc.vbs, Check the Path is correct"
End
End If
'
'
'