Author Topic: [VBS] Timed while loop  (Read 4674 times)

0 Members and 1 Guest are viewing this topic.

Offline Ragehottie

  • Knight
  • **
  • Posts: 313
  • Cookies: -9
  • Hack to learn, not learn to hack.
    • View Profile
[VBS] Timed while loop
« on: 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:
Code: [Select]


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?
Blog: rexmckinnon.tumblr.com

Offline techb

  • Soy Sauce Feeler
  • Global Moderator
  • King
  • *
  • Posts: 2350
  • Cookies: 345
  • Aliens do in fact wear hats.
    • View Profile
    • github
Re: [VBS] Timed while loop
« Reply #1 on: 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:
Code: [Select]
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.
   
« Last Edit: October 13, 2012, 02:12:39 am by techb »
>>>import this
-----------------------------

Offline Ragehottie

  • Knight
  • **
  • Posts: 313
  • Cookies: -9
  • Hack to learn, not learn to hack.
    • View Profile
Re: [VBS] Timed while loop
« Reply #2 on: 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.
Blog: rexmckinnon.tumblr.com