Consulting

Results 1 to 5 of 5

Thread: Cannot control the popup window

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Contributor
    Joined
    Nov 2009
    Posts
    114
    Location

    Cannot control the popup window

    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
    HTML Code:
    <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

  2. #2
    VBAX Contributor
    Joined
    Nov 2009
    Posts
    114
    Location
    Anyone can help? Thanks !

  3. #3
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    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
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  4. #4
    VBAX Contributor
    Joined
    Nov 2009
    Posts
    114
    Location
    Thanks how about popup

  5. #5
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    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
    '
    '
    '
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •