cliclick icon indicating copy to clipboard operation
cliclick copied to clipboard

Support for repeated commands

Open meyercm opened this issue 8 years ago • 5 comments
trafficstars

I know that cliclick can work from a commands file, or that I could write a bash loop; however, I'd love to see syntax like (inspired by xdotool):

> cliclick --repeat 500 -w 20 c:. => generate 500 click events at the current mouse position, one every 20ms

cliclick has a nice command chaining syntax, so maybe a better approach is to extend the algebra you've already written:

> cliclick -w 20 c:.*500 (same 500 clicks, once every 20ms as before)

allowing paren would enable more complicated logic:

> cliclick (c:.*5 m:+100,+100 w:20)*5 (5 clicks, move, wait, repeat all 4 more times)

meyercm avatar Feb 14 '17 23:02 meyercm

I think given the current syntax and the current code for “parsing” the syntax (which is no parsing, but simply reading a space-separated list of arguments), the most convenient syntax would be something like this:

cliclick repeat:500 c:. endrepeat

But just out of curiosity: what is the point of being able to do that? What would be a usage scenario?

BlueM avatar Feb 15 '17 06:02 BlueM

I think your proposed syntax looks fine.

Frankly, my use case would be for autoclicking scenarios, and wouldn't need any grouping logic- I proposed it as a natural extension to the repeat feature.

meyercm avatar Feb 26 '17 14:02 meyercm

I think given the current syntax and the current code for “parsing” the syntax (which is no parsing, but simply reading a space-separated list of arguments), the most convenient syntax would be something like this:

cliclick repeat:500 c:. endrepeat

But just out of curiosity: what is the point of being able to do that? What would be a usage scenario?

That doesn't work for me... is it implemented?

Touchy28 avatar Oct 12 '21 08:10 Touchy28

No, not implemented – that’s the reason why this issue is still open.

BlueM avatar Oct 12 '21 18:10 BlueM

In the mean time, one could do something like this to click repeatedly with a pause in between, and exiting after a certain amount of time:

#!/usr/bin/env bash

cliclick -e 200 m:1002,848 w:200

while true
do
    [[ "$SECONDS" -lt 10 ]] || exit
    cliclick c:1002,848 w:1000 t:Test
done

$SECONDS is a bash internal variable; the timer stars with the creation of a shell.

EDIT: Disclaimer: don't use while true ... done without some sort of exit mechanism.

paxperscientiam avatar Jun 12 '22 22:06 paxperscientiam