Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
997 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 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...