Vossen Posted June 17, 2008 Share Posted June 17, 2008 Hello. I have 100 bottons, named from 1x1 to 1x10 to 10x10... Is there anyway I can give them all the same function without having to writing a function to all of them. What I would like to avoid was...: While 1 Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $1x1 $mycode ... Case $1x10 $mycode ... Case $10x10 $mycode EndSwitch WEnd ... all the way through. Hope someone understands. // Vossen Link to comment Share on other sites More sharing options...
aslani Posted June 17, 2008 Share Posted June 17, 2008 (edited) Give your buttons the same variable and have that variable trigger the function. So instead of $1x1 - $10x10, just use $button on all of them. Problem solved. Edited June 17, 2008 by aslani [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version Link to comment Share on other sites More sharing options...
Kip Posted June 17, 2008 Share Posted June 17, 2008 (edited) Give your buttons the same variable and have that variable trigger the function. Problem solved.That will only work with the last created button. You'll have to do something like this: Global $Buttons[100] $Button[0] = guictrlcreatebutton("1x1",10,10,120,23) ... While 1 $nMsg = Guigetmsg() for $i = 0 to 100 if $nMsg = $Button[$i] Then ; your function endif next WEnd Edited June 17, 2008 by Kip MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
Vossen Posted June 17, 2008 Author Share Posted June 17, 2008 (edited) I see, minor problem with my explanation. Okay, the functions needs to be slightly different. I would like it to be like, when I press '5x2' the text should change from N to Y. Like this: NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN When I press '5x2' it should change to: NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN NYNNNNNNNN EDIT: Thanks Kip, will try that! Edited June 17, 2008 by Vossen Link to comment Share on other sites More sharing options...
Vossen Posted June 17, 2008 Author Share Posted June 17, 2008 (edited) That gives an error Kip $Button = GUICtrlCreateButton(...) $Button^ERROR Error: Expected a "=" operator in assignment statement. Any ideas? EDIT: Found the problem, Global $Buttons[100], my vars was $Button. Thanks for the help! Edited June 17, 2008 by Vossen Link to comment Share on other sites More sharing options...
Kip Posted June 17, 2008 Share Posted June 17, 2008 because it needs an element: $Button[0] ($Button[1], $Button[2], $Button[3], etc) MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
aslani Posted June 18, 2008 Share Posted June 18, 2008 (edited) I haven't tested this, but give it a shot While $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE ExitLoop For $i = 0 To 99 Step 1 If $msg = $button[$i] _cLabel(GUICtrlRead($button[$i]),$button[$i]) Next WEnd ... Func _cLabel($name,$btn) If $name = "N" Then GUICtrlSetData ($btn,"Y") If $name = "Y" Then GUICtrlSetData ($btn,"N") EndFunc Edited June 18, 2008 by aslani [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version 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