Sign in to follow this  
Followers 0
ayatest

step by step manual triggering

6 posts in this topic

Let say that I have a script with some functions and some actions like below. (it will use mouseclicks as it is now, keyboard shortcuts, and maybe something else).

Func test()
; test to repeat in various states
MouseClick("left",734,75,1)
Sleep(2000)
MouseClick("left",763,76,1)
Sleep(2000)
EndFunc

; state 1
test()

; state 2
MouseClick("left",104,76,1)
Sleep(2000)
test()

At the moment, steps are separated by time based pauses. What I'd like to do (and I'd like to make it work in called functions and outside them in the script) - is to use (with or instead of "sleep") a single hotkey, to trigger manually each next step (mouseclick, sent key, etc). So at least such step by step routine.

What also would be useful, would  be to have:

- two keys to: shut down the script and pause the script

- a key to repeat (retrigger) last step (optional)

Could someone post an example how to wire such thing (if it's possible to wire it in autoit) with example above? (yes, I tried to wire terminate/pause part according to wiki, but for some reason it did not worked)


functional testing. multimedia recording. flowstone. mouseclick, hotkeys and modularity in general.

Share this post


Link to post
Share on other sites



what's the name of the game your working on?

Share this post


Link to post
Share on other sites

It's not game, it's functional testing and multimedia recording.


functional testing. multimedia recording. flowstone. mouseclick, hotkeys and modularity in general.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

That's a lot to ask for.

You can find some pause functions >here.

here is one possible way to repeat the last step, may not be the best but it's the first way I thought of as I don't generally use functions in this manner.

It is minimalistic.

#include <Array.au3>

Global $aFuncs[3] = [_Func1, _Func2, _Func3]
Global $RepeatLastStep

_ArrayShuffle($aFuncs)

$aFuncs[0]($aFuncs[0])
$aFuncs[1]($aFuncs[1])
$aFuncs[2]($aFuncs[2])

$RepeatLastStep($RepeatLastStep)

Func _Func1($func)
    ConsoleWrite("Func 1" & @LF)
    $RepeatLastStep = $func
EndFunc

Func _Func2($func)
    ConsoleWrite("Func 2" & @LF)
    $RepeatLastStep = $func
EndFunc

Func _Func3($func)
    ConsoleWrite("Func 3" & @LF)
    $RepeatLastStep = $func
EndFunc
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Using Hotkeys

Native HotkeySet cannot handle function parameters, so need to alter the code slightly.

#include <Array.au3>

HotKeySet("^1", "_Func1")
HotKeySet("^2", "_Func2")
HotKeySet("^3", "_Func3")
HotKeySet("^4", "_RepeatLastStep")

Global $aFuncs[3] = [_Func1, _Func2, _Func3]
Global $RepeatLastStep

_ArrayShuffle($aFuncs)

While 3
    Sleep(333)
WEnd

Func _RepeatLastStep()
    If Not IsFunc($RepeatLastStep) Then Return
    ConsoleWrite("Repeating ")
    $RepeatLastStep()
EndFunc

Func _Func1()
    ConsoleWrite("Func 1" & @LF)
    $RepeatLastStep = _Func1
EndFunc

Func _Func2()
    ConsoleWrite("Func 2" & @LF)
    $RepeatLastStep = _Func2
EndFunc

Func _Func3()
    ConsoleWrite("Func 3" & @LF)
    $RepeatLastStep = _Func3
EndFunc 

EDIT: alter _RepeatLastStep function, due to error if called first.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Well - I thought there will be some sort of a simple 1-command switch, like "sleep" (a sort of standard debugging routine).

Thanks, I will look into it, and let you know.


functional testing. multimedia recording. flowstone. mouseclick, hotkeys and modularity in general.

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