Windows 7 - msgbox on top

Asked By Amir Atary on 04-Mar-10 09:40 AM
Hi there,

I have a very simple script:

msgbox "This is a test"

How can i make the msgbox to appear on top?
Sometimes our users work with a few application at once, and they cannot see
the message, unless it will be on top.

Thank you
Amir :)




Pegasus [MVP] replied to Amir Atary on 04-Mar-10 10:18 AM
I am not aware of a method that is native to VB Scripts that will do this.
You could walk around the problem by using msg.exe to generate the box. It
seems it is always on top, even when generated by a background process.
Tom Lavedas replied to Amir Atary on 04-Mar-10 10:34 AM
see

Something like this is all I can come up with ...

sTitle =3D "Testing"
with createobject("wscript.shell")
if wsh.arguments.count =3D 0 then
.run wsh.fullname & " """ & wsh.scriptfullname & """ 2nd", 1,
false
do until .appactivate(sTitle): wsh.sleep : loop
else
msgbox "This is a test", vbOKOnly, sTitle
end if
end with

It recursively calls the originating script and uses AppActivate to
bring it into focus.  This does not mean it cannot be covered up
later.  That is. it is not an 'always on top' function.  That's
considered 'rude' and can only be accomplished by calls to the OS API,
as I understand.

Note that an instance of a script cannot use this approach on itself
because the Msgbox stops the script's flow until it is released.  It
can only be applied to another script or another instance of itself
(as I did above).
_____________________
Tom Lavedas