Jump to content

Repeating a Given Function For A Set Time


Recommended Posts

First of all, Hello for anyone reading this.

I have been looking at the Help File and searching for a Pre-existing thread for a while now. I haven't found anything (doesn't mean it's not out there) I'm pretty tired and discouraged. I would like some help with this.

I would like to cause a Function to repeat itself for... oh let's say 12 minutes before terminating and moving on to the next part of the script.

AutoItSetOption("WinTitleMatchMode", 4)
Global $handle = WinGetHandle("classname=SoM3cRa2Yc0De")

WinWaitActive("Window Title")
                 
          
HotKeySet("{PGUP}", "Start")
HotKeySet("{F3}","Quit")

TogglePause()
                   
func Start() 
HotKeySet("{PGUP}")
HotKeySet("{PGUP}", "TogglePause")
ToolTip('Stuff is Happening',0,0)

ControlSend($handle, "", "", "") ;This is what I would like to repeat for 12 minutes
Sleep("somenumber")
ControlSend($handle, "", "", "")
Sleep("somenumber") ;This is the end

EndFunc

Func TogglePause()
ToolTip('Stuff is Not Happening',0,0)
HotKeySet("{PGUP}")
HotKeySet("{PGUP}", "Start")
While 1
sleep(100)
WEnd
EndFunc

func Quit()
HotKeySet("{F3}"
Exit
EndFunc

This is a basic example script to maybe show you what I mean and give you something to tinker with, as well as making this easier for me to relate to and implement in the future.

Cheers

Link to comment
Share on other sites

Func Start()
    Local $iInit
    
    HotKeySet("{PGUP}")
    HotKeySet("{PGUP}", "TogglePause")
    ToolTip('Stuff is Happening',0,0)

    $iInit = TimerInit()
    
    Do
        ControlSend($handle, "", "", "") ;This is what I would like to repeat for 12 minutes
        Sleep(150) ; somenumber
    Until (TimerDiff($iInit)/60000) > 12 ; 12 minutes
    
    $iInit = TimerInit()
    
    Do
        ControlSend($handle, "", "", "")
        Sleep(150) ; This is the end
    Until (TimerDiff($iInit)/1000) > 30 ; 30 seconds
EndFunc

Edited by Authenticity
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...