applescript

is there something akin to regEx in applescript, and if not, what's the alternative?

删除回忆录丶 提交于 2019-12-17 15:26:00
问题 I need to parse the first 10 chars of a file name to see if they are all digits. The obvious way to do this is fileName =~ m/^\d{10}/ but I'm not seeing anything regExy in the applescript reference, so, I'm curious what other options I have to do this validation. 回答1: Don't despair, since OSX you can also access sed and grep through "do shell script". So: set thecommandstring to "echo \"" & filename & "\"|sed \"s/[0-9]\\{10\\}/*good*(&)/\"" as string set sedResult to do shell script

Applescript: on clicking Menu Bar item via gui script

让人想犯罪 __ 提交于 2019-12-17 08:53:36
问题 I'm trying to make an applescript for an application called F.lux that clicks the menu item "Disable for an Hour" as indicated in the screenshot below: The element path is indicated in the screenshot below: Here is my code thus far: tell application "System Events" tell process "Flux" click (menu bar item 1 of menu bar 2) click menu item "Disable for an hour" of menu 1 of menu bar item 1 of menu bar 2 end tell end tell Everything compiles fine, however I keep getting the error message below

Expand a POSIX path with prefix “~” (using AppleScript)

被刻印的时光 ゝ 提交于 2019-12-14 03:59:13
问题 StandardAdditions has the path to command and we can use it to get known locations. For example, path to home folder returns a file reference to the user folder and if we want the posix path , we can do POSIX path of ((path to home folder) as text) . In Terminal.app we can use the tilde character ( ~ ) to represent the home folder . How can we do this tilde expanding in AppleScript ? 回答1: Started with OS X 10.10 you can easily access Cocoa classes and their functions and properties: use

Change the icon of an applescript-called notification

流过昼夜 提交于 2019-12-14 03:43:41
问题 With OSX Mavericks we now can make notifications with applescript pretty easily. However, there doesn’t seem to be a way to change the icon that appears to a custom one. Is there a way to accomplish this? 回答1: display notification will take application icon. You can set icon in bunlde content of applescript application. set fileName to choose file "Select a Folder" display notification "Parag Bafna" subtitle "Its working" & fileName display notification text required with title text optional

Applescript: number list of words according to their occurrence in the sequence

谁说我不能喝 提交于 2019-12-14 03:36:28
问题 So I have this list of words: {"It", "was", "the", "best", "of", "times", "it", "was", "the", "worst", "of", "times", "it", "was", "the", "age", "of", "wisdom", "it", "was", "the", "age", "of", "foolishness", "it", "was", "the", "epoch", "of", "belief"} I'd like each occurrence of a word to be numbered according to the number of times it has occurred in the sequence: {"It", 1}, {"was", 1}, {"the", 1}, {"best", 1}, {"of", 1}, {"times", 1} {"it", 2}, {"was", 2}, {"the", 2}, {"worst", 1}, {"of",

AUTOMATOR - Trying to issue a command inside a shell script with parameters received from AppleScript

笑着哭i 提交于 2019-12-14 03:07:23
问题 I am creating this automator script for macOS that receives videos and extract a frame at a given time in seconds. After receiving the videos from finder, it runs this applescript asking for the time in seconds, to extract the frame. The time is stored into the Applescript variable "seconds". When the applescript ends, I have 3 variables: inputVideo, containing the POSIX input video path outputVideo, containing the POSIX output video path seconds, containing the time in seconds. The

Looking for an Applescript to find files and move them to different folder

岁酱吖の 提交于 2019-12-14 03:05:12
问题 I'm trying to find a script to find and move files to a different folder. I've got a folder with hundreds pictures like this: PA-600-01.jpg, PA-600-02.jpg, PA-600-03.jpg, PA-600-04.jpg, PA-601-01.jpg, PA-601-02.jpg, PA-601-03.jpg, PA-602-01.jpg, PA-602-02.jpg, PA-602-03.jpg, PA-602-04.jpg, PA-602-05.jpg I want to move all the pictures with PA-600 ( so PA-600-01.jpg, PA-600-02.jpg, PA-600-03.jpg and PA-600-04.jpg ) on a folder (new or already existing, the easier...) named PA-600 , move all

Quit app after window is closed in AppleScript

夙愿已清 提交于 2019-12-14 01:34:39
问题 I've created an AppleScript app in Xcode and I would like to know how to get the app to quit after the window is closed. 回答1: Add a applicationShouldTerminateAfterLastWindowClosed: method in your AppDelegate, for example: on applicationShouldTerminateAfterLastWindowClosed_(sender) return true end applicationShouldTerminateAfterLastWindowClosed_ 来源: https://stackoverflow.com/questions/8365737/quit-app-after-window-is-closed-in-applescript

Result “Missing Value” with the JavaScript document.getElementById method

核能气质少年 提交于 2019-12-13 19:26:15
问题 I am trying to automate a search and a focusing on the part where the computer types in the search in the search bar. I think all of my syntax is correct but when I run the code, nothing happens and in the applescript result log it says "missing value".. Here is my code: to inputByID(theId, theValue) --defines the function-- tell application "Google Chrome" open location "https://www.google.com " execute javascript " document.getElementById(' " & theId & " ').value = ' " & theValue end tell

Can Applescript list all the applications placed in the dock?

﹥>﹥吖頭↗ 提交于 2019-12-13 18:08:56
问题 I can't work out how to list all the Applications that a user has placed in the dock. Is this possible? 回答1: Try this. This is a list of the apps a person has that are persistent in the dock. What I've basically done is use system events to read the plist file into an applescript record in the pListItems variable. Then I can use applescript techniques to access the lists and records inside of pListItems. There's lots of information in com.apple.dock so you can look at the pListItems variable