Skip to content

Latest commit

 

History

History
186 lines (128 loc) · 4.6 KB

File metadata and controls

186 lines (128 loc) · 4.6 KB

autoclick

A small, dependency-free Rust autoclicker that clicks after the mouse moves and then stops.

The main use case is dwell clicking: move the pointer to a target, stop moving, and let the app click for you after a configurable delay.

Features

  • Clicks only after pointer movement has been observed.
  • Waits for the pointer to remain still for a configurable idle delay.
  • Clicks once per movement-stop cycle, then waits for movement again.
  • Cancels a pending click when keyboard activity is detected, so hotkeys keep working.
  • Supports left, middle, and right click.
  • Reads configuration from ~/.autoclick.
  • Installs a background runner for Linux, macOS, and Windows.
  • Uses native OS APIs directly; no Rust crate dependencies.

Platform Support

Platform Backend Notes
Linux /dev/input/event* + /dev/uinput Works below both X11 and Wayland. Requires root or equivalent device permissions.
macOS CoreGraphics Requires Accessibility permission.
Windows User32 Uses GetCursorPos and SendInput.

Linux And Wayland

Wayland does not provide a standard global pointer-position or synthetic-click API for normal applications. On Linux, autoclick therefore uses kernel input devices instead of display-server APIs:

  • pointer motion is read from /dev/input/event*
  • keyboard activity can be used as a guard filter to cancel pending clicks
  • clicks are injected through /dev/uinput
  • keyboard-only devices are ignored using evdev capability checks

This makes the Linux backend display-server-independent, so the same implementation is used for X11 and Wayland.

Build

cargo build --release

The binary will be at:

target/release/autoclick

Configuration

autoclick reads ~/.autoclick by default. Create the default config with:

target/release/autoclick config

Default configuration:

# autoclick configuration
# The app clicks once after the pointer moves, then remains still for idle_ms.
enabled = true
idle_ms = 700
poll_ms = 50
keyboard_guard = true
button = left
max_clicks = unlimited
dry_run = false

Config keys:

Key Values Description
enabled true, false Enables or disables the autoclick loop.
idle_ms integer How long the pointer must be still before clicking.
poll_ms integer How often to poll pointer movement.
keyboard_guard true, false Cancels a pending click when keyboard activity is detected.
button left, middle, right Mouse button to click.
max_clicks integer, unlimited, none Optional limit before the process exits.
dry_run true, false Log would-be clicks without injecting real clicks.

repeat_ms is accepted for compatibility with older config files, but current behavior is intentionally one click per stop.

To use a different config path:

AUTOCLICK_CONFIG=/path/to/config autoclick run

Run

Linux requires elevated input-device access:

sudo target/release/autoclick run

macOS and Windows can run as the current user:

target/release/autoclick run

On macOS, grant the executable Accessibility permission in System Settings.

Install As A Background Service

Build the release binary first:

cargo build --release

Linux:

sudo target/release/autoclick install
sudo target/release/autoclick uninstall

The Linux installer creates:

/etc/systemd/system/autoclick.service

When installed with sudo, the service stores AUTOCLICK_CONFIG in the unit so the root-running service still reads the invoking user's ~/.autoclick.

macOS:

target/release/autoclick install
target/release/autoclick uninstall

The macOS installer creates:

~/Library/LaunchAgents/dev.autoclick.autoclick.plist

Windows:

autoclick.exe install
autoclick.exe uninstall

The Windows installer creates a Task Scheduler task named autoclick.

Safety

Autoclicking can interact with whatever is under the pointer. Test with:

dry_run = true
max_clicks = 1

On Linux, the daemon runs with elevated privileges because it needs /dev/input/event* and /dev/uinput. Review the code and configuration before installing it as a service.

Development

Format and check:

cargo fmt --check
cargo check

Cross-target type checks used during development:

cargo check --target x86_64-pc-windows-gnu
cargo check --target x86_64-apple-darwin

License

Licensed under either of:

at your option.