Is this still on the todo list or am I doing this wrong? In the GIF you can see %Variable%ProgressPercent% is increasing but the progress bar is not. I have tried enclosing the AppleScript in a group to see if that would work.
I have made an AppleScript that sends its progress back to a variable that then is put in the Progress bar with no success.
AppleScript with Progress Variable
tell application "Keyboard Maestro Engine"
-- Get the values of the KM variables "FindText" and "ReplaceText"
set findText to getvariable "FindText"
set replaceText to getvariable "ReplaceText"
end tell
tell application "Keyboard Maestro"
set selectedMacrosList to get selectedMacros
-- Get total count for progress calculation
set totalMacros to count of selectedMacrosList
set currentMacro to 0
-- Set initial progress
tell application "Keyboard Maestro Engine"
setvariable "ProgressPercent" to "0"
end tell
repeat with theMacro in selectedMacrosList
set macroName to name of macro id theMacro
-- Replace all instances of FindText with ReplaceText
set newMacroName to my replaceTextInString(macroName, findText, replaceText)
-- Update the macro name
set name of macro id theMacro to newMacroName
-- Calculate and update progress
set currentMacro to currentMacro + 1
set currentProgress to ((currentMacro * 100) / totalMacros) as integer
tell application "Keyboard Maestro Engine"
setvariable "ProgressPercent" to currentProgress as text
end tell
end repeat
end tell
-- Helper function to perform the text replacement
on replaceTextInString(originalText, findText, replaceText)
set AppleScript's text item delimiters to findText
set textItems to text items of originalText
set AppleScript's text item delimiters to replaceText
set newText to textItems as string
set AppleScript's text item delimiters to {""} -- Reset text item delimiters
return newText
end replaceTextInString
Here is the full macro if that helps.
Prompt to Replace Text for All Selected Macros
01)Text Replacement - (1) Prompt to Replace Text for All Selected Macros.kmmacros (51 KB)
Seems like this is supposed to be working from what I can tell in other forum posts.
I even tried turning the calulation into a text token and it still didn't work.