applescript

Add vcard to Contacts with Mail rules and Applescript

你离开我真会死。 提交于 2019-12-12 18:56:23
问题 I receive a lot of customer vcards to a specific email address. I want to automatically add the vcards to my contacts through the Mail rules and an AppleScript. I searched a lot and found something. I modified it a bit. And the opening and adding process works fine. But only when I choose a file. I can't get the file into a variable from the mail message. I tried it but it won't work. Here is my code so far: tell application "Mail" set att to attachment end tell set thefile to att tell

How to filter Outlook for Mac calendar events by category using AppleScript

柔情痞子 提交于 2019-12-12 17:30:20
问题 I'm trying to write an Applescript on OSX to filter Outlook for Mac 2011 calendar events based on event categories, e.g. find all events tagged as "Conference". For example, I have a calendar event named "WWDC" that is found by the following script: tell application "Microsoft Outlook" set theCategoryConference to first category whose name is "Conference" set theConferenceList to every calendar event whose (subject is "WWDC") display dialog "There were " & (count of theConferenceList) & "

Applescript to show Apple menu bar items

旧街凉风 提交于 2019-12-12 16:21:27
问题 I am an Applescript newbie. I want to know Applescript to show the Apple menu bar items from an arbitrary application (but the many bar should remain for the orginal application). I tried the following script, using Finder as a kind of dummy app, but it did not work. tell application "System Events" tell process "Finder" tell menu bar 1 click menu bar item "Apple" end tell end tell end tell Can anyone help? PS-1: I want to know this because Control-F2 to move focus to menu bar often does not

Spotify's “player state” is available in the editor, but in a packaged app, it gets only “«constant ****kPSP»”

為{幸葍}努か 提交于 2019-12-12 13:16:23
问题 Here's a testing code: tell application "Spotify" set playerState to player state as string end tell display dialog playerState Works fine from the AppleScript editor. However, when I export my script as an app, all I get is this: Why is this happening? 回答1: It seems that Spotify is not coercing the constant into a string. Since the editor can't coerce it from an applet as it does when you are running the script in AppleScript Editor, the four-letter constant code is returned. Since you can't

Issues with “On Open” Applescript handler in Yosemite

百般思念 提交于 2019-12-12 13:01:55
问题 In using Applescript in OSX 10.10 (Yosemite), it seems Apple has changed some of the default behavior. on open dropped_files display dialog (count of dropped_files) end open This very basic Applescript highlights the problem. If I select a group of 6 files from the Finder, and drop/drop onto a compiled version of this script, I get the response "2" and then the response "4". It should be responding "6"... but it's almost as if Finder is parsing the files into smaller groups. If I do this

How to close a Terminal tab using AppleScript?

瘦欲@ 提交于 2019-12-12 12:18:16
问题 I'm using AppleScript to open PostgreSQL in a Terminal tab like this: #!/bin/bash function new_tab() { TAB_NAME=$1 COMMAND=$2 osascript \ -e "tell application \"Terminal\"" \ -e "tell application \"System Events\" to keystroke \"t\" using {command down}" \ -e "do script \"printf '\\\e]1;$TAB_NAME\\\a'; $COMMAND\" in front window" \ -e "end tell" > /dev/null } new_tab "PostgreSQL" "postgres -D /usr/local/var/postgres" Running this script from the Terminal will open a new tab with PostgreSQL

How do I get the Scripts folder in the application bundle?

感情迁移 提交于 2019-12-12 10:54:50
问题 I'm really new to AppleScript so this is a real basic question but I couldn't find the answer or an example in the AppleScript ref. guide. I'm making a simple script that I'll bundle as an application file, in the AppleScript Editor I can see the app's Bundle Contents in which I have an icon, a description file and a Scripts folder. How do I access that content from the script and how do I access the scripts inside the scripts folder ? 回答1: If you save your script as a script bundle or as an

Applescript Finder path into POSIX path

泪湿孤枕 提交于 2019-12-12 10:17:09
问题 I'm running the following applescript: tell application "Finder" set input to POSIX file "/Users/sam/Desktop/Resized" set theFiles to (every file of folder input whose name does not contain "- Resized") end tell return theFiles It's working as it should, though it's returning: {document file "HighResCat.jpg" of folder "Resized" of folder "Desktop" of folder "sam" of folder "Users" of startup disk of application "Finder", document file "madonna.jpg" of folder "Resized" of folder "Desktop" of

Apple Script to set Primary Button, Secondary Button and other properties for Mouse Preference

落爺英雄遲暮 提交于 2019-12-12 10:16:55
问题 Can anyone suggest me: How to set Primary Button, Secondary Button and other properties of Mouse Preference via AppleScript? I have now tried this, script: tell application "System Preferences" activate end tell tell application "System Events" tell process "System Preferences" click menu item "Mouse" of menu "View" of menu bar 1 tell window "Mouse" set value of pop up button 1 to "Primary Button" end tell end tell end tell but it is giving this error message: System Events got an error: Can

How to open an application in Mac OS using Python

雨燕双飞 提交于 2019-12-12 09:54:21
问题 I want to open an application like TextEdit or Firefox in Mac OS using Python and wait till the applications exits. I can't figure out exact command to open an app and wait. 回答1: I don't know how to do it in applescript, but you can do this by using the /usr/bin/open UNIX-level OS X command. This snippet will open TextEdit.app and block, waiting for it to quit before continuing: import subprocess subprocess.call( ["/usr/bin/open", "-W", "-n", "-a", "/Applications/TextEdit.app"] ) Look at the