Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bringing Script MsgBox to foreground

1,390 views
Skip to first unread message

Csaba2000

unread,
Feb 25, 2005, 9:35:15 AM2/25/05
to
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"


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


Torgeir Bakken (MVP)

unread,
Feb 25, 2005, 9:46:41 AM2/25/05
to
Csaba2000 wrote:

> 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

Csaba2000

unread,
Feb 25, 2005, 10:05:39 AM2/25/05
to
Dang. I posted an easy one.
Thanks Torgeir. I hadn't even tried that because I thought I'd
read in a prior post that that wasn't working on Win2K and more
recent, but I see now that I misinterpreted what I read. Thanks
for your speedy reply,

Csaba

"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message
news:%23Xh9Ak0...@tk2msftngp13.phx.gbl...

Csaba2000

unread,
Feb 26, 2005, 7:26:53 AM2/26/05
to
OK, this is not the full story because (at least on my Win XP Pro,
SP 2 system) that MsgBox becomes visible, but it does not get focus
(I want that title bar to be blue). But I don't want to have to devote
an extra Alt+Shift+Tab keystroke to get to it. My fingers are
already overworked as it is.

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...

Michael Harris (MVP)

unread,
Feb 26, 2005, 2:04:31 PM2/26/05
to
Csaba2000 wrote:
> OK, this is not the full story because (at least on my Win XP Pro,
> SP 2 system) that MsgBox becomes visible, but it does not get focus
> (I want that title bar to be blue). But I don't want to have to
> devote an extra Alt+Shift+Tab keystroke to get to it. My fingers are
> already overworked as it is.


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


0 new messages