回复 10# afan
大概明白了用法,可以做计算器~
#include <GUIConstantsEx.au3>
Opt("GUICoordMode", 1)
GUICreate(" GUI 接收文件的输入控件", 320, 80, -1, -1)
$in1 = GUICtrlCreateInput("", 10, 5, 100, 20, 0x2000)
$in2 = GUICtrlCreateInput("", 10, 35, 100, 20, 0x0800)
$btn2 = GUICtrlCreateButton("+", 120, 30, 20, 20)
$btn3 = GUICtrlCreateButton("*", 145, 30, 20, 20)
$btn4 = GUICtrlCreateButton("-", 170, 30, 20, 20)
$btn5 = GUICtrlCreateButton("/", 195, 30, 20, 20)
$btn6 = GUICtrlCreateButton("C", 220, 30, 20, 20)
$btn = GUICtrlCreateButton("=", 245, 30, 20, 20)
Local $num[10], $x = 100
For $i = 1 To 9
$num[$i] = GUICtrlCreateButton($i, $x + 20 * $i, 5, 20, 20)
Next
GUISetState()
$msg = 0
While $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()
Switch $msg
Case $btn
GUICtrlSetData($in2, Execute(GUICtrlRead($in1)))
Case $btn6
GUICtrlSetData($in1, '')
Case $btn2, $btn3, $btn4, $btn5
GUICtrlSetData($in1, GUICtrlRead($in1) & GUICtrlRead($msg))
Case $num[1] To $num[9]
GUICtrlSetData($in1, GUICtrlRead($in1) & GUICtrlRead($msg))
EndSwitch
WEnd
|