applescript

Check if a Mac OS X application is present

為{幸葍}努か 提交于 2019-12-31 10:47:03
问题 I recall there being a Cocoa framework or AppleScript dictionary to check if an Application bundle with a specific name is installed at all, anywhere on the computer. How do I do this? Either Cocoa, AppleScript, or command line are useful to me. 回答1: You should use Launch Services to do this, specifically the function LSFindApplicationForInfo() . You use it like so: #import <ApplicationServices/ApplicationServices.h> CFURLRef appURL = NULL; OSStatus result = LSFindApplicationForInfo (

Calling AppleScript from Python without using osascript or appscript?

微笑、不失礼 提交于 2019-12-31 08:38:09
问题 Is there any way to execute (and obtain the results of) AppleScript code from python without using the osascript command-line utility or appscript (which I don't really want to use (I think?) because it's no longer developed/supported/recommended)? Rationale: in another question I've just posted, I describe a strange/undesired behaviour I'm experiencing with running some AppleScript via osascript . As I'm actually calling it from a python script, I wondered if there was a way to route around

How to send an imessage text with applescript, only in provided service?

孤人 提交于 2019-12-31 07:55:11
问题 Can somebody show me how to send a message directly to the user of iMessage via Messages app? tell application "Messages" if service type of service of buddy whose name is ("Name here" is "iMessage") then set x to 1 if service type of service of buddy whose name is ("Name here" is "iMessage") then set x to 2 if service type of service of buddy whose name is ("Name here" is "iMessage") then set x to 3 send "Message" to buddy "mail of name" of service x end tell I need to send a message to an

How to send an imessage text with applescript, only in provided service?

瘦欲@ 提交于 2019-12-31 07:55:11
问题 Can somebody show me how to send a message directly to the user of iMessage via Messages app? tell application "Messages" if service type of service of buddy whose name is ("Name here" is "iMessage") then set x to 1 if service type of service of buddy whose name is ("Name here" is "iMessage") then set x to 2 if service type of service of buddy whose name is ("Name here" is "iMessage") then set x to 3 send "Message" to buddy "mail of name" of service x end tell I need to send a message to an

Check if variable is number: Applescript

别说谁变了你拦得住时间么 提交于 2019-12-31 01:54:11
问题 How can I check if a variable is a number? I'm trying this: set a to 5 if a is a number display dialog "Yes! It's a number!" end if I've also tried this code: set a to 5 if a is integer display dialog "Yes! It's a number!" end if But unfortunately it doesn't work as expected. 回答1: class of a is integer will fail if you use set a to "5" This will work if even if the variable is a number but was entered as text. set a to "5" try set a to a as number display dialog "Yes! It's a number!" end try

Applescript: Create folders/subfolders and move multiple files

一曲冷凌霜 提交于 2019-12-30 13:34:10
问题 I have an Applescript question that is much more complex than I can construct. I have been searching for the past couple of days, and I cannot find any script like this, nor can I find enough information to piece one together with my limited knowledge. I have multiple files with structured names. Each file has the following name structure: ttu_collectionname_000001.pdf ttu_collectionname_000002.mp3 ttu_collectionname_000003.pdf ... etc. (Each of these files are of varying file types.) There

Applescript to launch file from current folder?

て烟熏妆下的殇ゞ 提交于 2019-12-30 09:54:09
问题 How does one open a file in the same folder as the AppleScript code? Something along these lines? tell application "QuickTime Player" activate open "file.avi" end tell (which doesn't work). Thanks! 回答1: tell application "Finder" open file "somefile.txt" of folder of (file (path to me)) end tell (only works once you've saved the script - otherwise "path to me" goes to the script editor) 来源: https://stackoverflow.com/questions/7003699/applescript-to-launch-file-from-current-folder

Most efficient method of activating an Emacs function with an applescript

半世苍凉 提交于 2019-12-30 05:11:58
问题 Is there a better method to activate a function in Emacs with an applescript instead of opening the minibuffer to launch the function? There is a delay that is needed to take my finger off of the control key to launch the applescript with a keyboard shortcut (so that Emacs doesn't register it as a command), and there is another delay after typing the name of the function into the minibuffer. Ideally, I'd like to tell Emacs under-the-hood to run a particular function without opening the

Applescript testing for file existence

試著忘記壹切 提交于 2019-12-30 04:35:20
问题 OK, I thought this would be a simple one, but apparently I'm missing something obvious. My code is as follows: set fileTarget to ((path to desktop folder) & "file$") as string if file fileTarget exists then display dialog "it exists" else display dialog "it does not exist" end if Easy right? Unfortunately, when I run the script it returns the error Can’t get file "OS X:Users:user:Desktop:files$". It doesn't matter if the file exists or not, this is the same error I get. I've tried a dozen

How do I create a Macintosh Finder Alias From the Command Line?

爱⌒轻易说出口 提交于 2019-12-30 04:06:07
问题 I am trying to create a Finder Alias from the command line or from a Python program. I have searched the web[1][2][3] and found this bit of applescript: $ osascript -e 'tell application "Finder" to make new alias at POSIX file "/Users/vy32/cyber.txt" to POSIX file "/Users/vy32/a/deeper/directory/cyber.txt"' Unfortunately, it gives me this error: 29:133: execution error: Finder got an error: AppleEvent handler failed. (-10000) [1] http://hayne.net/MacDev/Bash/make_alias [2] https://discussions