Skip to content

Show Real-Time CPS Score in Menubar#6

Open
O-mkar wants to merge 2 commits intoWorldOfBasti:masterfrom
O-mkar:feature/cps-score-display
Open

Show Real-Time CPS Score in Menubar#6
O-mkar wants to merge 2 commits intoWorldOfBasti:masterfrom
O-mkar:feature/cps-score-display

Conversation

@O-mkar
Copy link

@O-mkar O-mkar commented Feb 28, 2026

🎯 Overview

Displays the live Clicks Per Second score next to the menubar icon while the auto-clicker is running. The score clears automatically when the clicker stops.

📐 Formula

CPS = Total Clicks ÷ Total Elapsed Seconds

Same cumulative-average approach used by cpstest.org. The value starts high on the first tick and converges smoothly — e.g. 1.03 → 5.48 → 9.97 → 10.02.


🔧 Changes

2 files changed · 19 insertions · 3 deletions

AutoClicker.swift

  • Added clickStartTime: TimeInterval? — records ProcessInfo.systemUptime when the clicker starts
  • Computes CPS on the main thread each timer tick (before the background click dispatch):
    let measuredCPS = Double(clickCount + 1) / elapsed
  • Posts .cpsUpdated notification with current CPS each tick; posts cps: 0.0 on stop
  • Added Notification.Name.cpsUpdated extension
  • Bug fix: right mouse-up was incorrectly sending .leftMouseUp in both branches of the clicker timer ternary
  • Bug fix: stopClicker() now dispatched to main thread when triggered from the click-limit background block

AppDelegate.swift

  • Registers for .cpsUpdated in applicationDidFinishLaunching
  • Updates statusItem.button?.title to " X.XX" when active, "" when stopped

…tive

- AutoClicker: track click timestamps in a 1-second sliding window
  (recentClickTimes: [TimeInterval]) on the main thread; post .cpsUpdated
  notification with measured CPS = count of clicks in last 1 second after
  each timer tick; post cps: 0.0 and clear window when clicker stops
- AutoClicker: dispatch stopClicker() to main thread when click limit is
  reached from background thread, ensuring safe access to recentClickTimes
- AutoClicker: fix pre-existing bug where right mouse-up was sending
  leftMouseUp in both branches of the clicker timer ternary
- AppDelegate: observe .cpsUpdated and set statusItem.button?.title to
  " N" (integer CPS) when active and "" when stopped; space provides
  visual separation from the icon

Made-with: Cursor
…tive

- AutoClicker: track clickStartTime (systemUptime) on startClicker and
  compute CPS = totalClicks / elapsedSeconds each timer tick — same
  cumulative-average formula used by cpstest.org (score / elapsed)
- AutoClicker: reset clickStartTime and clickCount on stop, post
  cps: 0.0 via .cpsUpdated notification to clear the menubar title
- AppDelegate: observe .cpsUpdated and set statusItem.button?.title to
  " X.XX" (2 decimal places) when active, "" when stopped

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant