applescript

I need to URL-encode a string in AppleScript

六月ゝ 毕业季﹏ 提交于 2019-12-06 05:19:10
问题 My script searches a website for songs, but when there are spaces it doesn't search, you have to add underscores. I was wondering if there was a way to replace my spaces with underscores. Could you please use my current code below to show me how to do it? set search to text returned of (display dialog "Enter song you wish to find" default answer "" buttons {"Search", "Cancel"} default button 1) open location "http://www.mp3juices.com/search/" & search end 回答1: Try the following: set search to

Mac App Rejection - Temporary Exception Entitlement Key for Safari

我只是一个虾纸丫 提交于 2019-12-06 04:19:06
Let's consider an app doing the following steps using AppleScript, in order to auto-login to some website: 1- Open "Safari" and navigate to website 2- Fill the username and password fields with JavaScript do JavaScript " document.getElementById('password_input').value = 'userPassword' " 3- Submit form using JavaScript --- do JavaScript " document.forms['login_form'].submit() " For a sandboxed Mac app, com.apple.security.temporary-exception.apple-events entitlement key must be added for "Safari", in order to execute AppleScript procedure above. <key>com.apple.security.temporary-exception.apple

Mac OS Login Items with Arguments?

随声附和 提交于 2019-12-06 04:08:53
问题 In Mac OS, I've created a few AppleScripts to add and remove start up applications (Login Items, under the Accounts system pane). #!/bin/bash /usr/bin/osascript -e "tell application \"System Events\" to make new login item with properties { path: \"$1\", hidden:false } at end" Usage would be like this: ./addloginitem.sh /Applications/TextEdit.app I'm curious if it's possible to have startup items that use arguments? I have a program that I would like to pass a "startup" argument to if it is

How to open an application in Mac OS using Python

拜拜、爱过 提交于 2019-12-06 03:57:30
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. 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 open man page ( man open ) and the python subprocess module documentation for more details. AppleScript:

Automator + Applescript how to: new Desktop (open Calendar and Reminders in it)

岁酱吖の 提交于 2019-12-06 03:52:29
问题 The title is what I'm trying to achieve. In Automator, I've tried to simply record the actions of opening a new desktop, and then opening the apps in it -- but I get the The action 'Watch Me Do' encountered an error. Check the actionʼs properties and try running the workflow again Furthermore, if I do it in this way, the action that is recorded is "Click the Desktop 4 button". Similarly, I googled and found Applescripts that create specific Desktops (e.g. Desktop 3) but I always have a

AppleScript : How to get files in folder without hidden files?

ぐ巨炮叔叔 提交于 2019-12-06 03:24:06
I actually have two questions. How to exclude hidden files like .DS_STORE, Icon when I try to get files in folder ? I've tried " without invisibles " but it seems not working. How to set my var the_new_folder as an existing folder if already exists ? Thanks for answers. My code: -- -- Get all files in a selected folder -- For each file, create a folder with the same name and put the file in -- tell application "Finder" set the_path to choose folder with prompt "Choose your folder..." my file_to_folder(the_path) end tell on file_to_folder(the_folder) tell application "Finder" -- HELP NEEDED

Incorrect sender when sending Email via Applescript

故事扮演 提交于 2019-12-06 03:21:02
问题 The Applescript below is in the form that I have used for a number of years. And is basically a well known method of sending emails using Applescript. tell application "Mail" set newMessage to make new outgoing message with properties {subject:"IP Address", content:"Your IP Address Is: 86.195.132.134"} tell newMessage set visible to false set sender to "mark@sender.com" make new to recipient at end of to recipients with properties {address:"recipient@mac.com"} send end tell end tell What I

How Can I Pass a String From Applescript to Objective C

给你一囗甜甜゛ 提交于 2019-12-06 02:26:47
I'm working on an application where I need to be able to pass a string variable from Applescript to Objective C . I have figured out how to run Applescript from a method in my Objective C Class, but I need to be able to set an NSString to a string from Applescript . How would I be able to accomplish this? Thanks in advance! Quick example: NSString *theScript = @"set theTimeString to time string of (current date)\n" "return theTimeString"; NSDictionary *errorInfo = nil; NSAppleScript *run = [[NSAppleScript alloc] initWithSource:theScript]; NSAppleEventDescriptor *theDescriptor = [run

Editing Mac OS X login items in Objective-C through AppleScript

淺唱寂寞╮ 提交于 2019-12-06 01:22:39
In my Cocoa program, I want to examine what programs are registered to run at startup and modify that list as I feel appropriate. In order to be compatible with Tiger it seems like I need to work through AppleScript. I currently have the following code: NSDictionary* errorDict; NSAppleEventDescriptor* returnDescriptor = NULL; NSString *appleSource = @"tell application \"System Events\"\n\ get every login item\n\ end tell"; NSAppleScript *appleScript = [[NSAppleScript alloc] initWithSource: appleSource]; returnDescriptor = [appleScript executeAndReturnError: &errorDict]; If I run that command

OS X Applescript to Check if Drive Mounted and Mount It If Not

左心房为你撑大大i 提交于 2019-12-06 00:18:55
I am trying to write an AppleScript that will check if a network drive (in this case, my Time Capsule) is mounted and, if not, mount it. I've figured out how to mount the Time Capsule, but I am at a loss over how to have the script check whether it is mounted first and just exit if it is, or mount it if not. tell application "Finder" mount volume "afp://AirPort%20Time%20Capsule._afpovertcp._tcp.local" end tell Does that the job? set mountedDiskName to "AirPort Time Capsule" set diskIsMounted to false tell application "System Events" to set diskNames to name of every disk if mountedDiskName is