nitekram Posted March 13, 2006 Share Posted March 13, 2006 (edited) I had asked this question in another post as a sub question and have not received any feedback. I was wondering if I call the function from GUICtrlSetOnEvent ( controlID, "function" ) - can I send a Variable. Everytime I have tried I have received an ERROR. I guess I need the right syntax - does anyone know it? Edited March 13, 2006 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
Valuater Posted March 13, 2006 Share Posted March 13, 2006 (edited) Opt("GUIOnEventMode", 1) ; Change to OnEvent mode guictrlcreateButton GUICtrlSetOnEvent ( -1, "function1" ) while wend Func function1() msgbox(this is how ya do it) EndFunc 8) Edited March 13, 2006 by Valuater Link to comment Share on other sites More sharing options...
nitekram Posted March 13, 2006 Author Share Posted March 13, 2006 Opt("GUIOnEventMode", 1) ; Change to OnEvent mode guictrlcreateButton GUICtrlSetOnEvent ( -1, "function1" ) while wend Func function1() msgbox(this is how ya do it) EndFunc 8) I have done that - but what I would like to be able to do is sent the function a variable - I.E. Opt("GUIOnEventMode", 1) ; Change to OnEvent mode guictrlcreateButton GUICtrlSetOnEvent ( -1, "function1($testvariable)" ) while wend Func function1($testvariable) msgbox(this is how ya do it) EndFunc It may not be possible and then I would have to create a GLOBAL Variable - I just want to know if anyone has done it as I was not able to find an example anywhere. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 13, 2006 Moderators Share Posted March 13, 2006 Global $testvariable = 'This is one way to do it' Opt("GUIOnEventMode", 1); Change to OnEvent mode $main = GUICreate('Testing') $buttton = GUICtrlCreateButton('test', 10, 10) GUICtrlSetOnEvent ($buttton, "CollectParameter" ) GUISetState() While 1 Sleep(100) wend Func CollectParameter() function1($testvariable) EndFunc Func function1($f_FunctionParameter) MsgBox(0, 'Test', $f_FunctionParameter) EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
nitekram Posted March 13, 2006 Author Share Posted March 13, 2006 Global $testvariable = 'This is one way to do it' Opt("GUIOnEventMode", 1); Change to OnEvent mode $main = GUICreate('Testing') $buttton = GUICtrlCreateButton('test', 10, 10) GUICtrlSetOnEvent ($buttton, "CollectParameter" ) GUISetState() While 1 Sleep(100) wend Func CollectParameter() function1($testvariable) EndFunc Func function1($f_FunctionParameter) MsgBox(0, 'Test', $f_FunctionParameter) EndFunc Thats how it is done - you guys are the best. Thanks SmOke_N 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 13, 2006 Moderators Share Posted March 13, 2006 (edited) This is another way too:Global $buttton[2][2] Opt("GUIOnEventMode", 1); Change to OnEvent mode $main = GUICreate('Testing') $buttton[0][1] = GUICtrlCreateButton('test', 10, 10) $buttton[1][1] = 'This is another way' GUICtrlSetOnEvent ($buttton[0][1], "MyFunction") GUISetState() While 1 Sleep(100) wend Func MyFunction() If @GUI_CtrlId = $buttton[0][1] Then MsgBox(0, 'Testing', $buttton[1][1]) EndIf EndFuncEdit:Couldn't remember where I had seen this method... But I found it:http://www.autoitscript.com/forum/index.ph...ndpost&p=137751 Edited March 13, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
nitekram Posted March 13, 2006 Author Share Posted March 13, 2006 (edited) This is another way too:Global $buttton[2][2] Opt("GUIOnEventMode", 1); Change to OnEvent mode $main = GUICreate('Testing') $buttton[0][1] = GUICtrlCreateButton('test', 10, 10) $buttton[1][1] = 'This is another way' GUICtrlSetOnEvent ($buttton[0][1], "MyFunction") GUISetState() While 1 Sleep(100) wend Func MyFunction() If @GUI_CtrlId = $buttton[0][1] Then MsgBox(0, 'Testing', $buttton[1][1]) EndIf EndFunc Edit: Couldn't remember where I had seen this method... But I found it: http://www.autoitscript.com/forum/index.ph...ndpost&p=137751 *****EDIT I looked around for a while trying to find any info on it - thanks for your help That works too - would you be able to look at my post @ http://www.autoitscript.com/forum/index.ph...89entry160589 and see what I have done and see what code is not needed - I spent all weekend on it - still very new to programming, and I would like someone to tell me what I should not have done. The last post is the most resent program - believe me it is very sloppy - Edited March 13, 2006 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 13, 2006 Moderators Share Posted March 13, 2006 *****EDITI looked around for a while trying to find any info on it - thanks for your helpThat works too - would you be able to look at my post @ http://www.autoitscript.com/forum/index.ph...89entry160589and see what I have done and see what code is not needed - I spent all weekend on it - still very new to programming, and I would like someone to tell me what I should not have done. The last post is the most resent program - believe me it is very sloppy -Yeah, I can't make heads or tails of it... why don't you clean it up first... and comment what you would like to do and where. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Valuater Posted March 13, 2006 Share Posted March 13, 2006 This is another way too:Global $buttton[2][2] Opt("GUIOnEventMode", 1); Change to OnEvent mode $main = GUICreate('Testing') $buttton[0][1] = GUICtrlCreateButton('test', 10, 10) $buttton[1][1] = 'This is another way' GUICtrlSetOnEvent ($buttton[0][1], "MyFunction") GUISetState() While 1 Sleep(100) wend Func MyFunction() If @GUI_CtrlId = $buttton[0][1] Then MsgBox(0, 'Testing', $buttton[1][1]) EndIf EndFunc Edit: Couldn't remember where I had seen this method... But I found it: http://www.autoitscript.com/forum/index.ph...ndpost&p=137751 why ... the two dimension array?? Global $buttton[3] Opt("GUIOnEventMode", 1); Change to OnEvent mode $main = GUICreate('Testing') $buttton[1] = GUICtrlCreateButton('test', 10, 10) $buttton[2] = 'This is another way' GUICtrlSetOnEvent ($buttton[1], "MyFunction") GUISetState() While 1 Sleep(100) wend Func MyFunction() If @GUI_CtrlId = $buttton[1] Then MsgBox(0, 'Testing', $buttton[2]) EndIf EndFunc 8) Link to comment Share on other sites More sharing options...
nitekram Posted March 13, 2006 Author Share Posted March 13, 2006 (edited) Yeah, I can't make heads or tails of it... why don't you clean it up first... and comment what you would like to do and where. OK - I cleaned it up as best I can - sorry for posting here as well - I am not sure if I should have cleaned the first one up or this one - let me know and I will clean the other one up. expandcollapse popup; create 2 gui's and have one main and one dummy - the program should not end until the main gui is closed ; after closing the dummy gui the user should be albe to continue with the main gui ; QUESTION - because I am not a programmer - I am not sure if all my code is needed - is there a better way to write this code? ; I do not need the dummy window to be open (hidden) once the dummy gui is closed ; I want the main gui to remain open throughout the life of the program #include <GUIConstants.au3> Global $test = 1, $dummywindow, $dummyActive = 1 Opt("GUIOnEventMode", 1); Change to OnEvent mode ; Create main GUI - not to be deleted until top right X is clicked $mainwindow = GUICreate("Hello World", 200, 100) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUICtrlCreateLabel("Hello world! How are you?", 30, 10) $okbutton = GUICtrlCreateButton("OK", 70, 50, 60) GUICtrlSetOnEvent($okbutton, "OKButton") ; Create dummy - that can be deleted when hitting top right X but does not close main gui CreateDummyWindow($dummyActive) While 1 Sleep(1000); Idle around WEnd Func CreateDummyWindow($dummyActive) $dummywindow = GUICreate("Dummy window for testing ", 200, 100) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetState(@SW_SHOW) If $dummyActive = 1 Then GUISwitch($mainwindow) GUISetState(@SW_SHOW) WinActivate($mainwindow) EndIf EndFunc ;==>CreateDummyWindow ; If OK button was pressed should make dummy window visable Func OKButton() If Not WinActivate($dummywindow) Then $dummyActive = 0 CreateDummyWindow($dummyActive) ElseIf @GUI_WinHandle = $mainwindow Then GUISwitch($dummywindow) GUISetState(@SW_SHOW) WinActivate($dummywindow) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") EndIf EndFunc ;==>OKButton ; I only want the dummy gui to close not the main gui Func CLOSEClicked() If @GUI_WinHandle = $mainwindow Then MsgBox(0, "GUI Event", "You clicked CLOSE in the main window! Exiting...") Exit ElseIf @GUI_WinHandle = $dummywindow Then MsgBox('', "GUI Event", "@GUI_WINHANDLE = Dummy window for testing ") GUISetState(@SW_HIDE) GUIDelete(@GUI_WinHandle) GUISwitch($mainwindow) GUISetState(@SW_SHOW) WinActivate($mainwindow) EndIf EndFunc ;==>CLOSEClicked *****EDIT did not have ending code tage Edited March 13, 2006 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 13, 2006 Moderators Share Posted March 13, 2006 why ... the two dimension array?? Global $buttton[3] Opt("GUIOnEventMode", 1); Change to OnEvent mode $main = GUICreate('Testing') $buttton[1] = GUICtrlCreateButton('test', 10, 10) $buttton[2] = 'This is another way' GUICtrlSetOnEvent ($buttton[1], "MyFunction") GUISetState() While 1 Sleep(100) wend Func MyFunction() If @GUI_CtrlId = $buttton[1] Then MsgBox(0, 'Testing', $buttton[2]) EndIf EndFunc 8)Can you do this:Global $buttton[4][4] Opt("GUIOnEventMode", 1); Change to OnEvent mode $main = GUICreate('Testing') $buttton[0][1] = GUICtrlCreateButton('button 1', 10, 10) $buttton[0][2] = GUICtrlCreateButton('button 2', 10, 50) $buttton[0][3] = GUICtrlCreateButton('button 3', 10, 90) $buttton[1][1] = 'Text 1' $buttton[1][2] = 'Test 2' $buttton[1][3] = 'Test 3' GUISetOnEvent(- 3, 'EXITNOW', $main) For $x = 1 To 3 GUICtrlSetOnEvent ($buttton[0][$x], "MyFunction") Next GUISetState() While 1 Sleep(100) wend Func MyFunction() For $i = 1 To 3 If @GUI_CtrlId = $buttton[0][$i] Then MsgBox(0, 'Testing', $buttton[1][$i]) EndIf Next EndFunc Func EXITNOW() Exit EndFunc With a Single Array... without creating another variable? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Valuater Posted March 13, 2006 Share Posted March 13, 2006 Can you do this:Global $buttton[4][4] Opt("GUIOnEventMode", 1); Change to OnEvent mode $main = GUICreate('Testing') $buttton[0][1] = GUICtrlCreateButton('button 1', 10, 10) $buttton[0][2] = GUICtrlCreateButton('button 2', 10, 50) $buttton[0][3] = GUICtrlCreateButton('button 3', 10, 90) $buttton[1][1] = 'Text 1' $buttton[1][2] = 'Test 2' $buttton[1][3] = 'Test 3' GUISetOnEvent(- 3, 'EXITNOW', $main) For $x = 1 To 3 GUICtrlSetOnEvent ($buttton[0][$x], "MyFunction") Next GUISetState() While 1 Sleep(100) wend Func MyFunction() For $i = 1 To 3 If @GUI_CtrlId = $buttton[0][$i] Then MsgBox(0, 'Testing', $buttton[1][$i]) EndIf Next EndFunc Func EXITNOW() Exit EndFunc With a Single Array... without creating another variable? EVEN BETTER Global $buttton[4] Opt("GUIOnEventMode", 1); Change to OnEvent mode $main = GUICreate('Testing') $buttton[1] = GUICtrlCreateButton('button 1', 10, 10) $buttton[2] = GUICtrlCreateButton('button 2', 10, 50) $buttton[3] = GUICtrlCreateButton('button 3', 10, 90) GUISetOnEvent(- 3, 'EXITNOW', $main) For $x = 1 To 3 GUICtrlSetOnEvent ($buttton[$x], "MyFunction") Next GUISetState() While 1 Sleep(100) wend Func MyFunction() For $i = 1 To 3 If @GUI_CtrlId = $buttton[$i] Then MsgBox(0, 'Testing', "Text " & $i & " ") EndIf Next EndFunc Func EXITNOW() Exit EndFunc NA...NA 8) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 13, 2006 Moderators Share Posted March 13, 2006 @nitekram - I looked at your code... Changed one thing I think, just to look at what it was doing... I don't see where it's not doing what you want it to do with the comments you madeexpandcollapse popup; create 2 gui's and have one main and one dummy - the program should not end until the main gui is closed ; after closing the dummy gui the user should be albe to continue with the main gui ; QUESTION - because I am not a programmer - I am not sure if all my code is needed - is there a better way to write this code? ; I do not need the dummy window to be open (hidden) once the dummy gui is closed ; I want the main gui to remain open throughout the life of the program #include <GUIConstants.au3> Global $test = 1, $dummywindow, $dummyActive = 1 Opt("GUIOnEventMode", 1); Change to OnEvent mode ; Create main GUI - not to be deleted until top right X is clicked $mainwindow = GUICreate("Hello World", 200, 100) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUICtrlCreateLabel("Hello world! How are you?", 30, 10) $okbutton = GUICtrlCreateButton("OK", 70, 50, 60) GUICtrlSetOnEvent($okbutton, "OKButton") ; Create dummy - that can be deleted when hitting top right X but does not close main gui CreateDummyWindow($dummyActive) While 1 Sleep(1000); Idle around WEnd Func CreateDummyWindow($dummyActive) $dummywindow = GUICreate("Dummy window for testing ", 200, 100) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetState(@SW_SHOW) If $dummyActive = 1 Then GUISwitch($mainwindow) GUISetState(@SW_SHOW) WinActivate($mainwindow) EndIf EndFunc ;==>CreateDummyWindow ; If OK button was pressed should make dummy window visable Func OKButton() If Not WinActivate($dummywindow) Then $dummyActive = 0 CreateDummyWindow($dummyActive) ElseIf @GUI_WinHandle = $mainwindow Then GUISwitch($dummywindow) GUISetState(@SW_SHOW) WinActivate($dummywindow) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") EndIf EndFunc ;==>OKButton ; I only want the dummy gui to close not the main gui Func CLOSEClicked() If @GUI_WinHandle = $mainwindow Then MsgBox(0, "GUI Event", "You clicked CLOSE in " & WinGetTitle(@GUI_WinHandle) & "! Exiting...") Exit ElseIf @GUI_WinHandle = $dummywindow Then MsgBox('', "GUI Event", "@GUI_WINHANDLE = " & WinGetTitle(@GUI_WinHandle)) GUIDelete($dummywindow) GUISwitch($mainwindow) GUISetState(@SW_SHOW) WinActivate($mainwindow) EndIf EndFunc ;==>CLOSEClicked Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 13, 2006 Moderators Share Posted March 13, 2006 EVEN BETTER Global $buttton[4] Opt("GUIOnEventMode", 1); Change to OnEvent mode $main = GUICreate('Testing') $buttton[1] = GUICtrlCreateButton('button 1', 10, 10) $buttton[2] = GUICtrlCreateButton('button 2', 10, 50) $buttton[3] = GUICtrlCreateButton('button 3', 10, 90) GUISetOnEvent(- 3, 'EXITNOW', $main) For $x = 1 To 3 GUICtrlSetOnEvent ($buttton[$x], "MyFunction") Next GUISetState() While 1 Sleep(100) wend Func MyFunction() For $i = 1 To 3 If @GUI_CtrlId = $buttton[$i] Then MsgBox(0, 'Testing', "Text " & $i & " ") EndIf Next EndFunc Func EXITNOW() Exit EndFunc NA...NA 8)Smart ass!!!Global $buttton[4][4] Opt("GUIOnEventMode", 1); Change to OnEvent mode $main = GUICreate('Testing') $buttton[0][1] = GUICtrlCreateButton('button 1', 10, 10) $buttton[0][2] = GUICtrlCreateButton('button 2', 10, 50) $buttton[0][3] = GUICtrlCreateButton('button 3', 10, 90) $buttton[1][1] = 'All I want for Christmas' $buttton[1][2] = 'Is my' $buttton[1][3] = '2 Front Teeth' GUISetOnEvent(- 3, 'EXITNOW', $main) For $x = 1 To 3 GUICtrlSetOnEvent ($buttton[0][$x], "MyFunction") Next GUISetState() While 1 Sleep(100) wend Func MyFunction() For $i = 1 To 3 If @GUI_CtrlId = $buttton[0][$i] Then MsgBox(0, 'Testing', $buttton[1][$i]) EndIf Next EndFunc Func EXITNOW() Exit EndFunc!! Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
nitekram Posted March 13, 2006 Author Share Posted March 13, 2006 @nitekram - I looked at your code... Changed one thing I think, just to look at what it was doing... I don't see where it's not doing what you want it to do with the comments you madeIt does what is expected - my question would be is there anything that I missed - could the code be shorter. Could it be cleaned up. Since I could not find an example of using the Opt() with more than one window - the way I did, I was just making sure I did not make a newbee mistake by putting code that was not needed. Thanks for all your effort. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
Valuater Posted March 13, 2006 Share Posted March 13, 2006 (edited) Smart ass!!!Global $buttton[4][4] Opt("GUIOnEventMode", 1); Change to OnEvent mode $main = GUICreate('Testing') $buttton[0][1] = GUICtrlCreateButton('button 1', 10, 10) $buttton[0][2] = GUICtrlCreateButton('button 2', 10, 50) $buttton[0][3] = GUICtrlCreateButton('button 3', 10, 90) $buttton[1][1] = 'All I want for Christmas' $buttton[1][2] = 'Is my' $buttton[1][3] = '2 Front Teeth' GUISetOnEvent(- 3, 'EXITNOW', $main) For $x = 1 To 3 GUICtrlSetOnEvent ($buttton[0][$x], "MyFunction") Next GUISetState() While 1 Sleep(100) wend Func MyFunction() For $i = 1 To 3 If @GUI_CtrlId = $buttton[0][$i] Then MsgBox(0, 'Testing', $buttton[1][$i]) EndIf Next EndFunc Func EXITNOW() Exit EndFunc!! well you are sharp enough to stop calling labels buttons.... right??? Global $buttton[4], $Label[4] Opt("GUIOnEventMode", 1); Change to OnEvent mode $main = GUICreate('Testing') $buttton[1] = GUICtrlCreateButton('button 1', 10, 10) $buttton[2] = GUICtrlCreateButton('button 2', 10, 50) $buttton[3] = GUICtrlCreateButton('button 3', 10, 90) $Label[1] = 'All I want for Christmas' $Label[2] = 'Is my' $Label[3] = '2 Front Teeth' GUISetOnEvent(- 3, 'EXITNOW', $main) For $x = 1 To 3 GUICtrlSetOnEvent ($buttton[$x], "MyFunction") Next GUISetState() While 1 Sleep(100) wend Func MyFunction() For $i = 1 To 3 If @GUI_CtrlId = $buttton[$i] Then MsgBox(0, 'Testing', $Label[$i] & " ") EndIf Next EndFunc Func EXITNOW() Exit EndFunc NA... NA lol 8) Edited March 13, 2006 by Valuater Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 13, 2006 Moderators Share Posted March 13, 2006 LOL... well as far as a 'Label', I wouldn't have called it that anyway.... The subject was on Parameters.. and this was just a way that SlimShady came up with that I liked alot! The 2D array made perfect sense... And still does . Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 13, 2006 Moderators Share Posted March 13, 2006 It does what is expected - my question would be is there anything that I missed - could the code be shorter. Could it be cleaned up. Since I could not find an example of using the Opt() with more than one window - the way I did, I was just making sure I did not make a newbee mistake by putting code that was not needed. Thanks for all your effort.No not really... I like the idea that your using functions... and using Global Variables... I think those 2 combinations you'll be fine. Personally, If I was any help at all, I'm surprised... I am not a fan of the OnEventMode()... No particular reason, just stuck in my ways a bit I guess. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Valuater Posted March 13, 2006 Share Posted March 13, 2006 LOL... well as far as a 'Label', I wouldn't have called it that anyway.... The subject was on Parameters.. and this was just a way that SlimShady came up with that I liked alot! The 2D array made perfect sense... And still does .I am sure there are many cases that the two dimensional array is required... butif not.... i'm not going to use it ( actually, they confuse me and my simplle hobbyist mind )8) Link to comment Share on other sites More sharing options...
nitekram Posted March 13, 2006 Author Share Posted March 13, 2006 No not really... I like the idea that your using functions... and using Global Variables... I think those 2 combinations you'll be fine. Personally, If I was any help at all, I'm surprised... I am not a fan of the OnEventMode()... No particular reason, just stuck in my ways a bit I guess.Thanks for all your help - I have no like or dislike as I am just starting out. I now have the code both ways as I was helped before on the post above. I just want to learn and when I get stuck that is when I learn the most - I just wanted to make sure I did not do anything stupid. It took me so long to figure it out and the gurus here make it look so easy - when they write 5 lines of code for something that started off with 20 lines. Makes us wantabees - well - wantabee more. Again thanks. By the way - I do like the single array idea. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator 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