Hi everyone,
I'm trying to run this Applescript in KM but the KM engine is stuck when running the macro.
The script works perfectly when running from the Apple Script Editor app.
Is there anything incompatible with KM?
Maybe the ASCII number syntax in the Hash function at the end?
Thank for your help
-- Single function script to detect changes in Apple Reminders for Notion, SELF and WORK lists
-- Optimized for speed and compatibility with Keyboard Maestro
on run
-- Target lists to monitor
set targetLists to {"Notion", "SELF", "WORK"}
set combinedState to ""
tell application "Reminders"
-- Process only the targeted lists
repeat with listName in targetLists
try
set currentList to list listName
-- Add list name to combined state
set combinedState to combinedState & listName
-- Get only incomplete reminders in this list
set incompleteReminders to (every reminder in currentList where completed is false)
-- Get essential data for each reminder
repeat with aReminder in incompleteReminders
-- Just add name and ID - the most important identifiers
set combinedState to combinedState & id of aReminder & name of aReminder
-- Add priority only if it's set
try
set priorityValue to priority of aReminder
if priorityValue > 0 then
set combinedState to combinedState & priorityValue as string
end if
end try
-- Add due date only if it exists (in simplified format)
try
if due date of aReminder is not missing value then
set combinedState to combinedState & (due date of aReminder as string)
end if
end try
end repeat
on error errMsg
-- Skip if list doesn't exist, but don't output error to avoid Keyboard Maestro issues
end try
end repeat
end tell
-- Fast hash function integrated directly
set hashValue to length of combinedState
set charList to characters of combinedState
-- Only process a subset of characters to improve speed
repeat with i from 1 to count charList by 3
set thisChar to item i of charList
set asciiValue to ASCII number thisChar
set hashValue to (hashValue * 17 + asciiValue) mod 1.000000007E+9
end repeat
-- Ensure non-zero result
if hashValue = 0 then
set hashValue to 1
end if
return hashValue
end run