Jump to content

About timers and such


Recommended Posts

Well, basically im I have a script to spam a key and thats it. I wanna make it hit a difference key every hour but cant seem to think how to get it to work. I need some help on this one

Func Start() ;

While $i <= 1000000000000000000000000000000

ControlSend("Notepad", "", "Edit2", "Hello, World!") ;

Sleep(500

$i = $i + 1

WEnd

EndFunc

Now the way I think about this is that, if I stick it in the while, it will loop but it will hit the different key then wait and hour, go through the loop once and do it again.

the basis of what I want it to do is

hit the number 6 key, start typing in notepad "Hello, World!" until the hour is up on the number 6 key timer then hit 6 again and start spamming notepad.

Any ideas how I can get this done? And yes, I know my loop is inneficient, but I dont care. :)

Link to comment
Share on other sites

I'm not sure I understood. Try this for now. When you hit 6, it will start spamming notepad with "Hello World!" over and over for an hour. Assumes of course that notepad is already open.

HotKeySet("6","Go")

While 1
    Sleep(10)
WEnd

Func Go()
    $StartTime = @MIN&@SEC
    Sleep(1000)

    Do
        ControlSend("Untitled - Notepad","","Edit1","Hello World{!}")
    Until @MIN & @SEC = $StartTime
EndFunc
Link to comment
Share on other sites

That would be more like this:

#include <Misc.au3>

Main()

Func Main()
    HotKeySet("{ESC}", "_Quit"); have a way to kill it
    HotKeySet("6", "_HitSix")
    While 1
        Sleep(50)
    WEnd
EndFunc  ;==>Start

Func _HitSix()
; clear hot key
    HotKeySet("6")
    
    Local $iTimer = TimerInit()
    Do
        ControlSend("Untitled - Notepad", "", "Edit1", "Hello, World!" & @CRLF, True); Raw flag set
        Sleep(500)
    Until TimerDiff($iTimer) > 60 * 60 * 1000; 1 hour
    
; restore hot key
    HotKeySet("6", "_HitSix")
EndFunc

Func _Quit()
    Exit
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
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...