Set oIE=CreateObject("InternetExplorer.Application")
oIE.visible=true
oIE.Navigate("about:blank")
Do Until oIE.ReadyState = 4 : Wscript.Sleep 100 : Loop
oIE.quit
CreateObject("WScript.Shell").AppActivate("about:blank")
MsgBox "I want to be in the Foreground"
If the AppActivate call is there then the MsgBox in the last
line will not be in the foreground. This is regardless of which
side of AppActivate that oIE.quit is on. Furthermore, if the
oIE.quit call is commented out, then after the script has run
and I dismiss IE's window with a Ctrl+W, the message box
is still not in the foreground.
Since my script was initiated as a foreground app, isn't there
any way I can reclaim MsgBox privilages (without API calls)?
Thanks,
Csaba Gabor from Vienna
on Win XP Pro, SP 2
> I'd like to know if there is a way to bring my VBScript's MsgBox
> to the foreground once I have used AppActivate:
>
> Set oIE=CreateObject("InternetExplorer.Application")
> oIE.visible=true
> oIE.Navigate("about:blank")
> Do Until oIE.ReadyState = 4 : Wscript.Sleep 100 : Loop
> oIE.quit
> CreateObject("WScript.Shell").AppActivate("about:blank")
> MsgBox "I want to be in the Foreground"
Hi
MsgBox "I want to be in the Foreground", vbExclamation + vbSystemModal
--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx
Csaba
"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message
news:%23Xh9Ak0...@tk2msftngp13.phx.gbl...
I've checked out:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/dialogboxes/dialogboxreference/dialogboxfunctions/messagebox.asp
and couldn't get any combination of flags to work for me.
Then I went to
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsmthpopup.asp
to check out the details for CreateObject("WScript.Shell").Popup
This page leaves something to be desired saying something to the effect of:
We're not sure about all the details. But there's supposed to be
another page somewhere on the microsoft site that can clue you in
(The exact, linkless words they use are:
The previous two tables do not cover all values for nType.
For a complete list, see the Microsoft Win32 documentation).
Undaunted, I continued to the interesting
http://www.geocities.com/SiliconValley/Ridge/1057/api/apim.htm and
http://vbnet.mvps.org/index.html?code/comdlg/messageboxex.htm
Thus armed, I cycled through many combinations and finally found:
CreateObject("WScript.Shell").Popup "I want to have Focus, too", _
0, "Demo", &H1 + &H30 + &H20000
which produces a visible Popup in the foreground, focus and all.
Note that using the &H20000 leads to the system menu icon (mini
icon at top left of the popup) not being shown, but this menu can
be activated by means of Alt+Space or a right click on the title bar
of the popup.
Csaba Gabor from Vienna
"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message
news:%23Xh9Ak0...@tk2msftngp13.phx.gbl...
Whether or not an application (represented by your script's display of a
system modal message box) can steal the focus from another app's window is a
function of the OS from W2K and up. If you install TweakUI, you can control
that behavior to some degree. I don't have TweakUI installed on this box, so
I can't tell you which TweakUI tab the option is on.
--
Michael Harris
Microsoft MVP Scripting
http://maps.google.com/maps?q=Sammamish%20WA%20US