回复 4# laomeng
已经记录下控件ID,当然它的背景色由你喜欢设成什么样了,这个自己试.
上个完整代码吧,我也不知道蛋老大具体指的什么地方.
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <File.au3>
Global $iNumber = 3 ;
Global $X = 380, $Y = 350
;Local $aLines
;If Not _FileReadToArray("wz.txt", $aLines) Then Exit
Local $aLines[11] = [10]
For $i = 1 To $aLines[0]
$aLines[$i] = '第' & $i & '个按钮'
Next
Global $aBut[$aLines[0]] ;按钮总数
Global $iNumber = 3 ;
Global $X = 100, $Y = 30
Opt('GUIOnEventMode', 1)
GUICreate('循环创建按钮', 350, 200)
GUISetOnEvent(-3, '_ButtonEvents')
For $i = 0 To UBound($aBut) -1
$aBut[$i] = GUICtrlCreateButton($aLines[$i+1], $X * Mod($i, $iNumber) + 25, $Y * Floor($i / $iNumber) + 25, 95, 28)
GUICtrlSetOnEvent(-1, '_ButtonEvents')
Next
GUISetState()
While 1
Sleep(250)
WEnd
Func _ButtonEvents()
Switch @GUI_CtrlId
Case -3
Exit
Case $aBut[0] To $aBut[UBound($aBut) - 1]
Local $seq = @GUI_CtrlId - $aBut[0] + 1
Local $sPath = 'c:\111\lable' & $seq & '\'
MsgBox(0, '运行:', $sPath & '*.exe')
;local $aFile = _FileListToArray('c:\111\lable' & $seq, '*.exe', 1)
;If @error Then ContinueLoop
;For $i = 1 To $aFile[0]
; Run($sPath & $aFile[$i])
;Next
EndSwitch
EndFunc
|