在彈出式消息框中顯示文本。
intButton = object.Popup(strText,[nSecondsToWait],[strTitle],[nType])
無論主機可執(zhí)行文件(WScript.exe 或 CScript.exe)是否運行,Popup 方法都顯示一個消息框。如果 nSecondsToWaitis 等于零(默認(rèn)值),彈出式消息框?qū)⒈3挚梢,除非用戶關(guān)閉它。如果 nSecondsToWaitis 大于零,則彈出式消息框在 nSecondsToWait 秒之后關(guān)閉。如果未提供參數(shù) strTitle,則在默認(rèn)情況下,彈出式消息框的標(biāo)題為 "Windows Script Host"(Windows 腳本宿主)。nType 的含義與 Microsoft Win32® 應(yīng)用程序編程接口的 MessageBox 函數(shù)的含義相同。下列各表顯示這些值及其含義。您可組合這些表中的值。
注意 要以 RTL 語言(如希伯來語或阿拉伯語)正確地顯示文本,請將十六進制的 hex &h00100000(十進制的 1048576)添加到 nType 參數(shù)中。
按鈕類型
值 | 說明 |
---|---|
0 | 顯示“確定”按鈕。 |
1 | 顯示“確定”和“取消”按鈕。 |
2 | 顯示“放棄”、“重試”和“忽略”按鈕。 |
3 | 顯示“是”、“否”和“取消”按鈕。 |
4 | 顯示“是”和“否”按鈕。 |
5 | 顯示“重試”和“取消”按鈕。 |
圖標(biāo)類型
值 | 說明 |
---|---|
16 | 顯示“停止標(biāo)記”圖標(biāo)。 |
32 | 顯示“問號”圖標(biāo)。 |
48 | 顯示“感嘆號”圖標(biāo)。 |
64 | 顯示“信息標(biāo)記”圖標(biāo)。 |
上面的兩個表中并未涵蓋 nType 的所有值。有關(guān)完整列表,請參閱 Microsoft Win32 文檔。
返回值 intButton 表示用戶單擊按鈕的次數(shù)。如果用戶在 nSecondsToWait 秒之前未單擊按鈕,則 intButton 設(shè)為 1。
值 | 說明 |
---|---|
1 | “確定”按鈕 |
2 | “取消”按鈕 |
3 | “放棄”按鈕 |
4 | “重試”按鈕 |
5 | “忽略”按鈕 |
6 | “是”按鈕 |
7 | “否”按鈕 |
下面的代碼生成簡單的彈出式窗口。
Dim WshShell, BtnCode
Set WshShell = WScript.CreateObject("WScript.Shell")
BtnCode = WshShell.Popup
("Do you feel alright?", 7, "Answer This Question:", 4 + 32)
Select Case BtnCode
case 6 WScript.Echo "Glad to hear you feel alright."
case 7 WScript.Echo "Hope you're feeling better soon."
case -1 WScript.Echo "Is there anybody out there?"
End Select
var WshShell = WScript.CreateObject("WScript.Shell");
var BtnCode = WshShell.Popup
("Do you feel alright?", 7, "Answer This Question:", 4 + 32);
switch(BtnCode) {
case 6:
WScript.Echo("Glad to hear you feel alright.");
break;
case 7:
WScript.Echo("Hope you're feeling better soon.");
break;
case -1:
WScript.Echo("Is there anybody out there?");
break;
}