applescript

Send key down / up events for number keys using AppleScript

早过忘川 提交于 2019-12-06 00:16:33
I need to send a key down / key up event for number keys to an application using AppleScript. However, the commands: key down "6" delay 1 key up "6" send the keystrokes as if they were coming from the number pad. I need them to be interpreted as coming from the number row at the top of the keyboard. I’ve also tried using (ASCII character 54) instead of a literal, without success. Note I need key down to be sent – sending a keystroke or key code will not do. kopischke Try sending key down the virtual key code instead of a keystroke literal, i.e. key down (key code <int>) where int is one of 1 →

Error Relating to AppTranslocation in macOS Sierra

霸气de小男生 提交于 2019-12-06 00:09:39
It would appear that Gatekeeper in macOS Sierra is a bit pickier. At any rate, it is causing a small utility I made some years ago to throw a rather annoying error. As I haven't yet had the time to dig into the under-the-hood changes in Sierra, I'm not sure how to fix the error. Does anyone have experience dealing with errors relating to AppTranslocation and fixing them? Code and error follow: Code : tell application "Finder" set currentDir to POSIX path of ((container of (path to me)) as text) end tell set currentDir to quoted form of currentDir set lib80211 to quoted form of "AirPort Utility

Attach event listeners in OS X JavaScript for Automation (JXA)

不想你离开。 提交于 2019-12-05 18:43:54
How is it possible to listen for events in OS X JavaScript for automation. In the scripting Library for the Messages application there is a list of event handlers, such as messageSent and messageReceived . However, I cannot figure out how to use them. Trying to pass a function yields an error, and trying to set these variables to new functions causes the REPL to hang. What is the proper way to set up these event handlers? You would create a script that you then select from the AppleScript handler menu in Preferences > General . Use the built-in Speak Events.applescript file as your guide and

Change the icon of an applescript-called notification

此生再无相见时 提交于 2019-12-05 17:59:03
With OSX Mavericks we now can make notifications with applescript pretty easily. However, there doesn’t seem to be a way to change the icon that appears to a custom one. Is there a way to accomplish this? display notification will take application icon. You can set icon in bunlde content of applescript application. set fileName to choose file "Select a Folder" display notification "Parag Bafna" subtitle "Its working" & fileName display notification text required with title text optional subtitle text optional sound name text optional You change the icon by simply changing the icon of the

Applescript to add an audio file to keynote and upload the file to youtube

倖福魔咒の 提交于 2019-12-05 16:44:47
I am trying to use either automator or applescript to do two things. add an mp3 to an open keynote presentation (to the entire presentation and not a single slide) upload the resulting keynote presentation to youtube. If I use the add file command, as below it doesn't seem to work, although if i replace slideshow with slide 1, then it adds it to slide 1 only. Thanks very much. tell application "Keynote" tell slideshow 1 add file slideshow 1 path theFile end tell end tell You basically want to add a soundtrack to the slideshow, not add a file. Unfortunately I do not see a way to do this with

How to reload a Safari Extension from the command line?

强颜欢笑 提交于 2019-12-05 16:38:57
I need to "Reload" a Safari extension from the command line (and also build the package later). How can this be done? Why? I'd like to build in one step - my code is in CoffeeScript and thus I'm compiling it anyway. What have I tried? Apart from googling hopelessly I tried using this AppleScript: tell application "System Events" tell process "Safari" click the button "Reload" of window "Extension Builder" end tell end tell Which errors out with: System Events got an error: Can’t get button "Reload" of window "Extension Builder" of process "Safari". And this variation: tell application "System

Un-minimizing an app with Applescript

二次信任 提交于 2019-12-05 16:14:04
问题 I'm trying to write a script to un-minimize an app that was previously minimized to dock. Problem is, I can't find the relevant property. I've tried miniaturized and collapsed but neither the window nor the process seems to have those? The app I use (for testing) is Zipeg, a free packing tool. I've also tried to click the button which happily MINIMIZES the app, but gives me an error when running on an already minimized app to restore it, probably because no window is visible. This script is

Using Python with Scriptable Applications (on a Mac)

只愿长相守 提交于 2019-12-05 16:11:06
I'm quite new to programming, but I've learned some basic Python programming in a university course. I'm looking for a way to run very simple Python scripts on Mac applications (mainly iTunes), in lieu of AppleScript. I've read up on using AppScript for Python, but it is no longer in development and is broken as of iTunes 10.6.3. On my Windows computer, I was easily able to script applications with Python using a module called PyWin32. Since switching to a Mac, however, I haven't been able to find a good alternative. Here is an example script that I used on Windows, just to give an idea of the

Alias to make emacs open a file in a new buffer (NOT frame) and be activated/come to front?

喜欢而已 提交于 2019-12-05 15:58:00
What I have so far is alias em="open -a /Applications/Emacs.app "$@" && osascript -e 'tell application "Emacs.app" to activate'" But I am stumped. With that code, em file.txt will activate, but won't open the file . And I get '22:23: syntax error: Expected end of line but found unknown token. (-2741)' Doing alias em=open -a /Applications/Emacs.app "$@" Works fine and then it will open the file, but obviously not bring emacs to the front. And for some strange reason osascript -e 'tell application "Emacs.app" to activate' doesn't activate emacs.... I have no idea what is going on. I am happy to

Run multiple commands in multiple Terminal windows with a single bash line

放肆的年华 提交于 2019-12-05 15:06:42
Here's an interesting problem: Using the AppleScript method to launch a new command in a Terminal window fails if Terminal is "busy"; more precisely, it will open a new window but fail to run the command. For example, try copy+pasting this line in: osascript -e 'tell application "Terminal" to do script "foo"'; osascript -e 'tell application "Terminal" to do script "bar"'; osascript -e 'tell application "Terminal" to do script "baz"'; When I run this (I'm on Snow Leopard), I get three windows: In the first, the command foo is run, as expected; but in the other two, I just get an empty prompt.