applescript

open programs with applescript

 ̄綄美尐妖づ 提交于 2019-12-20 10:25:31
问题 2 part question: I'm simply trying to run programs using applescript from the terminal, so I tried: $ osascript tell application "iTunes" to activate and get the error: osascript: tell: No such file or directory Giving the full path to the program did not work either. What am I missing? The second part of the question is what I eventually want to use applescript for. I would like to use it to open an application I built using py2app. Can applescript open any mac app or just certain ones that

AppleScript to combine multiple Excel files into a single worksheet

隐身守侯 提交于 2019-12-20 06:32:09
问题 I am not an expert in AppleScript, so I've ben trying to find an example of AppleScript code that can successfully process a batch of Excel files (each one with a single worksheet), copying the content of each one into a single destination sheet. This is the pseudo code that I had in mind: pick source folder with Excel files; pick destination Excel file; for each file within the source folder: copy data from default sheet; paste data into destination sheet's first unused row end This is the

AppleScript: how to get the current directory of the topmost Terminal

情到浓时终转凉″ 提交于 2019-12-20 06:15:05
问题 I want to get the current directory of the topmost Terminal tab/window (via AppleScript or something else, it doesn't really matter). How can I do that? 回答1: Another solution. get_foregroundterminal_curdir_fast.scpt: tell application "Terminal" do shell script "lsof -a -p `lsof -a -c bash -u $USER -d 0 -n | tail -n +2 | awk '{if($NF==\"" & (tty of front tab of front window) & "\"){print $2}}'` -d cwd -n | tail -n +2 | awk '{print $NF}'" end tell I use lsof itself to get PID of the bash shell

AppleScript: how to get the current directory of the topmost Terminal

匆匆过客 提交于 2019-12-20 06:14:04
问题 I want to get the current directory of the topmost Terminal tab/window (via AppleScript or something else, it doesn't really matter). How can I do that? 回答1: Another solution. get_foregroundterminal_curdir_fast.scpt: tell application "Terminal" do shell script "lsof -a -p `lsof -a -c bash -u $USER -d 0 -n | tail -n +2 | awk '{if($NF==\"" & (tty of front tab of front window) & "\"){print $2}}'` -d cwd -n | tail -n +2 | awk '{print $NF}'" end tell I use lsof itself to get PID of the bash shell

pass and receive values between python script and applescript

陌路散爱 提交于 2019-12-20 05:12:13
问题 I'm very new to python and applescript. I have a python script which is calling 2 applescripts. I would like to define few global variables in python and pass to applescript 1 , those values will be modified by different functions in applescripts 1, and pass back to python scripts, then pass those values to applescript 2 to use. I have googled a bit and I tried the following: in applescript, on run argv if (item 1 of argv is start with "x") then function1(item1 of argv) else function2 (item 1

save mail attachment from applescript in Lion

我们两清 提交于 2019-12-20 04:45:14
问题 It seems, that the method of saving a mail attachment with applescript is broken under Lion. Assume, 'theAttachment' is already the right object containing the e.g. attached jpg, here is what I've done: set strPath to (path to pictures folder) as string save theAttachment in strPath -- leads to the error: "„Mail“ got an error: error in AppleEvent-Routine." number -10000 save theAttachment in strPath as "test" -- leads to \"test\" can't convert into typ constant" number -1700 from "test" to

Open an application from another (iOS)

偶尔善良 提交于 2019-12-20 02:32:37
问题 I read that there is nothing like NSWorkspace for iOS Equivalent of NSWorkspace for iOS Unfortunately, I wanted a button in my app that can run some others applications (in background). Is it possible without NSWorkspace ? 回答1: Your first problem is that you can't run applications in the background in the same way that you can on the Mac. But, assuming that just launching an app is enough, the answer is: it depends. The other app would need a URL scheme defined. Not all do, unfortunately.

“No user interaction allowed” When running AppleScript in python

不打扰是莪最后的温柔 提交于 2019-12-19 19:55:35
问题 I have the applescript which will displays menu list and allow user to select menu items etc. It runs fine by itself. And now I try to run it in python. I get the No user interaction allowed. (-1713) error. I looked online. I tried the following: add on run function in the same applescript, so what i did is just add the main into the run on run tell application “AppleScript Runner” main() end tell end run i tried to run the above in python import os def main(): os.system ('osascript -e "tell

Cocoa-Applescript NSOpenPanel?

ぐ巨炮叔叔 提交于 2019-12-19 11:39:07
问题 How do I do an NSOpenPanel in Cocoa-Applescript? Are there any good tutorials? I am familiar with Applescript, but not really the Cocoa part. Do I need a nib for the NSOpenPanel? I am making an Automator action. See my previous question. 回答1: Shane Stanley's PDF book AppleScriptObjC Explored is the one to get for AppleScriptObjC tutorials - pretty much all of the examples from Apple are in the existing ObjC documentation and would need to be converted. There is an Automator path pop-up button

Copying .rtf text into the body of an email with AppleScript

非 Y 不嫁゛ 提交于 2019-12-19 11:27:50
问题 I have an AppleScript application which creates an email (in Mail.app) with attachments from the options I choose through dialogs. The text templates are stored in .rtf format so non-programers can alter the text templates to their wishes. I am able to create an email from a .txt plain text file, but when I import an .rtf text file it imports the formatting commands, which I don’t want in the mail. Here is an example of a .rtf import into an email: {\rtf1\ansi\ansicpg1252\cocoartf1038