Jujo Posted October 28, 2008 Share Posted October 28, 2008 Guys, I need help! This is supposed to be my very first GUI. I think it is all OK with it (I looked at scripts here at forum, and combined them ;D), but I don't know how to make it repeat action This "program" is supposed to ask user for data about frequency and duration of "BEEP", and then, using Beep() function, annoy everybody in the room - simple. That is not problem, but when I enter data, and press the 'Annoy' button, it plays Beep, and after that I press the Annoy button again, but nothing happens. I think it is problem with Switch, but you tell me. NOTE: I am beginner, so don't laugh at me about this code. $GUI = GUICreate("Annoyer", 150, 85) GUICtrlCreateLabel("Frequency:", 20, 8, -1, 15) $Frequency = GUICtrlCreateInput("1000", 80, 5, -1, 20) GUICtrlCreateLabel("Duration:", 20, 38, -1, 15) $Duration = GUICtrlCreateInput("5", 69, 35, 15, 20) GUICtrlCreateLabel("seconds", 85, 38, -1, 15) $Annoy = GUICtrlCreateButton("Annoy!", 40, 60, 60, 20) GUISetState(@SW_SHOW, $GUI) While 1 Switch GUIGetMsg() Case $Annoy $Frequency = GUICtrlRead($Frequency) $Duration = GUICtrlRead($Duration) * 1000 Beep($Frequency, $Duration) Sleep($Duration) EndSwitch WEnd Link to comment Share on other sites More sharing options...
cageman Posted October 28, 2008 Share Posted October 28, 2008 (edited) you should use new variables for $frequenty and $duration here. what you do now is giving the inputforms the value of themselves. probably strange things happen then. so : While 1 Switch GUIGetMsg() Case $Annoy $Frequencybeep = GUICtrlRead($Frequency) $Durationbeep = GUICtrlRead($Duration) * 1000 Beep($Frequencybeep, $Durationbeep) Sleep($Durationbeep) EndSwitch WEnd Edited October 28, 2008 by cageman Link to comment Share on other sites More sharing options...
Achilles Posted October 28, 2008 Share Posted October 28, 2008 In case you didn't realize the specific problem that cageman told you, here is what happening: The variable $Frequency is originally stored as the actual control that you created. When you press the annoy button, it reads the data in the $Frequency control, and assigns the data to the variable $Frequency. $Frequency is now a number that does not represent your control. So the next time you press annoy, it can't read the data from the control. My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
Jujo Posted October 28, 2008 Author Share Posted October 28, 2008 Thanks for help I tought it will be problem with same names, but... 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