Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
798 views
in Technique[技术] by (71.8m points)

vbscript Get OK focus on back window after closing front window

I'm trying to set focus to the OK button so that the user can press Enter after being able to do the same with the No button on the front window.

![enter image description here

So, I have the No button on the first (VBScript) window focused so the user can hit Enter to close it. After they do this, I'm able to set focus to the back (IE) window, but, even though it looks like the OK button already has focus, you can't hit the Enter key to close that window.

Here's what I have:

[other code irrelevant to the question which builds the objIE window]

objIE.Visible = True   'Set visible to True to see the IE window

Disp_Respo = MsgBox("Do you want to see the full details of this group record?", vbYesNo + vbQuestion + vbSystemModal + vbDefaultButton2, "Full Details")
    
If Disp_Respo = vbYes Then
    objIE.Quit    'If the user wants to see full details, close the current IE window
    Set objIE = Nothing
    Call Expand_Display(GrpType)    'Function that gathers additional details, then creates new IE window
    Exit Function
Else
    WShell.AppActivate Win_Title    'Activate the current IE window so user can review data, then click OK to close
End If

objIE.document.all.OK.Focus    'In earlier code for display, OK button was created with the ID "OK". Using this to set focus to IE window again
            
Do Until FormExit = "GO"    'Keep the IE window visible until the OK button is clicked
   If objIE.document.all.OK.Value = 1 Then    'If OK button value is set to 1 after being clicked, close the window
        objIE.Quit
        SetEverythingToNothing
        Exit Function
   End If
Loop

I hope this is enough to go on. If not, please let me know so I can clarify.

question from:https://stackoverflow.com/questions/65909626/vbscript-get-ok-focus-on-back-window-after-closing-front-window

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...