MsgBox with autoit



我有这个:

Global $GUIAction = GUICreate("Selectionnez une Action", 345, 256, 1030, 0, -1, $WS_EX_TOPMOST)
Global $actionList = GUICtrlCreateList("", 104, 8, 137, 188, -1, BitAND($GUI_SS_DEFAULT_LIST, $LBS_SORT))
GUICtrlSetData(-1, "HAUT|BAS|GAUCHE|DROITE|POS PERSO|POS MAP|ZAAP|HAVRE-SAC|FLOOD|PAUSE|ECRIRE|COMBAT|COMMENTAIRE|END")
$btnSelectActionOK = GUICtrlCreateButton("&OK", 88, 225, 75, 25)
$btnSelectActionCancel = GUICtrlCreateButton("&Cancel", 184, 225, 75, 25)
GUISetState(@SW_SHOW)
GUIDelete($GUIListeConfigs)
MsgBox(64, "", GUICtrlRead($btnSelectActionOK))

如何检查是否按下了"确定"或"取消"?

THX

这里有两个简单的例子:

#include <MsgBoxConstants.au3>
Global $timeout = 3
example_1()
example_2()
Func example_1()
Local $returnValue = MsgBox($MB_YESNO, "Example", "Press a button :-)")
If $returnValue = $IDYES Then
MsgBox($MB_OK, "OK", "You pressed Yes!", $timeout)
Else
MsgBox($MB_OK, "Ok", "You pressed No!", $timeout)
EndIf
EndFunc   ;==>example_1
Func example_2()
Switch MsgBox($MB_YESNOCANCEL, "Example", "Press a button :-)")
Case $IDYES
MsgBox($MB_OK, "OK", "You pressed Yes!", $timeout)
Case $IDNO
MsgBox($MB_OK, "OK", "You pressed No!", $timeout)
Case $IDCANCEL
MsgBox($MB_OK, "Cancel", "You pressed Cancal!", $timeout)
EndSwitch
EndFunc   ;==>example_2

gui按钮示例(来自帮助文件)

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
Example()
; -------------------------------------------------------------------------------------
; Example - Press the button to see the value of the radio boxes
; The script also detects state changes (closed/minimized/timeouts, etc).
Func Example()
Opt("GUICoordMode", 1)
GUICreate("Radio Box Demo", 400, 280)
; Create the controls
Local $idButton_1 = GUICtrlCreateButton("B&utton 1", 30, 20, 120, 40)
GUICtrlCreateGroup("Group 1", 30, 90, 165, 160)
GUIStartGroup()
Local $idRadio_1 = GUICtrlCreateRadio("Radio &0", 50, 120, 70, 20)
GUICtrlCreateRadio("Radio &1", 50, 150, 60, 20)
Local $idRadio_3 = GUICtrlCreateRadio("Radio &2", 50, 180, 60, 20)
; Init our vars that we will use to keep track of GUI events
Local $iRadioVal1 = 0 ; We will assume 0 = first radio button selected, 2 = last button
; Show the GUI
GUISetState(@SW_SHOW)
Local $idMsg = 0
; In this message loop we use variables to keep track of changes to the radios, another
; way would be to use GUICtrlRead() at the end to read in the state of each control
While 1
$idMsg = GUIGetMsg()
Select
Case $idMsg = $GUI_EVENT_CLOSE
MsgBox($MB_SYSTEMMODAL, "", "Dialog was closed")
ExitLoop
Case $idMsg = $GUI_EVENT_MINIMIZE
MsgBox($MB_SYSTEMMODAL, "", "Dialog minimized", 2)
Case $idMsg = $GUI_EVENT_MAXIMIZE
MsgBox($MB_SYSTEMMODAL, "", "Dialog restored", 2)
Case $idMsg = $idButton_1
MsgBox($MB_SYSTEMMODAL, "", "Default button clicked:" & @CRLF & "Radio " & $iRadioVal1)
Case $idMsg >= $idRadio_1 And $idMsg <= $idRadio_3
$iRadioVal1 = $idMsg - $idRadio_1
EndSelect
WEnd
GUIDelete()
EndFunc   ;==>Example

最新更新