User Tools

Site Tools


autohotkey

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revision Both sides next revision
autohotkey [2013/03/30 17:28]
jariw created
autohotkey [2013/04/04 14:24]
jariw
Line 1: Line 1:
 +Many of the JW freeware plug-ins use the window concept of a tree view to the left (with tasks arranged into containers) and a panel to the right that is specific to the task. This page contains code for [[http://​www.autohotkey.com|AutoHotkey]] for Windows on how to fully automate a task in such a plug-in.
 +
 +AutoHotkey is a script-based Windows freeware macro application that's robust and extremely powerful, although it has some learning curve to work fluently (there are also GUI frontends and other tools available to simplify tasks). However, once the basic script is set up, adding new tasks is extremely trivial. This page contains functions and scripts to get you started.
 +
 +The full example can be downloaded here, so you can tweak it with more hotkeys: Finale.ahk
 +
 +==== All you need to know ====
 +
 +When you're basic script is set up, the following example should cover all you need to know to interact with the plug-in:
 +<​code>​
 +#​IfWinActive,​ ahk_class Finale
 +^!T::
 +if (openJWpluginwindow("​JW Plug-ins",​ "JW Meter and Rhythm",​ 5, 1) = 1)
 +{
 +   ​setJWpluginpanelvalue("​JW Meter and Rhythm",​ 1, 1)
 +   ​applyandcloseJWpluginwindow("​JW Meter and Rhythm"​)
 +}
 +return
 +</​code>​
 +
 +Since it's important to understand these lines of code, here's a closer look.
 +
 +  #​IfWinActive,​ ahk_class Finale
 +means that the keyboard macro will only be available **when Finale is active**. (More specifically,​ it requires that a window with a window class called Finale is active.)
 +
 +  ^!T::
 +is the **start of a keyboard macro**. ^ is the //Ctrl// key. ! is the //Alt// key. So the keyboard combination in the example is //​Ctrl+Alt+T//​.
 +
 +  if (openJWpluginwindow("​JW Plug-ins",​ "JW Meter and Rhythm",​ 5, 1) = 1)
 +calls the openJWpluginwindow function in the script (the code for the function is listed below). The function will start the plug-in from the menu, assure that the window opens and select container and task in the window. If everything went well, the function returns 1. //Since the plug-in is modeless, you can execute this function even if the window is already on the screen.// The first parameter to the function is the name of the submenu in Finale'​s //Plug-in// menu.
 +
 +==== How the code works ====
 +
 +This section lists the specific functions and other code that are required for the script.
 +
 +At the start of the script, add the following standard lines: ​
 +<​code>​
 #​NoEnv ​ ; Recommended for performance and compatibility with future AutoHotkey releases. #​NoEnv ​ ; Recommended for performance and compatibility with future AutoHotkey releases.
 #Warn  ; Enable warnings to assist with detecting common errors. #Warn  ; Enable warnings to assist with detecting common errors.
 SendMode Input  ; Recommended for new scripts due to its superior speed and reliability. SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
 SetWorkingDir %A_ScriptDir% ​ ; Ensures a consistent starting directory. SetWorkingDir %A_ScriptDir% ​ ; Ensures a consistent starting directory.
 +</​code>​
  
  
-; submenuname:​ The name of the Plug-ins submenu (where the plug-in is located) within quotes. Use ""​ for the root Plug-in menu.+Here's a general function, called //​openJWpluginwindow()//​ that will open a plug-in and selects a task from the tree list. 
 +<​code>​ 
 +; This function will open a plug-in and selects a task from the tree list. 
 +;  
 +; submenuname:​ The name of the Plug-ins submenu (where the plug-in is located) within quotes. 
 +Use ""​ for the root Plug-in menu.
 ; pluginname: The name of the plug-in name and window title (supply it within quotes) ; pluginname: The name of the plug-in name and window title (supply it within quotes)
 ; containerindex:​ The 1-based container from the top. Top container is 1, second container is 2, etc. ; containerindex:​ The 1-based container from the top. Top container is 1, second container is 2, etc.
Line 58: Line 101:
    ​return 1  ; Success    ​return 1  ; Success
 } }
 +</​code>​
  
 +The //​setJWpluginpanelvalue()//​ function sets a value in the panel to the right. 
 +<​code>​
 setJWpluginpanelvalue(pluginname,​ panelitemnumber,​ value) setJWpluginpanelvalue(pluginname,​ panelitemnumber,​ value)
 { {
Line 98: Line 143:
    ​return 1    ​return 1
 } }
 +</​code>​
  
 +/* The //​applyandcloseJWpluginwindow()//​ function will simulate a press of the Enter key and close the plug-in window. */
 +<​code>​
 applyandcloseJWpluginwindow(pluginname) applyandcloseJWpluginwindow(pluginname)
 { {
Line 115: Line 163:
    ​WinClose %pluginname%    ​WinClose %pluginname%
 } }
 +</​code>​
  
- 
- 
-#​IfWinActive,​ ahk_class Finale 
-^!T:: 
-if (openJWpluginwindow("",​ "JW Meter and Rhythm",​ 5, 1) = 1) 
-{ 
-   ​setJWpluginpanelvalue("​JW Meter and Rhythm",​ 1, 1) 
-   ​applyandcloseJWpluginwindow("​JW Meter and Rhythm"​) 
-} 
-return 
  
  
autohotkey.txt · Last modified: 2013/04/28 17:17 by jariw