EvilZone

Programming and Scripting => .NET Framework => : Ragehottie October 13, 2012, 01:27:04 AM

: [VBS] Timed while loop
: Ragehottie October 13, 2012, 01:27:04 AM
Does anyone know how to do a timed while loop? This is what I want to do in pseudocode:
:


while time < 1 minute:
        shell.SendKey "w"


I'm making a game bot, that is correct.
Anyways. Is the while loop what I need? And if not what do I need?
: Re: [VBS] Timed while loop
: techb October 13, 2012, 02:10:43 AM
I haven't done VBS in so long, but you got the right idea. You will need a method or builtin function that gets system time. Have a var to keep track of the system time, and do a difference on the last logged time.


pseudo code:
:
old_time = system.getCurrentTime()
new_time = 0
passed_time = 0
end_time = 60000 //because most all system times keep track in miliseconds

while passed_time < end_time:
    shell.SendKey "w"
    new_time = system.getCurrentTime()
    passed_time = old_time - new_time
    old_time = new_time


Something along those lines. There probably is a more efficient way to do it like this; such as comparing the difference in the while loop check.


For more detail/better help, look up how videogames keep track of FPS.
   
: Re: [VBS] Timed while loop
: Ragehottie October 13, 2012, 04:06:16 AM
Ahh, thanks. I was thinking about something like that, but I was hoping for like a built in function. Oh well, thats perfectly fine for my needs.