Tag Info

Hot answers tagged

3

namedFolder only exists in the scope of your tell block. Define it first thing so that it will persist after you’re done with Finder. set namedFolder to "" tell application "Finder" ... end tell return namedFolder Alternatively, you could just put the return statement inside the tell block.


2

Updated answer: There is an Apple doc which shows the correct way of doing it. You was close. (I have not tried it myself) do shell script "rm -rf /$HOME/Downloads/*" user name "USERNAME" password "THEPASSWORD" with administrator privileges From the doc: How do I get administrator privileges for a command? Use the administrator privileges, user ...


2

Buscar's comment made me check the process hierarchy and it turns out, a service is a sub-sub-sub process of the application that launched it. So, even though in many cases, a query for the frontmost application may be ok, I think looking at the process tree is better. Here is some sample code from a test Service Workflow that for me appears to work ...


2

set theMonth to do shell script " date -v2d -v1m -v99y +%B%n%b%n%m%n%-m" -> "January Jan 01 1" set theDay to do shell script " date -v2d -v1m -v99y +%A%n%a%n%d%n%-d" -> "Saturday Sat 02 2" set theYear to do shell script " date -v2d -v1m -v99y +%Y%n%y" -> "1999 99" -v flag adjusts the date item without changing the real date. -v2d is 2nd ...


2

Expanding on my comment above.... See the comment by user kerma at this related StackFlow article His little command line app at https://github.com/kerma/defaultbrowser does what you need. He provided the source code but it was designed for 10.9. A small change can make it to compile on 10.6 as well. I tested it on my system and it worked correctly. ...


1

As you launch the service from Safari, the application will be the one in the foreground. You can use this Applescript in the "Run AppleScript" action. tell application "System Events" set x to first process whose its frontmost is true and name is "Safari" return unix id of x end tell


1

Based on Vic's answer, this is what I came up with. Download defaultbrowser, create a cronjob to run at 9 am and 6pm. Because there is no gui, it will require taking advantage of the fact that mac is unix. First checkout the source code of defaultbrowser, and copy it to /usr/local/bin git clone https://github.com/kerma/defaultbrowser.git ...


1

I've not used it inside a shellscript, only in 'pure' Applescript, but why not just tell application "myApp" to activate ..it would prevent the randomness of which particular app was next in line.


1

According to this you need to tell Finder as well: tell application "System Events" tell process "finder" activate keystroke tab using {command down} end tell end tell But I also like the suggestion to specify the app by name...


1

Have a look at http://stackoverflow.com/questions/18136567/applescript-keystroke-not-behaving-as-expected & the list of ANSI codes at How do I automate a key press in AppleScript? It appears you're not the only one with the issue. One solution on there was to use the key code instead... tell application "System Events" key code {18} using ...


1

You can also use AppleScript or defaults: $ osascript -e 'version of app "TextEdit"' 1.9 $ defaults read /Applications/TextEdit.app/Contents/Info.plist CFBundleShortVersionString 1.9 You can use AppleScript or mdfind to find the path of an application: $ osascript -e 'posix path of (path to app "textedit")' /Applications/TextEdit.app/ $ mdfind ...


1

You can place this Applescript in your workflow: tell application "System Events" to get name of first process whose frontmost is true It will output the name of the current foreground app (you can't really call a service from an inactive application). You can then pass it as a string into another action like this:


1

As far as I can tell, there is no direct way. You would have to use applescript to select the text and set the formatting in the Mail application after the fact... (Example below taken from the web...) tell application "System Events" to tell (process 1 where frontmost is true) set {c1, c2} to value of attribute "AXSelectedTextRange" of text area 1 of ...


1

I tested copying 8.95GB worth of files and folders and you do get a timeout. The best thing you can try is to add a timeout clause to the code. When I did this it worked ok. I gave the script 30mins. I do not have SD cards so in my testing I had to change the code some to accommodate my setup. I do notice : you have a two tell blocks for finder where ...


1

Not nearly as complicated, but perhaps of value, is the app Choosy. It allows you to choose your browser every time you open a link outside of a browser. While this might sound onerous, it's actually pretty transparent, and I find it very useful in the leadup to going live with a new web project and testing in multiple browsers over and over and over… Might ...



Only top voted, non community-wiki answers of a minimum length are eligible