Madza91 Posted May 10, 2008 Share Posted May 10, 2008 (edited) Hi all, i maded this example script and don't know how to control these buttons, i want to get $x and $y of button ($button[$x][$y]) ... #include <GuiConstants.au3> Global $button[100][100] Local $x, $y GuiCreate("MyGUI", 320, 350,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) For $x = 1 To 10 For $y = 1 To 10 $button[$x][$y] = GuiCtrlCreateButton(Random(1,50,1), $x*30-20, $y*30-20, 30, 30) Next Next $Label11 = GUICtrlCreateLabel("Pressed button ( x , y ) : ?", 10, 320, 300, 20, $SS_CENTER, BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE)) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button;??? GUICtrlSetData($Label11,$x) EndSelect WEnd Exit Edited May 10, 2008 by n3nE [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
rover Posted May 10, 2008 Share Posted May 10, 2008 #n3ne you could also use oneventmode with @GUI_CtrlId in a function #include <GuiConstants.au3> Global $button[100][100] Local $x, $y GUICreate("MyGUI", 320, 350, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) For $x = 1 To 10 For $y = 1 To 10 $button[$x][$y] = GUICtrlCreateButton(Random(1, 50, 1), $x * 30 - 20, $y * 30 - 20, 30, 30) Next Next $Label11 = GUICtrlCreateLabel("Pressed button ( x , y ) : ?", 10, 320, 300, 20, $SS_CENTER, BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE)) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $button[1][1] To $button[10][10] Beep(1000,5) GUICtrlSetData($Label11, GUICtrlRead($msg)) EndSwitch WEnd Exit I see fascists... Link to comment Share on other sites More sharing options...
Madza91 Posted May 10, 2008 Author Share Posted May 10, 2008 Oh, thank you [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
rover Posted May 10, 2008 Share Posted May 10, 2008 perhaps I misunderstood what you want do you want the x and y numbers from the array, not the random button number? here's a version in oneventmode expandcollapse popup#include <GuiConstants.au3> Opt("GUIOnEventMode",1) Global $button[100][100] Local $x, $y GUICreate("MyGUI", 320, 350, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) GUISetOnEvent($GUI_EVENT_CLOSE, "_Events") GUISetOnEvent($GUI_EVENT_MINIMIZE, "_Events") GUISetOnEvent($GUI_EVENT_RESTORE, "_Events") For $x = 1 To 10 For $y = 1 To 10 $button[$x][$y] = GUICtrlCreateButton(Random(1, 50, 1), $x * 30 - 20, $y * 30 - 20, 30, 30) GUICtrlSetOnEvent(-1, "_ButtonMatrix") Next Next $Label11 = GUICtrlCreateLabel("Pressed button ( x , y ) : ?", 10, 320, 300, 20, $SS_CENTER, BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE)) GUISetState() While 1 Sleep(10000) WEnd Func _ButtonMatrix() For $x = 1 To 10 For $y = 1 To 10 If $button[$x][$y] = @GUI_CtrlId Then GUICtrlSetData($Label11, "Pressed button: " & GUICtrlRead(@GUI_CtrlId) & " (" & $x &","& $y & ")") ExitLoop 2 EndIf Next Next Beep(1000,5) EndFunc Func _Events() Switch @GUI_CtrlId Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_MINIMIZE Case $GUI_EVENT_RESTORE Case Else EndSwitch Endfunc I see fascists... Link to comment Share on other sites More sharing options...
Madza91 Posted May 10, 2008 Author Share Posted May 10, 2008 I need x and y, and with your first script i may get that, but 2nd script is exactly what i want, thank you [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
rover Posted May 10, 2008 Share Posted May 10, 2008 I need x and y, and with your first script i may get that, but 2nd script is exactly what i want, thank you Your Welcome I see fascists... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now