Tag Archives: applescript

How to send F2, F8, F9, F12 to a VNC Remote PC from Mac OS X

When recently using Intel Active Management Technology (AMT) I was remotely connected via the RealVNC client, but was having trouble sending keystrokes like F2 to enter the BIOS, F12 to select a startup device, or F8 to access the Windows startup menu. This setup is complicated for a few reasons – first I’m using a Mac keyboard. Secondly, OS X remaps the function keys to do things like dashboard, expose, brightness, and volume by default. After a little searching and trial and error, I found that I can use the free utility included with Mac OS X – AppleScript Editor.app – to send keycodes to the VNC connection. Here’s the code for the applescript you can use to send the F12 key: tell application “VNC Viewer” activate tell application “System Events” to key code 111 end tell This is what it should look like in the editor: To send key combos, like holding down alt and pressing F4, the syntax would be something like this: tell application “System Events” to key code 118 using {command down} We use command instead of alt because that is how Real VNC Viewer translates the “alt” key for a remote windows system by default. To send other keyboard F-keys to the remote Windows machine, use the table below to find the appropriate key – make sure to reference the “Mac” column even if the remote machine is a Windows box. What about JAVA? But what happens if you are running a java applet for … Continue reading

Posted in Tech Tips | Tagged , , , | Leave a comment

Applescript: Check Application Is Running

Below is my Applescript example of how to check if an application is running, such as Finder.app, VLC.app, itunes.app, or something along those lines. Quite often I need to check if an application is running as part of my applescript, and so I use this little function / subroutine in applescript to test if the application is running: on appIsRunning(appName) tell application “System Events” to (name of processes) contains appName end appIsRunning Example usage: display dialog appIsRunning(“Finder”) The above apple script example will show “true” in a popup dialog.

Posted in Mac, Software, Tech Tips | Tagged , , , , , , , , | 1 Comment

Applescript: Unhide / Restore All Windows

I got tried of accidentally hitting the CMD-H key and having a window disappear. So I wrote this little script and then assigned it to CMD-SHIFT-H to restore (unhide, unminimize) all hidden or minimized windows. Works on OS X 10.6, 10.7, 10.8, and 10.9 Snow Leopard, Lion, Mountain Lion, and Mavericks. Feel free to post improvements in the comments. I also think it would be cool to figure out the last window that was hidden, something like tell previous application and just restore that one. But this works for now. tell application “System Events” repeat with theApplication in application processes if visible of theApplication is not true then set visible of theApplication to true end if end repeat end tell You can also do this with an Application like Terminal.app: tell application “System Events” repeat with theApplication in application “Terminal” if visible of theApplication is not true then set visible of theApplication to true end if end repeat end tell Sometimes if you have “Minimized” instead of “Hidden” an application, it still won’t come back into the foreground when using the previous methods, so you can also try something like this: do shell script “open ‘/Applications/Utilities/Terminal.app'” This works by telling the application to “open” again which should also bring it to the front.

Posted in Mac | Tagged , | 1 Comment

Applescript: How to Activate the File Menu

set front_app_path to path to frontmost application as Unicode text delay .2 //short delay, get your hands off the keys you used to activate tell application “System Events” //tell the front application tell application front_app_path //press control+f2 (activate apple menu) key code 120 using {control down} key code 124 //right key code 124 //right key code 125 //down end tell end tell

Posted in Tech Tips | Tagged , | Leave a comment