A short, simple Objective-C program written to a source file (e.g. mouse.m) that can be compiled with Clang on the command-line into a Unix Executable File for placement in a directory in the $PATH variable such as /usr/local/bin.
When run on the command-line in a Bash shell, or used in AppleScript’s do shell script command, the program detects whether no mouse button is pressed down, the left mouse button is pressed down, or the right mouse button is pressed down. In Terminal it might look like this after each press of the Return key:
bash-3.2$ mouse
none
bash-3.2$ mouse
left
bash-3.2$ mouse
right
// Extensive commenting in the code is an asset. Provide the compile command, e.g. clang mouse.m -framework Cocoa -o mouse
I retain all rights and privileges to the source code and any product thereof, and may freely distribute the same without attribution.
A price quote as per the above description. Options to be priced separately:
A second version of the program written in Swift.
Detection of a trackpad click and secondary click.
Hi,
I have prepared the code that fulfills your requirement, both in Objective-C and Swift. It works both for mouse and trackpad (without distinguishing those events).
When run, it reads the state of mouse and prints the required output. Objective-C code will work on 10.6 or newer systems, Swift will run on all systems that support swift.
Regards,
Jacek