Sign in to follow this  
Followers 0
Flemingjp

Timer Without Using Sleep

6 posts in this topic

I want to create a script where a arrow keys a press with delays for how long its held and when to press them.

E.G

Script Started

Up arrow held down >

Wait 500 >

Left Arrow held down >

Wait 250 >

Left Arrow Up >

Script Stopped

I've tried it using Sleep(100), but it doesn't keep the Up arrow held down constantly as it pause the script. Not delay an action.

Thanks

Flemingjp

Share this post


Link to post
Share on other sites



Should work fine when done correctly.... post your script to see what you are doing.

By the way, welcome and hope you did take the time to read our forum rules.


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

MouseClick("Left", 300, 350, 1, 5)
sleep(2990)
Send("{UP down}")
sleep(550)
Send("{LEFT down}")
sleep(350)
Send("{LEFT up}")

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

MouseClick("Left", 300, 350, 1, 5)
sleep(2990)
Send("{UP down}")
sleep(550)
Send("{LEFT down}")
sleep(350)
Send("{LEFT up}")

The sleep is for pausing script. It won´t work.

This is what you´re after:

#include <Timers.au3>

_Timer()

Func _Timer()

    Send("#r")
    WinWaitActive("Run")
    Send("notepad.exe{Enter}")
    WinWaitActive("[CLASS:Notepad]")
    
    Global $starttime = _Timer_Init()
    
    While _Timer_Diff($starttime)<1000
        Send("Hello ... Is just an example")
        
    WEnd
EndFunc   ;==>_Timer
Edited by realshyfox

Learn, learn and ... learn

Share this post


Link to post
Share on other sites

The sleep is for pausing script. It won´t work.

It works fine to keep the KeyDown, but it will not repeatedly press it.

Slight difference here :huh2:


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

It works fine to keep the KeyDown, but it will not repeatedly press it.

Slight difference here :huh2:

Well, let´s change a little:

#include <Timers.au3>

_Timer()

Func _Timer()

    Send("#r")
    WinWaitActive("Run")
    Send("notepad.exe{Enter}")
    WinWaitActive("[CLASS:Notepad]")
    
    Global $starttime = _Timer_Init()
    
    While _Timer_Diff($starttime)<5000
        Send("Hello ... Is just an example")
        Sleep(500)
    $iIdleTime = _Timer_GetIdleTime()
    $starttime = $starttime + $iIdleTime
    WEnd
EndFunc   ;==>_Timer
Edited by realshyfox

Learn, learn and ... learn

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