Flemingjp 0 Posted June 2, 2011 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
Jos 2,211 Posted June 2, 2011 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. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Share this post Link to post Share on other sites
Flemingjp 0 Posted June 2, 2011 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
realshyfox 3 Posted June 2, 2011 (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 June 2, 2011 by realshyfox Learn, learn and ... learn Share this post Link to post Share on other sites
Jos 2,211 Posted June 2, 2011 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 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Share this post Link to post Share on other sites
realshyfox 3 Posted June 2, 2011 (edited) It works fine to keep the KeyDown, but it will not repeatedly press it. Slight difference here 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 June 2, 2011 by realshyfox Learn, learn and ... learn Share this post Link to post Share on other sites