bluem / cliclick Goto Github PK
View Code? Open in Web Editor NEWmacOS CLI tool for emulating mouse and keyboard events
Home Page: https://www.bluem.net
License: Other
macOS CLI tool for emulating mouse and keyboard events
Home Page: https://www.bluem.net
License: Other
Im not that good at coding and now really just a bit. I got this python script for blender which copies the mouse movent in blender to something in Marvelouse Designer. Now this code was written for windows, which can use:
ctypes.windll.user32.mouse_event(2, 0, 0, 0,0) # left down
is there a easy way to do this with for example Popen orso? But i need to now how to get the path or should i look elsewhere?
If I do a click through AppleScript on the system bar (where the clock, the battery, the wifi etc. are, in german "Menüleiste") nothing happens. My code (with AS):
do shell script "/opt/local/bin/cliclick c:810,10"
Not possible to emulate a click there. The mouse jumps to the position (810,10) but doesn't click.
With direct command on Terminal it is no problem.
Is there a trick or is it just forbidden by the system to use cliclick through AS?
On Mac OS 10.11.6 with cliclick (vs3.3, 11/12/2016) on my MacBook Pro Mid 2009
Thank
frank
If I run cliclick m:foo,bar
, there is no error, and the mouse pointer is moved to 0,0.
I'm using cliclick to test hotkeys in my app. For example it presses control+shift+v. And the test runs on english and russian keyboards. But now then i run it on mac with 10.12.6 on board I get only control+shift when i switch to russian. Button "V" is ignored. It worked in earlier versions of OS X.
Some .NET/MONO games use backspace key, but the Mac keyboard does not provide this key.
Would you add support for Backspace key ?
As the title suggests, the keypress functions aren't working for the volume options (I'm on a Macbook Air 10.10.2)
For purposes such as scripting screencasts, where things like the movement of the mouse pointer should be perceivable (instead of the mouse jumping around the screen, which is what happens when using cliclick now), it would be nice to have mouse movement easing – probably cubic in/out easing.
This means that a whole series of mouse move events would have to be fired to emulate this.
Reminder: for calculating the easing, this would be sufficient:
// Modeled after the piecewise cubic
// y = (1/2)((2x)^3) ; [0, 0.5)
// y = (1/2)((2x-2)^3 + 2) ; [0.5, 1]
//
// Source: AHEasing, License: WTFPL
//
// Expects the [whatever action] to be split up into small steps represented
// by a float from 0 (start) to 1 (end). Method is to be called with the float
// and returns an "eased float" for it.
-(float)cubicEaseInOut:(float)p {
if (p < 0.5) {
return 4 * p * p * p;
} else {
float f = ((2 * p) - 2);
return 0.5 * f * f * f + 1;
}
}
The help says to prefix with = to specify absolute positions on displays left of (/above) the main display:
(If you need to specify absolute negative values in case you have a setup
with a second display arranged to the left of your main display, prefix the
number with “=”, for instance “c:100,=-200”.)
However this isn't working for me:
$ ./cliclick p
Current mouse position: -1039,-1328
$ ./cliclick c:=-1039,=-1328
Invalid X axis coordinate “=-1039” given
If I try that without the = I get a click at a relative position (as expected).
Perhaps I misunderstood the format?
The dragging of spaces to rearrange them in Mission Control works as expected in OS X Yosemite 10.10.5 but fails every time in any version of OS X El Capitan. The click down registers as evidenced by the darkening of the target space, but the space fails to drag. I'm using cliclick as part of an Applescript implementation, for example: do shell script "usr/local/bin/cliclick dd:830,70 w:1000 du:500,70" I'm using cliclick version 3.2.
Hi,
Unfortunately, from my experience, the drag command does not seem to always return the expected results. I was trying to drag a folder from a Finder's window over a window of "ImageOptim" and repeating the same command over and over, sometimes (a few times) it works perfectly, sometimes (most of the time) it doesn't.
In addition, during these tests nothing else was changed and the "working conditions", at least those under my control, were always the same.
I tried to run all the commands directly from Terminal and all via Applescript, and I tried all the following with little changes of w:
(wait amount and/or wait position(s) in the command) or other slight variations:
dd:1010,113 du:1010,650
(via AppleScript and activating Finder's window just before do shell …
)
c:1010,113 dd:. du:1010,650
(as suggested having a similar issue)
c:1010,113 dd:1010,113 du:1010,650
open -a Finder; cliclick dd:1010,113 w:300 du:1010,650
c:1010,113 w:300 dd:. du:1010,650
cliclick m:1010,113 w:200 c:. w:200 dd:1010,113 w:200 du:1010,650
(this last one from Terminal, having the ImageOptim's window as last "active" window before focus on Terminal, has worked 4 times continuously … but not the 5th and 6th. Then again the 7th test.
Actually if one of these command works… repeating it again after a while, it doesn't any more. Have you please any further suggestion or advice about this?
And about this topic the dd:x,y du:x,y
commands, may also have other commands between them or only the w:
command is allowed? Thanks.
Currently I'm using macOS 10.12.1 with Xcode 8.1 and if I import the project and initially try to build it I get an error stating The run destination My Mac is not valid for Running the scheme 'cliclick'.
This is caused by the project setting Base SDK
located under PROJECT > cliclick > Build Settings > Architectures set to macosx10.7
which for me is showing SDK not found
.
I'm not that familiar with Xcode (actually this is the first time I'm contributing to a project using it 😅) therefore this might be no good suggestion, but couldn't it help to set it to always use the latest SDK?
Therefore I'm suggesting this:
diff --git a/cliclick.xcodeproj/project.pbxproj b/cliclick.xcodeproj/project.pbx
index 58db10c..b4b3c4b 100644
--- a/cliclick.xcodeproj/project.pbxproj
+++ b/cliclick.xcodeproj/project.pbxproj
@@ -413,7 +413,7 @@
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "-DDEBUG=1";
PREBINDING = NO;
- SDKROOT = macosx10.7;
+ SDKROOT = macosx;
};
name = Debug;
};
@@ -428,7 +428,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.7;
OTHER_CFLAGS = "";
PREBINDING = NO;
- SDKROOT = macosx10.7;
+ SDKROOT = macosx;
};
name = Release;
};
Hello,
I'm looking for a method to emulate shift + cmd + 3 (screenshot)
I tried this
cliclick kd:shift,cmd kp:num-3
but it doesn't work.
Any help will be very nice
When attempting to read commands from stdin, so that I could type them line by line into the terminal, by invoking cliclick as cliclick -w 100 -f /dev/stdin
(and a few similar attempts), cliclick simply exits immediately and doesn't read from stdin/the terminal.
I'm doing this because I was trying to control a home theatre app with cliclick, by SSH'ing onto the machine running the home theatre app and having cliclick read from stdin and run commands. Individual commands like cliclick -w 100 kp:return
work over SSH of course, but it's cumbersome to type that for every key, as opposed to typing like:
$ cliclick -w 100 -f /dev/stdin
h
j
k
l
:i
etc
This would allow me to interactively control said home theatre app just by typing into the terminal.
Hi,
Is brew 3.1 already available via brew?
I just wanted to updated to cliclick 3.1 via brew and got this message:
brew upgrade cliclick
Error: cliclick 3.0.3 already installed
When triggering cliclick to perform actions, all other windows/programs are being minimised/hidden?
El Capitan 10.11.1
Hi,
I'm writing a slider for backlit intensity for the mbp 2016 touch bar. I'm using your app to set the value up/down but I can't read the value as Apple removed the old ways of doing it.
Do any one have an idea on how to read the keyboard backlit value ?
It would be cool to suggest a homebrew formula this project
Automatic compile / install with hombrew would be really nice
I was using cliclick and it was working great. I've recently switched to a 15" macbook retina display and now c:500,500 click is vertically somewhere in the middle of the screen. The screen is 2880x1800 so that can't be right.
Are there some scaling adjustments I need to make when working on a retina display?
Some web pages/menus only recognize a click after releasing the mouse,,, a key up.
Using cliclick c
on a menu does not trigger the web page button. The only way to achieve a click on these menus is to use the cliclick dc
option which seems to work. If a ku
in combination with coordinates and not other keystrokes could be programmed into the software that would be helpful.
I really like this small, it's incredible helpful. Is there anyway that I can get the position of cursor on screen ?
Hi Carsten,
After an upgrade to Sierra I had to realize that Karabiner/Seil are not working anymore, for the following use case:
I could, before the update, bind a key to the left mouse button, e.g. in their config format:
KeyCode::D, ModifierFlag::OPTION_R | ModifierFlag::NONE,
PointingButton::LEFT
(and option-r was remapped to caps-lock via seil)
That enabled me to do this:
This was amazingly effective, far more precise then clicking on the trackpad and less strain, basically just like tapping - but without having to move the hand away from the default typing position....
With cliclick I can't get it, since you 'just' support a full click but not a seperate mouse down / mouse up and drag did also not really work, e.g.:
#!/usr/bin/env bash
while true; do
sleep 1
echo down
./cliclick dd:.
sleep 1
echo up
./cliclick du:.
done
and then moving the pointer over text did not select in the browser and also not move any window when I move over its border while the the script is running.
Note: Tried to mess around a few hours with swift and obj.c - but to no success, could not really emulate a left mouse button down / up only, at the current track pad position.
Only managed to get same behaviour like pressing the '5' key on the numeric keyboard when the MouseEvents feature is on - but that allows not to drag, after 5 is down, dragging works then only with the other numeric keys. Crazy...
Maybe you find it trivial, sort of my last hope,
Cheers from Nr. 400 ;-)
Hello, I'm the maintainer of cliclick in MacPorts and I recently updated our port to 3.0.2. It doesn't build for us on Mac OS X 10.6. We see errors like:
KeycodeInformer.m:48: error: expected ')' before 'instancetype'
and:
Actions/KeyBaseAction.m:36: error: expected expression before '@' token
Curiously, although your web page lists 10.6 or later as a requirement, it builds fine on Mac OS X 10.4.
I cannot execute any command.
Hi, I'm trying to use this with Bluestacks and it seems that the cursor is moved to the position but it does not stimulate the clicking. I have tried this with c, dc and tc. Is there a fix for this or a workaround that I could use?
Thanks.
Add a --record SECONDS
option.
I want to record a set of movements (minimum, just X/Y coordinates) with timings for a set number of seconds.
I have a use case where I need the mouse to follow a specific path, currently, am doing while true; do ./cliclick p >> output.txt; done
, and regexing the output.
Unfortunately, there are lots of duplicates during pauses but mostly because I don't know the ms between the pauses or the polling interval since I'm running command-line (re-running the command obviously causes some ms delay, as well as writing to a file). There's no control. I don't know if it's 10ms or 20ms that I've stayed in a certain spot.
A record function could remove duplicate m:x,y
positions, and insert in proper w:ms
commands.
EDIT: sorry, I derped. ./cliclick
actually clicked Close. ;)
I believe this is due to a new version of the OS and/or XCode.
OS version: 10.12.4
XCode Version: 8.3.2
Here's the build:
sandra@MacBook-Pro-2:~/socrates/snapshots/bin/cliclick-master$ make install
cc -include cliclick_Prefix.pch -I Actions -I . -c -o Actions/ClickAction.o Actions/ClickAction.m
cc -include cliclick_Prefix.pch -I Actions -I . -c -o Actions/ColorPickerAction.o Actions/ColorPickerAction.m
cc -include cliclick_Prefix.pch -I Actions -I . -c -o Actions/DoubleclickAction.o Actions/DoubleclickAction.m
cc -include cliclick_Prefix.pch -I Actions -I . -c -o Actions/DragDownAction.o Actions/DragDownAction.m
cc -include cliclick_Prefix.pch -I Actions -I . -c -o Actions/DragUpAction.o Actions/DragUpAction.m
cc -include cliclick_Prefix.pch -I Actions -I . -c -o Actions/KeyBaseAction.o Actions/KeyBaseAction.m
cc -include cliclick_Prefix.pch -I Actions -I . -c -o Actions/KeyDownAction.o Actions/KeyDownAction.m
cc -include cliclick_Prefix.pch -I Actions -I . -c -o Actions/KeyDownUpBaseAction.o Actions/KeyDownUpBaseAction.m
cc -include cliclick_Prefix.pch -I Actions -I . -c -o Actions/KeyPressAction.o Actions/KeyPressAction.m
Actions/KeyPressAction.m:136:51: warning: 'NSSystemDefined' is deprecated: first deprecated in macOS 10.12
[-Wdeprecated-declarations]
NSEvent *e1 = [NSEvent otherEventWithType:NSSystemDefined
^~~~~~~~~~~~~~~
NSEventTypeSystemDefined
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSEvent.h:78:26: note:
'NSSystemDefined' has been explicitly marked deprecated here
static const NSEventType NSSystemDefined API_DEPRECATED_WITH_REPLACEMENT("NSEventTypeSystemDefined", macosx(10....
^
Actions/KeyPressAction.m:147:51: warning: 'NSSystemDefined' is deprecated: first deprecated in macOS 10.12
[-Wdeprecated-declarations]
NSEvent *e2 = [NSEvent otherEventWithType:NSSystemDefined
^~~~~~~~~~~~~~~
NSEventTypeSystemDefined
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSEvent.h:78:26: note:
'NSSystemDefined' has been explicitly marked deprecated here
static const NSEventType NSSystemDefined API_DEPRECATED_WITH_REPLACEMENT("NSEventTypeSystemDefined", macosx(10....
^
2 warnings generated.
cc -include cliclick_Prefix.pch -I Actions -I . -c -o Actions/KeyUpAction.o Actions/KeyUpAction.m
cc -include cliclick_Prefix.pch -I Actions -I . -c -o Actions/MouseBaseAction.o Actions/MouseBaseAction.m
cc -include cliclick_Prefix.pch -I Actions -I . -c -o Actions/MoveAction.o Actions/MoveAction.m
cc -include cliclick_Prefix.pch -I Actions -I . -c -o Actions/PrintAction.o Actions/PrintAction.m
cc -include cliclick_Prefix.pch -I Actions -I . -c -o Actions/RightClickAction.o Actions/RightClickAction.m
cc -include cliclick_Prefix.pch -I Actions -I . -c -o Actions/TripleclickAction.o Actions/TripleclickAction.m
cc -include cliclick_Prefix.pch -I Actions -I . -c -o Actions/TypeAction.o Actions/TypeAction.m
cc -include cliclick_Prefix.pch -I Actions -I . -c -o Actions/WaitAction.o Actions/WaitAction.m
cc -include cliclick_Prefix.pch -I Actions -I . -c -o ActionExecutor.o ActionExecutor.m
ActionExecutor.m:30:10: fatal error: 'ActionClassesMacro.h' file not found
#include "ActionClassesMacro.h"
^
1 error generated.
make: *** [ActionExecutor.o] Error 1
It'd be heaps nice if there was a way to issue scrolling commands - ideally the smooth scrolling kind, not the chunky click mouse wheel variety. Is this a possibility?
The pure X11 (Linux) equivalent to cliclick, called xdotool, allows the user to specify which mouse button is used when sending a click event.
How can you generate keyboard sequences like Copy, Paste etc. ?
I tried 'cliclick kd:cmd t:v ku:cmd' but that just prints out v instead of triggering a copying event.
If this isn't possible yet, I am happy to add something along the line of:
or extend kd, ku to take a key code in addition to the current special keys
Any feedback would be helpful
It could be handy to add a command-line option which takes coordinates, example: cliclick -b 500,400
.
The idea behind this is that sometimes when defining coordinates to be used by cliclick, all coordinates depend on a certain base value. For example, when performing actions in an application window, the click or move coordinates will frequently be fixed relative to the window, but the window could be anywhere on the screen. In this case it would be great to just get the window bounds using AppleScript (or osascript
at the shell) and set the base coordinate to a window corner and specify all distances from that base coordinates. cliclick would then add that base coordinates to all given action coordinates.
As cliclick supports relative coordinates, something similar can be done already using relative values only, but having base coordinates is probably easier to read and write.
I have an old applescript that I wrote a couple of years ago that uses the -q option to get the current mouse position. However, in the current version cliclick -q returns an illegal option error.
I'm using c:x,y to click on an application control, but it does not click on the location sometimes. It seems like the click is initiated but not released. I have used cliclick with OS X 10.9 and 10.10 as well but there was never such an issue. Can you help m fix this?
Quote from cliclick’s help:
If you need to specify absolute negative values in case you have
a setup with a second display arranged to the left of your main display,
prefix the number with “=”, for instance “c:100,=-200”.
Such coordinates are not accepted by cliclick 3.2
I am using the start drag and end drag commands invoked as voice commands from Mac Dragon 6 so that I can drag windows and other UI elements around without having to hold the mouse button down. So, for example, I'll say the command "mouse down" (cliclick dd:+0,+0) to start the drag once my mouse is positioned over a window title bar, then I will move the window using my mouse, and then I will say the command "mouse up" (cliclick du:+0,+0) to end the drag.
All of this works, but the problem I'm having is that while the drag is in progress, the window is not being continuously dragged across the screen; only when I end the drag operation does the window position update.
I'm seeing the same behavior when using this technique to drag objects within a drawing program like Sketch. Scrollbars in the Chrome browser do actively update during the drag, although scrollbars in the Finder do not.
Any ideas why the Mac would not update the position of an element while it is being dragged using these commands?
Thanks!
-rem
Hallo
I just updated to cliclick 4.0b1 from version 3.3 and now I notice that when I do mouse moves the Mouse Cursor doesn't jump anymore, but moves visible from a to b. It moves as if I would use the mouse myself, even slower.
Is this by purpose or intention?
Or is it a setting?
Is it related to my own compiling with XCode and kind of home-made? I set Product > Build For > Running though.
I reverted to 3.3 where it is fast again.
Thanks
frank
First: cliclick is awesome! Congrats BlueM
The current dd and du commands work well when you try to drag an object from one place to another in an immediate action. But I could not find a way of having an ongoing dragging action, which is needed when using cliclick as a component in a remote desktop software (a la RDP or VNC)
Examples:
I could not find a way to do it (possible I just didn't find a existing way), so I took cliclick's code and adjusted actions for dd, du and mm. Happy to share and create a pull request but I couldn't create a separate branch in order to actually create a pull request. BlueM, let me know what I should do, I would love to contribute.
Hallo
on my MacBook Pro from late 2009 (and surely on many other macs) there is the "Eject" Button, this is the very top right key on the keyboard. This is the picture on the key.
There seems no emulation for this button in cliclick.
Is it possible to add it?
Thanks
frank
When in “verbose” mode (-m verbose
), cliclick prints the action (as expected), but does not emulate any key events (= bug).
Example:
cliclick t:'ls -l' kp:return
works as expected
cliclick -m verbose t:'ls -l' kp:return
does not
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)
To make more perceivable what is going on (cf. #23) when events are scripted using cliclick, it would be helpful if clicks could be (optionally) visualized, similar to what some presentation tools (Mouseposé, OmniDazzle, …) offer.
I'm really enjoying this tool - many thanks to the developer. I'm using it to simulate mouse events for a GUI application that lacks fine tuning by keyboard. The issue I'm encountering is that sometimes if I accidentally move the physical mouse while cliclick is executing, the mouse will get stuck in a click until the next cliclick event. Is there any way to disable physical mouse input while cliclick is executing? Thanks!
For example, say I need to move the mouse 50px down. Currently, I must find the current mouse position, then do some math to find the end mouse position. Preferably, we could just send the command m:+0,+50
, to indicate a relative move of +0 on x and +50 on y.
Love the utility!
Hi,
If I have a left and a right Finder's window, and I execute say "cliclick dd:. du:200,300" the current item under the cursor in the right Finder's window is correctly dragged to left window. Ok.
But, if on the left I have an application's window (ImageAlpha) and on the right the Finder's window, the drag command doesn't work anymore (actually neither if the drag command is always run on the app's window without involving the Finder). in short: the cursor moves at the coordinates but any dragging has performed.
So please is there any cliclick tricks to make it work or is it normal?
Just have not found how to ask question, so the question is: how to send shortcut into active windows e.g. ALT+CMD+I, to open Google Chrome Development Tools
Thanks
Hi, not an issue, but an important question: I want to use cliclick to insert text into Sublime. How would I accomplish this? Thanks!
When I run "cliclick t:test" in terminal, I got error: Segmentation fault: 11
Other cliclick option is work fine.
Problem: user reported that after executing the (invalid) command …
cliclick -dd:261,132
… no doubleclicking was performed, but the donations page (invokable via -d
) was opened.
Option -d
should be changed to a character which is not identical to the first character of any of the commands.
Trying to build cliclick 2.2 from source works, but trying to install it fails with:
cliclick.1: No such file or directory
hi, great utility btw...
I'm using it inside app via an embedded ruby api.
I can get a click position from both ruby and cliclick to work out the offset factor to reliably find the window edge for a window drag resize...
that all works, however I can't work out a edge test to ensure I'm not being masked...
I was wondering if 'The resize-left-and-right cursor (resizeLeftRightCursor)' could be tested for and the dd: x,y target modified until true...
e.g. safe = safe + 10 if not left_right_cursor
drag = %Q[dd:#{@edg},#{safe} du:#{sq},+0]
so I guess it's a 'get cursor' function I'm after. e.g. cliclick gc:#{@edg},#{safe}
not convinced i'm making sense, but thought I'd ask...
john
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.