applescript

Use Applescript to send mail without mail.app

依然范特西╮ 提交于 2020-01-03 06:03:09
问题 I'm new to Applescript and working on an app that runs in the background, and I want it to send email updates every so often WITHOUT mail.app. I've tried googling this numerous times, and while this is the closest I've found, I don't know how to use a Python script. This app needs to work no matter what Mac OSX it is installed in, including Computers without Python. Is that possible? 回答1: I have often wanted to do the same thing and struggled myself. I ultimately landed on a python option.

Applescript - Creating folders based on the first word of the filename

放肆的年华 提交于 2020-01-03 05:04:19
问题 Essentially i'm looking for an applescript that allow me to order the massive 50.000 files by creating folders that have just the first word of the files, ignoring the rest of the filename after the first space. For eaxmple the 50.000 files are named like this: - amazingfrog -shootingbase.jpg - frog 2sHDn1_9fFs12s.jpg - frog 29adjjdd39939.mov - Horse IUS39aosdja.mov - horse 282131888.jpg - HORSE.jpg And so on..... - I would like to be like this: - amazingfrog -amazingfrog -shootingbase.jpg -

Possible to execute inline JavaScript statement in Applescript?

别来无恙 提交于 2020-01-03 04:38:44
问题 I know that you can tell Chrome or Safari to do JavaScript (or write entirely in JS... à la JXA) but whilst answering another question, I got curious... Is there a way to arbitrarily execute an inline JavaScript statement inside an AppleScript (without tell ing another process)? So far I've only used something like this (in an AppleScript): do shell script "osascript -l JavaScript -e '\"" & myVar & "\".trim()'" But that seems such a silly workaround 回答1: If you want to write JavaScript, then

How do I check if text can be converted to a number in AppleScript?

醉酒当歌 提交于 2020-01-03 04:00:08
问题 I'm trying to write a simple AppleScript to do some text manipulation on the contents of the clipboard. The following code works only if the text in the clipboard can be converted to a number: set CB to the clipboard set bugNum to CB as number But if the text in the clipboard is not a number I get an AppleScript error: "Can’t make "foo" into type number." How do I write an if condition that I can use to check if CB (of class text) can be converted to a number (and put the "set bugNum to CB as

AppleScript: encoding arbitrary query-string values in URLs passed to Firefox

怎甘沉沦 提交于 2020-01-02 10:35:34
问题 I use firefox for a long time as my only browser on Pc or Mac. In a few words my problem: I want to create a service on mac with automator and Applescript for quite instant translation using translate.google.com. What works great with Safari or Chrome (below the 4 or 5 lines of script) On run {input, parameters} Tell application "Safari" activate try Open location "https://translate.google.com/#auto/en/" & (the clipboard) end try end tell end run The same thing (script) does not work at all

How can I access a property that has the same name as class but different event code?

本小妞迷上赌 提交于 2020-01-02 07:25:15
问题 When an application uses the same name for a class and a property but different event codes, and I try to use the property in an object specifier, AppleScript interprets the identifier as the class rather than the property. For example: tell application "Mail" header of first rule condition of first rule end This results in the error: Mail got an error: Can’t get header of rule condition 1 of rule 1. The styling of header in AppleScript Editor (blue italics) suggests it's a class name rather

Error Relating to AppTranslocation in macOS Sierra

心不动则不痛 提交于 2020-01-02 06:56:08
问题 It would appear that Gatekeeper in macOS Sierra is a bit pickier. At any rate, it is causing a small utility I made some years ago to throw a rather annoying error. As I haven't yet had the time to dig into the under-the-hood changes in Sierra, I'm not sure how to fix the error. Does anyone have experience dealing with errors relating to AppTranslocation and fixing them? Code and error follow: Code : tell application "Finder" set currentDir to POSIX path of ((container of (path to me)) as

Run multiple commands in multiple Terminal windows with a single bash line

假如想象 提交于 2020-01-02 06:07:37
问题 Here's an interesting problem: Using the AppleScript method to launch a new command in a Terminal window fails if Terminal is "busy"; more precisely, it will open a new window but fail to run the command. For example, try copy+pasting this line in: osascript -e 'tell application "Terminal" to do script "foo"'; osascript -e 'tell application "Terminal" to do script "bar"'; osascript -e 'tell application "Terminal" to do script "baz"'; When I run this (I'm on Snow Leopard), I get three windows:

AppleScript - System Events Error : Access for assistive devices is disabled

家住魔仙堡 提交于 2020-01-02 01:58:14
问题 I have a problem with AppleScript and System Events. I have check "Enable access for assistive devices" in the “Universal Access” preference pane in System Preferences. When I try : arch -i386 osascript -e 'tell application "System Events" to get the position of every window of every process' I have this error : System Events got an error: Access for assistive devices is disabled. (-25211) Do you have any idea ? Thanks a lot 回答1: The problem is not the assistive devices. AppleScript seems to

How to automate extracting pages from a PDF using AppleScript and Acrobat Pro?

风格不统一 提交于 2020-01-01 16:53:51
问题 I'm new to AppleScript, but I am trying to create a script that will go through all PDFs in a folder extracting the pages into separate files. My plan is to use a combination of Automator and AppleScript. My AppleScript so far is: tell application "Adobe Acrobat Pro" open theFile set numPages to (count active doc each page) --execute the extraction here end tell The command in Acrobat Pro is under Options > Extract Pages... , where I can specify the page range and to extract to separate files