Sign in to follow this  
Followers 0
sen21

While loop with start button

5 posts in this topic

Hey,

I am trying to make a while loop to start executing when a start button is clicked then to stop when the mouse is moved. I was trying to use 2 onEvent functions to do this button I can't get the loop to start working. It would look like this kinda.

dim $choice = false

While $choice = true

do something

WEnd

Then when the mouse is moved set $choice = false so the loop stops. Am i approaching this wrong or am I just missing something here?

Thanks

Share this post


Link to post
Share on other sites



Hey,

I am trying to make a while loop to start executing when a start button is clicked then to stop when the mouse is moved. I was trying to use 2 onEvent functions to do this button I can't get the loop to start working. It would look like this kinda.

dim $choice = false

While $choice = true

do something

WEnd

Then when the mouse is moved set $choice = false so the loop stops. Am i approaching this wrong or am I just missing something here?

Thanks

If you want the loop to continue starting and stopping the action more than once, then it would be more like this:

GuiCtrlSetOnEvent($start, "StartEvents")

dim $choice = false

dim $avMouse = MouseGetPos()

While 1

If $choice Then do something

If ($avMouse[0] <> MouseGetPos(0)) Or ($avMouse[1] <> MouseGetPos(1)) Then $choice = false

WEnd

Func StartEvents()

$choice = true

EndFunc

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Ok, but that locks the whole program as it continuously executes the program. I tried changing the while loop's condition to "While $choice" but then the program just exits because choice starts out as false and jumps right by the while loop. Basically I want the program to do nothing until the start button is clicked, then once the start button is clicked, execute the while loop until the mouse is moved and stop doing the while loop. I'm so used to Visual Studio it's hard to realize how to do this lol.

Thanks

Share this post


Link to post
Share on other sites

Ok, but that locks the whole program as it continuously executes the program. I tried changing the while loop's condition to "While $choice" but then the program just exits because choice starts out as false and jumps right by the while loop. Basically I want the program to do nothing until the start button is clicked, then once the start button is clicked, execute the while loop until the mouse is moved and stop doing the while loop. I'm so used to Visual Studio it's hard to realize how to do this lol.

Thanks

What I posted was medium-detailed pseudo code meant to be similar to yours in the OP. If you want to talk about actual code vice the logic of a theoretical loop, post some code so we can both be talking about the same thing! You could start by posting the code you tested for this comment...

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0