Sorry for the newbie question, but I am trying to step through an AppleScript and nothing is happening. Watched the new user videos, have enabled Full Disc access but after enabling debugging and then click the step button in the tool bar, nothing happens (unlike in the video). I’m must be missing something obvious - any ideas?
Hey Michael,
Welcome to the forum!
Post the script you’re working with, so we can test and see…
-Chris
Here you go
-- Manage Server Spam application
-- Save as Application in script editor to Applications folder
-- Customize to delete problematic spam that rules won't address
-- 12/30/22 - Michael Lines - Initial version
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
on idle
-- This is executed periodically when the script is run as a stay-open application.
my deleteSpam()
return 60 -- Run every minute
end idle
on deleteSpam()
tell application "Mail"
check for new mail -- Refresh/sync mail
--
-- Loop through all junk messages
--
set myJunkList to every message of junk mailbox
repeat with junkMsg in myJunkList
--
-- Mark all junk messages as read & junk
--
set junkMsg's read status to true
set junkMsg's junk mail status to true -- mark junk to protect privacy
--
-- Delete known junk mail
--
if junkMsg's source contains "please don't use a VPN" or (junkMsg's recipient is not "mlpobox@icloud.com" and junkMsg's source contains "dmarc=fail") then
set junkMsg's background color to red -- To make them easy to spot and not open
delete junkMsg
end if
--
-- Move all remaining server caught spam messages to separate junk folder
--
if junkMsg's source contains "X-Apple-Movetofolder: Junk" then
move junkMsg to mailbox "Junk/Server_Spam" of account "iCloud"
end if
end repeat
end tell
end deleteSpam
Sorry, not sure why this is not all formatting correctly
To clarify - I compile, turn on debug, click on any line and then click on the step button - nothing happens
Nothing is happening because there is no on run
handler.
To step into your on idle
handler you need to use the Idle event simulator:
This is also available from the Script > Step Into sub-menu.
2 Likes
That was it - thank you!
You can’t step through this script because there not a run handler or any top level commands.
If you type:
in the first line, then you will be able to step into your handler.