DanielDaniel Posted November 2, 2010 Share Posted November 2, 2010 (edited) Why won't the button on my GUI call the function? Here's the relevant parts of the code: $BtnAdd = GUICtrlCreateButton("Add", 305, 7, 50, 49) $BtnStart = GUICtrlCreateButton("Start", 354, 7, 50, 49) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $BtnAdd Case $msg = $BtnStart Call RunApps() EndSelect WEnd Thanks! Edited November 2, 2010 by DanielDaniel Link to comment Share on other sites More sharing options...
taietel Posted November 2, 2010 Share Posted November 2, 2010 delete Call and leave the function RunApps() alone. Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
DanielDaniel Posted November 2, 2010 Author Share Posted November 2, 2010 Thanks for the quick reply, but still no use. I have reduced the code to this: While 1 $msg = GUIGetMsg() If $msg <> 0 Then msgbox(0, "hj", $msg) Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $BtnAdd MsgBox(0, "hh", "hh") EndSelect WEnd But the msgbox never fires as I suspect that $msg never has a value other than 0. Link to comment Share on other sites More sharing options...
taietel Posted November 2, 2010 Share Posted November 2, 2010 (edited) I've added a gui to your script and a message to the RunApps() function, to test it. #include <GUIConstantsEx.au3> GUICreate("GUI", 600, 400) $BtnAdd = GUICtrlCreateButton("Add", 305, 7, 50, 49) $BtnStart = GUICtrlCreateButton("Start", 354, 7, 50, 49) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $BtnAdd Case $msg = $BtnStart RunApps() EndSelect WEnd Func RunApps() MsgBox(0,"mnbvbv","mnbvmnbbv") EndFunc Maybe you have a problem with your other part of the script. [edit] Please use "[autoit]" tags when you post your code. It's more "readable" because of the syntax highlighting. Edited November 2, 2010 by taietel Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
DanielDaniel Posted November 2, 2010 Author Share Posted November 2, 2010 Hmm, so it must be a problem elsewhere in the code because when I adapt your example to include the rest of my code, the button presses are ignored. Any suggestions on how to debug this? I have 300 lines of code so far... Thanks! Link to comment Share on other sites More sharing options...
DanielDaniel Posted November 3, 2010 Author Share Posted November 3, 2010 Just to close the loop, I solved this problem. I had put the below line in my code, meaning that the buttons were now event driven (I actually prefer this) rather than using the msg$ and Do/Until option. Opt("GUIOnEventMode", 1) Simply adding the event to the button with the below command solved the problem. GUICtrlSetOnEvent($BtnStart, "RunApps") 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