Rikko Posted August 18, 2012 Posted August 18, 2012 I have a problem with my script, it auto click on $button with is not created yet.. #include <GUIConstantsEx.au3> Global $List, $Button, $ListButton $MainGUI = GUICreate('MyGui', 400, 300) GUISetState() _list('1') Func _Bilder($Value) $Button = GUICtrlCreateButton('Test', 20, 20, 120, 60) EndFunc ;==>_Bilder Func _list($ListValue) $ListButton = GUICtrlCreateButton("Test", 200, 20) $List = GUICtrlCreateList('Test', 20, 20) EndFunc ;==>_list While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $ListButton MsgBox(0, '', 'List') Case $Button MsgBox(0, '', 'Button') EndSwitch WEnd The problem is when i run the script it launches the func _list but when it enters the loop with the switch, it trigger the $button witch is only created in the _button func. Why does it do this and how do i fiks it?
JScript Posted August 18, 2012 Posted August 18, 2012 (edited) Hello, welcome to the forum!The "$Button" had not yet been created!#include <GUIConstantsEx.au3> Global $List, $Button, $ListButton $MainGUI = GUICreate('MyGui', 400, 300) GUISetState() _Bilder(1) _list('1') While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $ListButton MsgBox(0, '', 'List') Case $Button MsgBox(0, '', 'Button') EndSwitch WEnd Func _Bilder($Value) $Button = GUICtrlCreateButton('Test', 20, 20, 120, 60) EndFunc ;==>_Bilder Func _list($ListValue) $ListButton = GUICtrlCreateButton("Test", 200, 20) $List = GUICtrlCreateList('Test', 20, 20) EndFunc ;==>_listRegards,João Carlos. Edited August 18, 2012 by JScript http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere!
Bowmore Posted August 18, 2012 Posted August 18, 2012 Untill you create the button $Button = 0 which is the value that GUIGetMsg() returns when ther is no message in the que. Change you message loop to this to fix the problem While 1 $msg = GUIGetMsg() Switch $msg Case 0 ContinueLoop Case $GUI_EVENT_CLOSE ExitLoop Case $ListButton MsgBox(0, '', 'List') Case $Button MsgBox(0, '', 'Button') EndSwitch WEnd "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook
Rikko Posted August 18, 2012 Author Posted August 18, 2012 (edited) Untill you create the button $Button = 0 which is the value that GUIGetMsg() returns when ther is no message in the que. Change you message loop to this to fix the problem While 1 $msg = GUIGetMsg() Switch $msg Case 0 ContinueLoop Case $GUI_EVENT_CLOSE ExitLoop Case $ListButton MsgBox(0, '', 'List') Case $Button MsgBox(0, '', 'Button') EndSwitch WEnd Thank you. Just adding $Button = 1 at the beginning fixed it.. So if i understad it right: when i create a variable with $Button = Guictrlcreatebutton('') then when i click on the button Autoit sets the $button = 0 then the case is looking for the $Button = 0 Hello, welcome to the forum! The "$Button" had not yet been created! #include <GUIConstantsEx.au3> Global $List, $Button, $ListButton $MainGUI = GUICreate('MyGui', 400, 300) GUISetState() _Bilder(1) _list('1') While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $ListButton MsgBox(0, '', 'List') Case $Button MsgBox(0, '', 'Button') EndSwitch WEnd Func _Bilder($Value) $Button = GUICtrlCreateButton('Test', 20, 20, 120, 60) EndFunc ;==>_Bilder Func _list($ListValue) $ListButton = GUICtrlCreateButton("Test", 200, 20) $List = GUICtrlCreateList('Test', 20, 20) EndFunc ;==>_list Regards, João Carlos. This did not help because the $Button should not yet be created Edited August 18, 2012 by Rikko
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