applescript

Get process name from application name and vice versa, using Applescript

无人久伴 提交于 2019-12-21 20:19:09
问题 On 27 February 2003, Apple employee Christopher Nebel said he'd like to straighten out this problem as reported by Bill Cheeseman: Because of the different naming for applications and application processes in some circumstances, we end up having to write slightly confusing scripts like this (if we've renamed Adobe Photoshop 7.0 to "Photoshop" in the Finder): tell application "Photoshop" to activate tell application "System Events" tell application process "Adobe Photoshop 7.0" Suffice it to

Find and Replace in AppleScript

感情迁移 提交于 2019-12-21 17:49:40
问题 I'm currently writing a super simple script and I need to find and replace text in a variable (specifically in the path of the items dropped onto the applescript.) Here is what I have currently: on open {dropped_items} tell application "Finder" to set filePathLong to the POSIX path of dropped_items as text on replaceText(find, replace, subject) set prevTIDs to text item delimiters of AppleScript set text item delimiters of AppleScript to find set subject to text items of subject set text item

Display and update applescript output in background

五迷三道 提交于 2019-12-21 05:45:13
问题 I have a short and sweet program that outputs my internal and external ip in applescript. Here it is the Applescript code: set inIP to IPv4 address of (get system info) set exIP to (do shell script "curl ipecho.net/plain") display dialog "Internal: " & inIP & " External: " & exIP I would like it to constantly update in the background and preferably not in a display dialog function as it does at the moment. I do not want a display dialog constantly popping up so I am looking for example,

How to detect which Space the user is on in Mac OS X Leopard?

可紊 提交于 2019-12-21 05:07:30
问题 Mac OS X Leopard has a virtual desktop implementation called Spaces. I want to programatically detect which space the user is currently on . Cocoa is preferable but AppleScript is acceptable if there's no other way. I've seen a couple of AppleScript implementations, but the techniques they used seemed a bit too hacky to use in production code (one relied on causing an error and then parsing the error message to get the current space, the other interrogated the Spaces menu GUI) 回答1: Use

Getting AppleScript return value in Obj-C

左心房为你撑大大i 提交于 2019-12-21 04:35:22
问题 I'm using some AppleScript in my Obj-C cocoa project to control QuickTime player (play, pause, stop, jog forward and back etc.) with great success, though my knowledge of AppleScript is very limited. However, what I want most of all is the movie's 'Current Time' offset to convert into time-stamps for writing a subtitle script. The following simple method shows the precise current position in (float) seconds in a dialog, but I'd really like the AppleScript to return me a variable that I can

How can I edit file metadata in OS X?

ⅰ亾dé卋堺 提交于 2019-12-21 04:27:24
问题 Does anyone know if it is possible to directly edit file metadata on OS X. Specifically in perl. The parameter I'm specifically trying to change is kMDItemFSLabel (The color of the file). I've had a search around and I can't seem to find a way to do this without using a module such as Mac::Glue or an external application (Finder). 回答1: The kMDItemFSLabel attribute is a property of the Finder. You need to use a way to communicate with the Finder to change its data. As far as I know, there is

Execute AppleScript file in Mac app?

放肆的年华 提交于 2019-12-21 04:27:21
问题 I'm looking for a way to execute an Applescript file from within a Mac App. I've made previous mac applications that use NSAppleScript *script = [[NSAppleScript alloc] initWithSource: @"MY_CODE"]]; , but my applescript is quite lengthy and I'd like to just be able to reference that file as part of my project, and pipe in the contents of it (or just directly execute the file from within my app). Thank you! 回答1: To run user-supplied AppleScripts outside the sandbox (10.8+), use

How to create an Apple Script that runs a Terminal command?

别等时光非礼了梦想. 提交于 2019-12-21 03:43:36
问题 I want to create an apple script that opens terminal and summons this command : sudo killall coreaudiod How is this possible? 回答1: do shell script "sudo killall coreaudiod" with administrator privileges the user gets asked for the password then 来源: https://stackoverflow.com/questions/19101518/how-to-create-an-apple-script-that-runs-a-terminal-command

single quote escaping in applescript/shell

无人久伴 提交于 2019-12-21 02:52:19
问题 I'm trying to process this shell script in applescript, but it keeps saying error EOF, because of the single quote in the folder name. do shell script "cp -R " & a & " " & "'" & d & "/My 'Folder/java/" & "'" The folder /My 'Folder/ is a legitimate directory. The variable a = '/Applications/MyProgram/' (and includes the single quotes) The variable d = /Folders (with no single quotes) However, shell is getting stuck processing it, im guessing because the folder is enclosed in quotes. Is there

In Mac OS X 10.11, Opening a VPN connection window with the command line gives me an error

我只是一个虾纸丫 提交于 2019-12-20 10:57:20
问题 On Mac OS X <= 10.10, I could run the following command to open a VPN connection window: function go-vpn { /usr/bin/env osascript <<-EOF tell application "System Events" tell current location of network preferences set VPN to service "LF VPN" if exists VPN then connect VPN repeat while (current configuration of VPN is not connected) delay 1 end repeat end tell end tell EOF } This would open the connection window (same as selecting the "LF VPN" network from the VPN dropdown). In El Capitan,