4

Objective: To process an AppleScript list of strings so that each string is filtered to remove any non-digit character followed by all leading zeroes. Resultant empty strings are discarded. property digits : "0123456789" property text item delimiters : {} set L to {"abc", "qwerty.24", "01 abc23xyz", "123abc456", "2.1abc", "20"} repeat with textItem in L ...


4

You can use random number, e.g.: set timeDelay to random number from 18 to 58 delay timeDelay Or any integer values you wish. For more information about random number click the link. Also have a look at: AppleScript Language Guide


3

You could try converting items in the list to the desired class, and ignore the ones that error: set theNumbers to {} set theList to {"123", "124", "abc", "125", "efgh", "126"} repeat with anItem in theList try if contents of anItem is not "" then set the end of theNumbers to anItem as number on error errmess number errnum -- didn't convert log ...


2

Here's an alternative implementation that will be faster and is a lot more compact: set L to {"1", "", "", "apple", "acda", "", "3454", "ImportantStuff", ¬ "important1", "important2", "NotImportantStuff", "2", "", "efrg"} set {i, j} to {1, -1} tell L repeat until item i = "ImportantStuff" set i to i + 1 end repeat repeat until item ...


2

Submitting a separate answer, as it is entirely distinct from my first in that it solves the issue at hand. Credit goes to @user3439894 who pointed the OP and I to a link (Toggle caps lock programmatically) that features some source code written in C that can programmatically toggle/set the state of the caps lock. Thus credit goes also to the original ...


2

The following script works but it needs to open (and close) a Finder window. Save this to maccopy: #!/usr/bin/osascript on run args set theFile to (POSIX file (first item of args)) as alias tell application "Finder" reopen activate set selection to {} reveal theFile end tell delay 1 tell app "System Events" keystroke ...


2

Save whatever script you wish to a file and when you change the extension to .command Finder will robustly make a command line window that’s new to run that command / script. This works for whatever #!/bin/whatever shell or script you start the text file. AppleScript can open documents just like when Finder clicks on them to open, this should be a fairly ...


2

The final line of your script is using curved quoted instead of straight quotes. “ and ” have been used in place of ". Replace the line send “ssh-add etlbi-master” with send "ssh-add etlbi-master" Look at the syntax highlighting of your script in your question — the ‘string’ is not red but black.


1

The currently logged in Apple IDs for iCloud are stored in the MobileMeAccounts preferences. You can query the entire store with: defaults read MobileMeAccounts Accounts To return just the first account ID (an email address nowadays): /usr/libexec/PlistBuddy -c "print :Accounts:0:AccountID" ~/Library/Preferences/MobileMeAccounts.plist


1

Here is some AppleScript that should help. To select the move folder you would use set moveFolder to POSIX path of (choose folder with prompt "Choose the folder you would like to move") and for setting the destination folder you would write set aFolder to POSIX path of (choose folder with prompt "Choose the Application you would like to copy items to") ...


1

keystroke "120" is not the same as key code 120; the former taps the keys 1, 2, and 0. I've had success with the following AppleScript, but you can also try key code 120 and key code 113. tell application "System Events" to key code 144 using command down


1

Restarting the Mac fixed the issue for me. I can now set the screen brightness alright. Apparently it's a mysterious bug in macOS.


1

If you have: set Q to {"a", "b", "c"} You can then do: set Q to (Q as string) as list (Q as string) coerces the Q list {"a", "b", "c"} into a string, "abc", and as list turns the string into a list item assigned to Q. Not necessary, but if you also add: return Q Just to see what it returns, it will return: {"abc"} Which is what you wanted.


1

I'd look into what can be done with applescript using the scripting dictionary. script editor > file > open scripting dictionary I do not know the details of what you are doing but here are some coloring options.


1

Modifying your original attempt: set myList to {"30.00", "30.00"} set myFinalTotal to 0 repeat with x in myList set myFinalTotal to myFinalTotal + x end repeat myFinalTotal And for the joy of learning: Recursive: to sumItems from L as list if L = {} then return 0 (L's first item) + (sumItems from the rest of L) end sumItems Iterative: to ...


1

I finally got an error message which answered my question: com.automator.runner.xpc is not allowed to send keystrokes.


1

You need to use a different name for your repeat statement’s loop variable - the term name is an AppleScript property and is also in System Events scripting dictionary. Your usage isn’t generating a syntax error, but it is probably causing more confusion than usual and is winding up targeting the wrong item (welcome to AppleScript). You can use pipes ...


1

found this on Macscripter.net I think it is what you are looking for: tell application "Microsoft Excel" tell active sheet select used range end tell end tell


1

The following works for me: set SuperSleep to (do shell script "pmset -g | awk '/SleepDisabled/{print $2}'") if SuperSleep is equal to "0" then do shell script "pmset -a disablesleep 1" with administrator privileges else do shell script "pmset -a disablesleep 0" with administrator privileges end if NOTE: Do not use sudo in a do shell script ...


1

Though not exactly the same thing, a similar action might be to simulate the shift key being held down. You can command System Events to keep the shift key down until you command it to be reset: tell application "System Events" to key down shift To reset: tell application "System Events" to key up shift It has obvious differences to activating caps lock,...


1

It's because you are supplying dates in the format dd-mm-yyyy, where you need to be supplying them in the format yyyy-mm-dd. So your creationDate was already in the correct format before your script adjusted it. There's no need to replace slashes with hyphens—the handler is, for the most part, indifferent to the delimiter being used (notable exceptions ...


1

Yes. You could use this: tell application "Microsoft Word" set theDoc to document 1 return document property "Number of words" of theDoc end tell Since you asked for the word count of "the currently open Microsoft Word® document" this does it. This script works ONLY in the case where you have a single Word document open. It works for Word 2011 ...


1

Manual Filter One approach is to manually filter the list with a repeat loop: set theList to {"1", "", "", "apple", "acda", "", "3454", "ImportantStuff", "important1", "important2", "important3", "NotImportantStuff", "2", "", "efrg"} -- put the filtered items into subList set subList to {} -- note when iterating through important items set ...


1

I'm not sure I understand your question exactly. But, if all of the tables are on one sheet, and all of the tables need to get the same new column and the same column title, this will work. Screenshot of Numbers document with three tables on the sheet, before running the script. Screenshot of Numbers document with three tables on the sheet, with column ...


1

You can schedule shutdown's and restarts directly from within ARD, no scripting needed.


1

If you want to run sudo command with ARD select run command as User and written root. Edit : It doesn't have to go through the osascript to turn it off. A shutdown -h now with root user is enough You can also shutdown the station via the Manage menu


Only top voted, non community-wiki answers of a minimum length are eligible