Post

Replies

Boosts

Views

Activity

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 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 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 Applescript templates
Templates are more for a script or application skeleton/layout than for small pieces of code. In the Script Editor, the right-click contextual menu has items for inserting various statements; another option would be to create your own scripts for inserting code snippets and place them in the Script Menu, for example: set theCode to "display dialog \"Question?\" default answer \"answer\" buttons {\"Other\", \"Cancel\", \"OK\"} default button \"OK\" cancel button \"Cancel\" with title \"title\" with icon note giving up after 5" tell application "Script Editor" to tell front document set contents of selection to theCode try check syntax on error errmess display alert "Syntax Error" message errmess end try end tell Also note that these are not social media or chat forums - it may take a while for topics to be read and/or answered.
Oct ’21