?
Solved

How can I start a messagebox in vbscript that gets the focus

Posted on 2011-05-04
2
Medium Priority
?
1,564 Views
Last Modified: 2012-05-11
please advise
0
Comment
Question by:itbabe
2 Comments
 
LVL 31

Assisted Solution

by:merowinger
merowinger earned 800 total points
ID: 35690274
This should do it

set objShell = CreateObject("Wscript.Shell")
msgbox "this is a text",, "this is the title"
objShell.AppActivate("this is the title")

Open in new window

0
 
LVL 13

Accepted Solution

by:
Daz_1234 earned 1200 total points
ID: 35696587
MsgBox has the facility built-in to be displayed 'System Modal', which means the message is on top of all other windows and will remain so until dismissed.  This is not quite the same as 'focus' since it is possible to interact with other applications on the desktop, i.e. another window can have focus, but the message box remains on-top.

The following will display a message box that will be displayed over all other windows:
MsgBox "Hello World.", vbSystemModal, "Message Title"

Open in new window


The 'vbSystemModal' part of the statement can be added to in order to add custom buttons.  The following code displays 'Yes' and 'No' options and stores the return in variable iBtn:
iBtn = MsgBox ("Hello World.", vbSystemModal + vbYesNo, "Message Title")
If iBtn = vbYes Then
   MsgBox "You clicked Yes"
Else
   MsgBox "You clicked No"
End If

Open in new window


And you can add an icon, here a yellow exclamation mark by adding vbExclamation:
iBtn = MsgBox ("Hello World.", vbSystemModal + vbYesNo + vbExclamation, "Message Title")
If iBtn = vbYes Then
   MsgBox "You clicked Yes"
Else
   MsgBox "You clicked No"
End If

Open in new window


If you look here:

http://msdn.microsoft.com/en-us/library/sfw6660x(v=vs.85).aspx

There are all the possible constants you can use in a MsgBox command.

Hope this helps,
Daz.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question