Skip to content

Prevent multiple instances (double hotkey registration doubles click rate) #50

Closed

Description

@TMHSDigital

Summary

Launching the app twice registers the F6/F7/ESC global hotkeys twice. One F6 press then starts two click loops at the same target, which doubles the click rate. Each instance's runaway guard only counts its own clicks, so neither one trips. Both instances also write the same settings file.

Evidence

  • autoclicker/app/hotkeys.py — keyboard.add_hotkey registrations are process-local and don't conflict across processes.
  • autoclicker/main.py — no instance check.
  • core/settings_paths.py — both processes write %APPDATA%\WindowsAutoclicker\autoclicker_settings.json (atomic, but last writer wins).

Suggested approach

At startup, create a named mutex (win32event.CreateMutex(None, False, "Local\TMHSDigital.WindowsAutoclicker"); pywin32 is already a dependency). If GetLastError() == ERROR_ALREADY_EXISTS, bring the existing window to the front (FindWindow + SetForegroundWindow) and exit.

Done when

A second launch focuses the first instance and exits, and a unit test covers the already-running branch with the win32 calls mocked.

Activity

  1. added
    bug
    priority: medium
    safety
    on Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority: mediumsafety

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions