Ready-to-use Code ExampleKVProductivityCounterDateTime

Daily Click Counter (KV)

Uses the macro’s persistent KV store to keep a daily click, run, or event counter. `KV.increment` raises the counter and returns the new value; counters survive script restarts. A date-based key (yyyy-MM-dd) keeps a separate count per day.

Completion, parameter hints and type checking. Installation instructions and downloads are hosted on GitHub.

Copyable Example Code

You can paste this into the code editor; still verify target image, region, color, text, and timing values in your own device flow.

-- Daily click counter
-- KV.increment raises a counter, KV.has checks a key

local today = DateTime.now():format("yyyy-MM-dd")
local key = "clicks_" .. today

-- First run of the day
if not KV.has(key) then
  toast("New day: " .. today)
end

-- Raise the counter and read the new total
local total = KV.increment(key, 1)
toast("Clicks today: " .. total)

-- Alert at a threshold
if total == 100 then
  System.vibrate(200)
  System.noti("100 clicks reached today (" .. today .. ")")
end

-- How many days are stored
if KV.size() > 7 then
  local allKeys = KV.keys()
  toast("Stored days: " .. #allKeys)
end

Implementation and Adaptation Notes

  • Before running, replace sample values such as image names, text, colors, coordinates, and file paths with your own macro values.
  • For examples that use Region or coordinates, retest the target area on different resolutions and DPI values.
  • Tune mScore, timeout, and scan rate in a test macro first, then move the verified values into the production macro.