#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#Include <Array.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Global $Button[13], $j = 0, $array[1]
$Form1 = GUICreate("密码键盘", 133, 165, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "_ButtonXY")
$b = Random(0, 9, 1)
_ArrayAdd($array, $b)
_ArrayDelete($array, 0)
For $i = 1 To 9
Do
$b = Random(0, 9, 1)
$Index = _ArraySearch($array, $b)
Until $Index = -1
_ArrayAdd($array, $b)
Next
Dim $x = 1, $y = 1
For $i = 1 To 12
Select
Case $i <= 10
$arrayButton = $array[$i - 1]
Case $i = 11
$arrayButton = "退格"
Case $i = 12
$arrayButton = "清除"
EndSelect
$Button[$i] = GUICtrlCreateButton($arrayButton, ($x * 42) - 36, ($y * 38) - 30, 38, 35)
GUICtrlSetOnEvent($Button[$i], "_ButtonXY")
$x += 1
If $x = 4 Then
$x = 1
Switch $y
Case 1
$y = 2
Case 2
$y = 3
Case 3
$y = 4
EndSwitch
EndIf
Next
GUISetState()
While 1
Sleep(1000)
WEnd
Func _ButtonXY()
Switch @GUI_CtrlId
Case $Button[12]
MsgBox(4096, "", "")
Case $Button[11]
Exit
Case $GUI_EVENT_CLOSE
Exit
Case Else
MsgBox(4096, "", GUICtrlRead(@GUI_CtrlId))
EndSwitch
EndFunc
写的乱七八糟的,但大体实现了楼主想要的效果 |