Post

Replies

Boosts

Views

Activity

Reply to Applescript text item delimiters not working
Your variable originalDateString got coerced to a list in your bigger script. from "Mon 22nd April" to {"M", "o", "n", " ", "2", "2", "n", "d", " ", "A", "p", "r", "i", "l"} so, text item 3 in the list is "n". place in your code, before setting the text item delimiter set originalDateString to originalDateString as text . Text item delimiter. I don't bother to save it to a variable "tid". I just set it back to it's default "", an empty string. Text item delimiters only changes when we temporarily need it. By saving it to a variable you might backup an uncorrect tid and restore this mistake. So, set it to it's default "". handler based on your example set originalDateString to items of "Mon 22nd April" -- 'items of' to test with a list set dateItems to my getDateItems(originalDateString) -- 'dateItems', list of 3 items -- or declare 3 variables at once set {dayOfWeekAbbrev, dayOfMonth, monthName} to my getDateItems(originalDateString) on getDateItems(someText as text) try set AppleScript's text item delimiters to " " set {ti1, ti2, ti3} to {text item 1, text item 2, text item 3} of someText set AppleScript's text item delimiters to "" return {ti1, ti2, ti3} on error errorMessage number errorNumber set AppleScript's text item delimiters to "" error ((name of me) & linefeed & "....> getDateItems()" & linefeed & linefeed & errorMessage) number errorNumber end try end getDateItems
Oct ’24
Reply to Applescripting Chrome email
short answer: NO Long answer: Possible, but you will have to learn javascript. This is the same for every browser, they offer commands and classes to manipulate the window and tabs and only one command to manipulate HTML through javascript. For Google Chrome that's the command "execute". With this command you can do what ever javascript can do, but you have to know/learn the language.
3w
Reply to AppleScript to Automate Envelope Printing
Warning, while I'm familiar with AppleScript, not so with scripting Word. I checked the dictionary and oh boy, the number of commands and classes is quite overwhelming. I'm impressed by the extent that Microsoft made Word scriptable. But for a beginner maybe the worst application to start scripting. The command you use, print out, is deprecated and Microsoft recommends to use the Standard Suite command print, which is the standard print command for most applications. Nonetheless I tried both commands. Only with the Standard Suite command 'print' I could print. But only after I saved the document first. With a new unsaved document it does not work. That said, GUI scripting is a the rescue for such cases. Also for cases where the application is not scriptable and has no dictionary! GUI scripting is done through the application 'System Events'. We have 2 commands availble, keystroke and click. Keystroke, as the name implies, simulates a keystroke. The only requirement is to make sure the application is frontmost. tell application "System Events" tell application process "Word" set frontmost to true -- to make sure the next command, keystroke, is send to Word keystroke "p" using {command down} end tell end tell Click a menu item, File > Print ... tell application "System Events" to tell application process "Word" to click menu item "Print..." of menu 1 of menu bar item "File" of menu bar 1 hope this helps
3w
Reply to Applescript seems to run in Rosetta on M2
I interpret the error in a different way. Can't load Perl Encode.bundle ... trie another ... failure ... ... trie another ... failure, can't find the other ... trie another ... failure and each time (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')) I read this as, tried to open Perl encode.bundle, it's a mach-o file and you have 64 while this file needs x86_64. Looks like a Perl issue not a AppleScript issue. Don't know the script and thus don't know how you make the call to Perl.
3w
Reply to Sonoma: Is It No Longer Possible to Fetch Wallpaper File Names?
Hi, don't have Sonoma, but following script works for me in Sequoia 15.1. I used two shell commands to get the trick done, pgrep and lsof. lsof is nice to figure out which process is using a file. So, I made a folder with a few pictures, played with the wallpaper settings and found that the pictures were used by process WallpaperImageExtension. And because lsof also works the other way, which files a process is using, we can use WallpaperImageExtension to figure out the path(s) to the desktop pictures. pgrep is only used in the script to reliably find the pid of WallpaperImageExtension process, which changes after each reboot. the handler returns a list of aliases. The number depends on the number of spaces in use. Handler only looks for pictures, so it returns 'missing value' if the wallpaper was set to a movie. on getDesktopPicture() tell application "Finder" if desktop picture is missing value then return missing value if class of desktop picture is document file then return {dp} set folderPath to POSIX path of (desktop picture as alias) set pid to do shell script "pgrep WallpaperImageExtension" set lsofResult to do shell script "lsof -p " & pid & " | grep -o '" & folderPath & ".*$'" set {filePaths, fileList} to {(every paragraph of lsofResult) as list, {}} repeat with f in filePaths set end of fileList to (f as POSIX file as alias) end repeat return fileList end tell end getDesktopPicture
2w
Reply to No result from AppleScript Calculator
Hi first the code tell application "Calculator" to activate tell application "System Events" to tell application process "Calculator" set frontmost to true keystroke "(6+2)*20=" repeat 10 times click menu item "Copy" of menu 1 of menu bar item "Edit" of menu bar 1 if (the clipboard) is not "" then return the clipboard delay 0.3 end repeat end tell UI scripting is much easier if you write your code within a "System Events" block instead of the application's block. You are scripting System Events, not the application. With UI scripting you have to deal with delays and they vary. Even triggering the same action on a menu/button/... can vary over time. If you just use an arbitrary number like delay 0.1. You will have to set that number to the maximum time if you want that script to work 100% of the time. Wich means, you also wait 100% of the time longer than you have too. With a repeat loop you can set a maximum time you want to wait but don't have to wait that long if it's not necessary. repeat 10 times click menu item "Copy" of menu 1 of menu bar item "Edit" of menu bar 1 if (the clipboard) is not "" then return the clipboard delay 0.3 end repeat or exit repeat instead of return if you want to do more after the repeat. if (the clipboard) is not "" then exit repeat ______ Not sure what you try to achieve here. If it's just calculations, then there are better ways to do it. Best to avoid UI scripting if you can. UI scripting is used when you have no other options. But on the other hand, it has saved my bacon so many times.
6d