Post

Replies

Boosts

Views

Activity

Reply to Seeking suggestions - how to have versions of an Automator service workflow
If all you are doing is reading the XML file, I'm not sure what would corrupt it, but an idea similar to the AppleScript comment would be to add a variable to the workflow (both would be in the file). In a workflow's bundle, the /Contents/document.wflow file is a property list that declares the various actions with their settings (such as the script for the Run AppleScript action), action connections, workflow metadata, and any variables. By adding a variable for a version number to the workflow, your script can just look for the variable name and get its value instead of adding a file to the bundle - System Events includes a Property List Suite, so you can do something like: on run -- example set plistFile to (choose file with showing package contents) -- get the document.wflow file set variables to getPlistElement from {plistFile, "variables"} if variables is not missing value then repeat with anItem in variables -- multiple variables if |name| of anItem is "Version" then -- or whatever return first item of value of anItem -- the value is a list end if end repeat return missing value -- not found end run to getPlistElement from plistItems -- get specified element from plist structure by name or index try if (count plistItems) < 2 then error "item list contains too few items" tell application "System Events" set element to property list file ((first item of plistItems) as text) -- root element repeat with anItem in rest of plistItems -- add on the sub items set anItem to contents of anItem try -- handle an index number set anItem to anItem as integer end try set element to (get property list item anItem of element) end repeat return value of element end tell on error errmess number errnum -- not found, etc log "getPlistElement error: " & errmess & " (" & errnum & ")" -- or pass it on return missing value end try end getPlistElement
Feb ’22
Reply to Applescripting multi strings into one
To make sure a string is defined, you can initially declare it as an empty string, then replace the value as needed. Also, instead of 10 different variables, just use a list - that is what they are for. Since the strings are in a fixed order, items in a list can be assigned according to the selections, then the list coerced to a string, which will add them all together (selected or not): set stringsList to {"", "", "", "", "", "", "", "", "", ""} -- 10 items set the choices to {"Music Sharing", "Remove Network Icons", "Dual - Galley & Active", "HD video", "Hide Menu", "Hide Reactions", "Remove All Overlays", "Dual - Galley x2", "Remove Names", "Other"} set the response to (choose from list choices with prompt "Select Advanced Dial String Command(s). Use Command (⌘) to select multiple." with multiple selections allowed and empty selection allowed) if the response is not false then repeat with anItem in the response if contents of anItem is "Music Sharing" then set item 1 of stringsList to "306" if contents of anItem is "Remove Network Icons" then set item 2 of stringsList to "307" if contents of anItem is "Dual - Galley & Active" then set item 3 of stringsList to "308" if contents of anItem is "HD video" then set item 4 of stringsList to "309" if contents of anItem is "Hide Menu" then set item 5 of stringsList to "504" if contents of anItem is "Hide Reactions" then set item 6 of stringsList to "508" if contents of anItem is "Remove All Overlays" then set item 7 of stringsList to "606" if contents of anItem is "Dual - Galley x2" then set item 8 of stringsList to "608" if contents of anItem is "Remove Names" then set item 9 of stringsList to "102" if contents of anItem is "Other" then set item 10 of stringsList to text returned of (display dialog "Enter other advanced string command(s)" default answer "") end repeat return the stringsList as string
Jul ’22
Reply to Click Drag function. Need Help with this Script I get Syntax Errors.
You get errors from stuff like declaring a handler in a tell statement, missing handlers or applications that perform commands such as mouse up, mouse move, and get mouse location, bad syntax for several if statements, and just bad formatting in general.  This script has no chance of running - where did you get it or the commands you are trying to use?
Feb ’23
Reply to i've noticed many times that applescript doesn't take this syntax
Make a note to post actual code, never pictures of code - you aren’t going to get many replies when people have to type in your script or debug formatting errors from the text recognition framework. The error is from trying to use Reminders to get the start date of a Calendar event. You need to target the appropriate application to use its terminology, for example: -- Set the names of your calendar and reminders set calendarName to "appts" set remindersName to "appts" -- Get the current date and time set currentDate to current date -- Get the events from the calendar tell application "Calendar" set calendarEvents to every event of calendar calendarName whose start date is greater than currentDate repeat with theEvent in calendarEvents set eventTitle to summary of theEvent set eventStartDate to start date of theEvent set eventNotes to description of theEvent if eventNotes is missing value then set eventNotes to "(no notes)" -- Create a new reminder with the event details tell application "Reminders" to tell list remindersName make new reminder with properties {name:eventTitle, due date:eventStartDate, body:eventNotes} end tell end repeat end tell
May ’23