Sign in to follow this  
Followers 0
Vindicator209

Loop while another loop is running?

5 posts in this topic

Ok, I have this script and it has a while loop that sleeps and adds a number to a control, and I want it so that they cannot cheat, by opening other windows for answers, or going out to use cheat engine or something. I have, within the same loop, a WINACTIVATE, to ALWAYS keep it ontop and makesure no one can go out of the window without finishing the made-up test.. but I had just realized that because the script SLEEPS, the loop doesnt continue, so how sould I be able to have the script sleep, while running another loop to keep it on top and covering everything else? (it fills the whole screen)

Run("RocketTest.exe")
While 1
                                               WinActivate("Rocket Test")
            If ProcessExists("RocketTest.exe") Then
                Sleep(0)
            Else
                Run("RocketTest.exe")
            EndIf
                $wait=Random(1200,5000)
                Sleep($wait)
                $total=GUICtrlRead($Progress_6)
                $overall=$total + 1
                GUICtrlSetData($Progress_6,$overall)
                $overall2=0.015
                GUICtrlSetData($Progress_9,$overall2)
            WEnd

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Share this post


Link to post
Share on other sites



If i understand right you want to do "2" different things in the same script.. on the same time?


[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Share this post


Link to post
Share on other sites

maybe "AdlibEnable()" ?

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Well.. I think you want something like this:

Opt("WinTitleMatchMode", 2)
HotKeySet("{F2}", "_Quit")
AdlibEnable("_WindowCheck")

While 1
    $wait=Random(1200,5000)
    Sleep($wait)
    $total=GUICtrlRead($Progress_6)
    $overall=$total + 1
    GUICtrlSetData($Progress_6,$overall)
    $overall2=0.015
    GUICtrlSetData($Progress_9,$overall2)
    Sleep(40)
WEnd

Func _WindowCheck()
    If WinActive("Rocket") Then
        Sleep(40)
    Else
        Run("RocketTest.exe")
        Sleep(40)
    EndIf
EndFunc   ;==>_WindowCheck

Func _Quit()
    If ProcessExists("RocketTest.exe") Then
        ProcessClose("RocketTest.exe")
        Sleep(40)
        Exit
    EndIf
EndFunc   ;==>_Quit

I always add sleep(40) in loops, Because of the CPU usage :lmao:

Edited by AceLoc

[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Share this post


Link to post
Share on other sites

thanks!


[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

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