houseonfire Posted September 10, 2007 Share Posted September 10, 2007 Can someone please tell me how give a button in a GUI a command? I'm really new to using the GUI.. Link to comment Share on other sites More sharing options...
billthecreator Posted September 11, 2007 Share Posted September 11, 2007 $button_1 = guictrlcreatebutton("Go", left, top, width, height) if you want that button to do something, then example: While 1 $msg = GuiGetMsg() if $msg = (button name) then (do something here) endif [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap Link to comment Share on other sites More sharing options...
houseonfire Posted September 11, 2007 Author Share Posted September 11, 2007 (edited) I was gonna try that.. but the $msg thing made me think its gonna pop up a message. Thank you very much. $Button1 = GUICtrlCreateButton("test", 32, 112, 89, 41, 0) While 1 $msg = GuiGetMsg() If $msg = $Button1 Then MSGBox (0, "test", "test") endif WEnd Doesn't seem to work :s Edited September 11, 2007 by houseonfire Link to comment Share on other sites More sharing options...
billthecreator Posted September 11, 2007 Share Posted September 11, 2007 if your using SciTE, click on help, and you'll find everything... [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap Link to comment Share on other sites More sharing options...
houseonfire Posted September 11, 2007 Author Share Posted September 11, 2007 Thats just the thing.. I've been searching for this for an hour and cant find it. Link to comment Share on other sites More sharing options...
billthecreator Posted September 11, 2007 Share Posted September 11, 2007 do you have a chat thing, i walk you though it [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap Link to comment Share on other sites More sharing options...
retghy Posted September 11, 2007 Share Posted September 11, 2007 I tried that code to give a button some commands and it works great, but, whenever I click any button, I cannot close the Form via the X on the window corner, its like frozen waiting for the "While" to end. Is there a way to prevent this? thanks in advance. Link to comment Share on other sites More sharing options...
crash748 Posted September 11, 2007 Share Posted September 11, 2007 I tried that code to give a button some commands and it works great, but, whenever I click any button, I cannot close the Form via the X on the window corner, its like frozen waiting for the "While" to end. Is there a way to prevent this? thanks in advance.Try to add this in your While loop! ;Check if user clicked on the close button If $msg = $GUI_EVENT_CLOSE ;Destroy the GUI including the controls GUIDelete() ;Exit the script Exit EndIf Link to comment Share on other sites More sharing options...
JustinReno Posted September 11, 2007 Share Posted September 11, 2007 You actually need to create a GUI for it: CODE #include <GUIConstants.au3> $GUI1 = GUICreate("GUI!", 346, 179, 193, 115) $Button1 = GUICtrlCreateButton("Press Me!!!", 8, 8, 331, 161, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 msgbox(0, "Test", "Testing!!!") EndSwitch WEnd Link to comment Share on other sites More sharing options...
retghy Posted September 11, 2007 Share Posted September 11, 2007 Thank you! That worked great for me. Still need to understand in detail all the code, because I just did a copy paste. Never worked with GUI before in autoit. Thanks again. 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