本帖最后由 半芯竹 于 2012-9-17 21:54 编辑
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
Local $InPut, $Lcbel, $Btn[2], $section, $i,$IniFile = 'Letter.ini'
$section = inireadsection($IniFile, 'letter')
$i = random(1, $section[0][0], 1)
$IniAddress = IniRead($IniFile, 'answer', $i, '')
$Gui = GUICreate ( "自订意英文单字", 300, 230)
$InPut = GUICtrlCreateInput("Enter Your Answer", 100, 15, 160, 20)
$Lcbel = GUICtrlCreateLabel($section[$i][1], 10, 20, 80, 35)
$Btn[0] = GUICtrlCreateButton ( "离开", 220, 180, 80, 50)
$Btn[1] = GUICtrlCreateButton ( "执行", 1, 180, 80, 50)
GUISetState (@SW_SHOW)
ControlFocus ( $GUI, "", $Btn[1]);将EXIT BOX 设为预设启动按钮
While 1
$NMsg = GUIGetMsg()
Switch $NMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Btn[0]
Exit
Case $Btn[1]
GetInput()
EndSwitch
WEnd
Func GetInput()
$Input_Get = GUICtrlRead($InPut)
If $Input_Get = $IniAddress Then
MsgBox(0, '恭喜', '您答对了~!')
$section = inireadsection($IniFile, 'letter')
$i = random(1, $section[0][0], 1)
$IniAddress = IniRead($IniFile, 'answer', $i, '')
GUICtrlSetData($Lcbel, $section[$i][1])
Else
MsgBox(0, '很可惜', $IniAddress)
$section = inireadsection($IniFile, 'letter')
$i = random(1, $section[0][0], 1)
$IniAddress = IniRead($IniFile, 'answer', $i, '')
GUICtrlSetData($Lcbel, $section[$i][1])
EndIf
EndFunc
|