robotgo icon indicating copy to clipboard operation
robotgo copied to clipboard

Any way to interrupt automations?

Open kvnxiao opened this issue 7 years ago • 4 comments

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.

kvnxiao avatar Sep 21 '18 19:09 kvnxiao

Only StopEvent(), no other.

vcaesar avatar Sep 22 '18 13:09 vcaesar

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

kvnxiao avatar Sep 22 '18 19:09 kvnxiao

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.

redstarcoder avatar Oct 01 '18 20:10 redstarcoder

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.

arizvisa avatar Dec 01 '20 13:12 arizvisa