Jester009 0 Posted September 16, 2007 Hi, I'm trying to do the following but I can't get it working There are three buttons in my gui. When the 1st button is pressed I want to start a loop. Inside the loop when the 2nd button is pressed I want to execute a certain piece of code and when the 3rd button is pressed I need to execute another piece of code. But I'm unable to get this working Can anybody help me with this? Example would be really helpful.. I'm kinda new to Autoit Thanks Jester009 Share this post Link to post Share on other sites
DjDeep00 0 Posted September 16, 2007 For trouble shooting....Post your existing code. Share this post Link to post Share on other sites
Achilles 2 Posted September 17, 2007 This is a messy way of doing it.GuiCreate('Testing', 300, 100) $buttonOne = GuiCtrlCreateButton('First', 0, 0, 100, 30) $buttonTwo = GuiCtrlCreateButton('Second', 100, 0, 100, 30) $buttonThree = GuiCtrlCreateButton('Third', 200, 0, 100, 30) GuiSetState() While 1 Switch GuiGetMsg() Case $buttonOne GuiCtrlCreateLabel('Here', 0, 35) While 1 Switch GuiGetMsg() Case $buttonTwo GuiCtrlCreateLabel('Here', 100, 35) While 1 Switch GuiGetMsg() Case $buttonThree GuiCtrlCreateLabel('Here', 200, 35) Sleep(1000) Exit Case -3 Exit EndSwitch WEnd Case -3 Exit EndSwitch WEnd Case -3 Exit EndSwitch WEnd This is how I would to it#include <GUIConstants.au3> GuiCreate('Testing', 300, 100) $buttonOne = GuiCtrlCreateButton('First', 0, 0, 100, 30) $buttonTwo = GuiCtrlCreateButton('Second', 100, 0, 100, 30) GuiCtrlSetState($buttonTwo, $GUI_DISABLE) $buttonThree = GuiCtrlCreateButton('Third', 200, 0, 100, 30) GuiCtrlSetState($buttonThree, $GUI_DISABLE) GuiSetState() While 1 Switch GuiGetMsg() Case $buttonOne GuiCtrlCreateLabel('Here', 0, 35) GuiCtrlSetState($buttonTwo, $GUI_ENABLE) GuiCtrlSetState($buttonOne, $GUI_DISABLE) Case $buttonTwo GuiCtrlCreateLabel('Here', 100, 35) GuiCtrlSetState($buttonTwo, $GUI_DISABLE) GuiCtrlSetState($buttonThree, $GUI_ENABLE) Case $buttonThree GuiCtrlCreateLabel('Here', 200, 35) GuiCtrlSetState($buttonThree, $GUI_DISABLE) Sleep(1000) Exit Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Share this post Link to post Share on other sites
Jester009 0 Posted September 17, 2007 (edited) This the code... #include <GUIConstants.au3> $Form1 = GUICreate("Form1", 392, 132, 193, 120) $Button1 = GUICtrlCreateButton("Button1", 48, 48, 57, 25, 0) $Button2 = GUICtrlCreateButton("Button2", 160, 48, 65, 25, 0) GUICtrlSetState($Button2, $GUI_DISABLE) $Button3 = GUICtrlCreateButton("Button3", 280, 48, 65, 25, 0) GUICtrlSetState($Button3, $GUI_DISABLE) GUISetState(@SW_SHOW) Do $msg = GUIGetMsg() if $msg = $Button1 Then MsgBox(0, "Test", "Button1 pressed") GUICtrlSetState($Button2, $GUI_ENABLE) GUICtrlSetState($Button1, $GUI_DISABLE) For $i = 1 to 5 MsgBox(0, "Test", "About to press Button2") If $msg = $Button2 Then MsgBox(0, "Test", "Button2 pressed") GUICtrlSetState($Button3, $GUI_ENABLE) GUICtrlSetState($Button2, $GUI_DISABLE) EndIf If $msg = $Button3 Then MsgBox(0, "Test", "Button3 pressed") EndIf Next EndIf Until $msg = $GUI_EVENT_CLOSE Edited September 17, 2007 by Jester009 Share this post Link to post Share on other sites
Jester009 0 Posted September 18, 2007 Can anyone tell me the code to wait for user input inside a FOR loop??? Thanks Jester009 Share this post Link to post Share on other sites
Jester009 0 Posted September 19, 2007 Please can somebody help me?? I'm stuck here How to wait inside a FOR loop till the user enters a button? Please help... Share this post Link to post Share on other sites
DjDeep00 0 Posted September 19, 2007 Your really cant use a forloop, you will need to use either while or do loop. Share this post Link to post Share on other sites
DjDeep00 0 Posted September 19, 2007 This is the most retarded way of doing it.....try it out...lol... expandcollapse popup#include <GUIConstants.au3> $Form1 = GUICreate("Form1", 392, 132, 193, 120) $Button1 = GUICtrlCreateButton("Button1", 48, 48, 57, 25, 0) $Button2 = GUICtrlCreateButton("Button2", 160, 48, 65, 25, 0) GUICtrlSetState($Button2, $GUI_DISABLE) $Button3 = GUICtrlCreateButton("Button3", 280, 48, 65, 25, 0) GUICtrlSetState($Button3, $GUI_DISABLE) GUISetState(@SW_SHOW) Do $msg = GUIGetMsg() if $msg = $Button1 Then ; MsgBox(0, "Test", "Button1 pressed") GUICtrlSetState($Button2, $GUI_ENABLE) GUICtrlSetState($Button1, $GUI_DISABLE) For $i = 1 to 5000000 ; MsgBox(0, "Test", "About to press Button2") ;ConsoleWrite($i & @CRLF) $msg2 = GUIGetMsg() If $msg2 = $Button2 Then ;MsgBox(0, "Test", "Button2 pressed") GUICtrlSetState($Button3, $GUI_ENABLE) GUICtrlSetState($Button2, $GUI_DISABLE) ExitLoop EndIf Next EndIf if $msg = $Button2 Then GUICtrlSetState($Button3, $GUI_ENABLE) GUICtrlSetState($Button2, $GUI_DISABLE) For $i = 1 to 5 ; MsgBox(0, "Test", "About to press Button2") ;ConsoleWrite($i & @CRLF) $msg3 = GUIGetMsg() If $msg3 = $Button3 Then MsgBox(0, "Test", "Button2 pressed") GUICtrlSetState($Button3, $GUI_DISABLE) ; GUICtrlSetState($Button2, $GUI_DISABLE) EndIf Next EndIf if $msg = $Button3 Then ; MsgBox(0, "Test", "Button1 pressed") GUICtrlSetState($Button3, $GUI_DISABLE) For $i = 1 to 5000000 ; MsgBox(0, "Test", "About to press Button2") ;ConsoleWrite($i & @CRLF) $msg4 = GUIGetMsg() If $msg4=$GUI_EVENT_CLOSE then ExitLoop Next EndIf Until $msg = $GUI_EVENT_CLOSE Share this post Link to post Share on other sites
Jester009 0 Posted September 20, 2007 Thanks alot for the reply DjDeep. Seems my method is not working. can you suggest me a method to get user input from a GUI using inputbox and buttons? it should run for a given number of times Thanks Jester009 Share this post Link to post Share on other sites