applescript

applescript - control click

风流意气都作罢 提交于 2019-12-24 01:37:17
问题 How can I control click with AppleScript? This script should work, but it doesn't activate application "Finder" tell application "System Events" tell process "Finder" key down control delay 1 click at {600, 600} -- {from left, from top} delay 1 key up control end tell end tell MouseTools is sometimes unreliable. I know of cliclick — still haven't tried it. I'd prefer an AS only workaround but welcome any suggestions. 回答1: Most of the actions from contextual menu you can do using menu bar

Build own AppleScript numerical error handling

て烟熏妆下的殇ゞ 提交于 2019-12-24 00:44:48
问题 I'm wanting to build an app for validating projects using custom error numbers I've defined similar to: try ## do something on error number -2700 display dialog "Foobar" end try with the help of JSON Helper defining the list as: tell application "JSON Helper" set myJSON to make JSON from {-1232:"missing definition", -123231:"foo", -1232314:"bar" } return myJSON end tell however I do not see a way to do this after referencing: Error Numbers and Error Messages Working with Errors other then

How do I get the file path of an iTunes Selection

时光毁灭记忆、已成空白 提交于 2019-12-23 22:23:42
问题 I'm trying to determine the path of track selected in iTunes using AppleScript. It doesn't seem to be a property of the track class. Can anyone tell me how I can get the file path? 回答1: Try this: --gets file path of selected song tell application "iTunes" set songLocation to get location of selection end tell return songLocation --gets file path of currently playing song tell application "iTunes" set songLocation to get location of current track end tell return songLocation 回答2: If you're

Applescript to run Detect Displays

人盡茶涼 提交于 2019-12-23 19:36:40
问题 When I plug an external monitor into my Macbook and wake it, the display is often the wrong resolution. Prior to Mountain Lion, I was able to run the following applescript to detect displays: tell application "System Preferences" to activate tell application "System Events" tell process "System Preferences" click menu item "Displays" of menu "View" of menu bar 1 tell button "Detect Displays" of window 1 to click end tell end tell tell application "System Preferences" to quit But, with 10.8,

Getting directory of input file (Applescript)

廉价感情. 提交于 2019-12-23 16:51:59
问题 I'm confused - I've been googling for an hour and have tried probably ten different forms of set posixDirectory to POSIX path of (parent of (path to aFile) as string) but I can't seem to get it right. I'm getting the full POSIX path (including the filename) by doing set posixFilePath to POSIX path of aFile Now, how do I get the POSIX path of just the directory?? I'm getting various errors depending on what I do... can't make alias.. can't get parent of alias... I would think this should work

AppleScript - JavaScript execution on Opera

放肆的年华 提交于 2019-12-23 16:26:39
问题 Safari and Chrome can execute JavaScript via AppleScript Safari: tell application "Safari" open location "http://example.com" activate do JavaScript "alert('example');" in current tab of first window end tell Chrome: tell application "Google Chrome" open location "http://example.com" activate execute front window's active tab javascript "alert('example');" end tell Is there a way to do this in Opera? Note: Same question for Firefox is here: AppleScript - JavaScript execution on Firefox I

Applescript application read from file

喜你入骨 提交于 2019-12-23 12:26:16
问题 I have a compiled AppleScript application which I have moved to my windows server. I'd like to then insert a text file into the application (which looks like a zip file on windows): myapplescript.app/Contents/Resources/MyNewDir/MyTxtFile.txt So, I've precompiled the AppleScript to try to read from this text file and get the contents as a string. This is what I do: set theFolder to POSIX path of (the path to me) set theFile to theFolder & "Contents/Resources/MyNewDir/MyTxtFile.txt" open for

i need an applescript to open safari in full screen an to hide the toolbar on mavericks

假装没事ソ 提交于 2019-12-23 12:03:02
问题 I need an applescript to open safari in full screen an to hide the toolbar on mavericks. it sounds easy but it isnt! i need to open safari then open google in full screen mode an then hide the toolbar. it would be the equivilent to the below sample but instead for safari tell application "Google Chrome" open location "http://internet.ceo.wa.edu.au/Pages/default.aspx" end tell tell application "Google Chrome" to activate tell application "System Events" keystroke "f" using {command down, shift

Erase Safari cookies from Terminal

荒凉一梦 提交于 2019-12-23 10:53:21
问题 I am making an application that involves controlling Safari from Applescript. Is there a way in the Terminal (preferred) or Applescript to erase Safari's cookies. Basically I want to the "Reset Safari" item from the menu using the Terminal. Is there a method that can do this? 回答1: You could simply delete the Cookies.plist file: rm ~/Library/Cookies/Cookies.plist Or take a look at this: List & delete Safari cookies 回答2: Reset Safari does more than just erasing the cookies: Basically I want to

Applescript Error -10810

跟風遠走 提交于 2019-12-23 10:25:12
问题 I have an Applescript that runs fine on my Macbook Retina but fails on a Mac Mini. Both are running MacOS 10.9.2. After peeling the onion a bit I'm able to reproduce the problem with a one-line Applescript: tell application "MidiPipe" to activate On the Mini that throws the error: An error of type -10810 has occurred. On the Macbook the MidiPipe application opens. MidiPipe works normally on the Mini when started from the Finder or from Launchpad. Google provides no insight into this error.