go-vgo / robotgo

RobotGo, Go Native cross-platform RPA and GUI automation @vcaesar
Apache License 2.0
9.6k stars 879 forks source link

Any way to interrupt automations? #166

Open kvnxiao opened 6 years ago

kvnxiao commented 6 years ago

Is there any way to interrupt an automation? For example, if I am automating mouse movement with robotgo.MoveMouseSmooth(...), robotgo will obviously take over my mouse until it is done.

I have a hotkey system implemented in my program where I would like to be able to "pause" or "stop" the automation if a user presses a certain key combination, so that the automation stops and the user will have full control over their mouse again.

I've looked over the docs and couldn't seem to find anything of the sorts.

vcaesar commented 6 years ago

Only StopEvent(), no other.

kvnxiao commented 6 years ago

Then is it possible to implement an interrupt to fully pause automation process?

redstarcoder commented 6 years ago

The easiest way I can think of off the top of my head is to simply store all the steps you want to run in a slice, and have a method to begin automation, checking for a pause after each step.

I don't personally want pausing to be implemented at the library level.

arizvisa commented 3 years ago

Rather than pausing/resuming which would require maintenance of the current state, you can probably just include golang's context to allow people to cancel the currently running action the same way net/http works. You'd only need to check a channel, and interrupt execution if the channel is signalled.