Saturday, October 29, 2011

Applescript, TextExpander and AutoHotKey

It is possible to access the Parallels Desktop with AppleScript, using a script like this:

activate application "Parallels Desktop"
    tell application "System Events"
    keystroke ";" using {command down}
end tell

If AutoHotKey is running in the Parallels Desktop and "#;" is a shortcut Autohotkey recognizes, it will act just as if the shortcut were invoked from within Windows itself. The applescript snippet can be run from TextExpander, an application that reproduces some of AutoHotKeys functionality (AppleScript supplies most of the rest).

This setup opens up all kinds of possibilities for interaction between the two operating systems. So far, I have just set up  this TextExpander/AppleScript Combo to start ConnectedText, Quicken and SyncBack, Once they are running I can control them with AutoHotkey in Windows.

ConnectedText, AutoHotKey, SyncBack, Windows Live Mesh and Quicken are the only windows applications I am still using. I hope to replace Quicken for my budgeting and keeping track of financial matters with a native Mac OX application. The other four I will keep. AutoHotKey for automating ConnectedText, SyncBack mainly for backing up my ConnectedText files to a folder that synchronizes all my computers (by means of Windows Live Mesh).

P.S.: I solved the problem with AHK always opening up in notepad whenever I left and returned to the Parallel Desktop. The culprit was a snippet that allowed me to edit the file in use easily.

P.P.S.: I saw on the Internet another solution to opening windows programs from the Mac with an AppleScript and short cut keys for windows applications, but it did not work for me.

No comments: