Last updated 14 Jul 1999

Jerboa scripts in general

Jerboa scripts are small programs used to execute other programs and send keyboard macros. Every time Jerboa recognizes a sign, it executes a script binded with the sign. Jerboa scripts do not have any variables, loops or user made functions, hence they are fairly easy to use. Everybody should be able to do their own scripts with this Jerboa Script Reference.

Like I allready said there are no variables, loops or user made functions. The lack or variables is propably the bigest difference when compared to other programming languages. I thought of implementing also variables but then realized that they really aren't that important when just executing programs and sending keyboard macros. If you have used C or Pascal you will notice that there are no semi-colons (";") ending lines. Lines are separated only by line breaks. Therefor there can only be one program line in one physical line (so you cannot use "ELSE IF" in one line).

When there are no variables, there isn't any use for numbers or mathematical operations either. All constants are therefor strings and must be in double quotation marks (like this "this is a string constant"). There are however two pseudo variables <ORIGINAL> and <UNDER>. Though they must also be inside quotation marks. They can be in constant with other text (like "program <UNDER> is under mouse").

Everything else but constants (that is built-in functions and keywords) is written as plain text. Built-in functions' parameters are written straight after function separated only by white-spaces.

Lines beginning with a semi-colon (";") are comment lines and will be skipped. Do not use too much comments because they will take up memory.

Jerboa scripts have a size limit of 16384 bytes. This includes everything in the script (characters, white-spaces, return characters, comments, and terminating null character).

Note that keyboard shortcuts may be different in different versions and different language versions of a program. Default bindings are for english versions of different software if not otherwise mentioned.

If you have any problems or find some part of this reference confusing or otherwise unclear please let me know.

In usage sections in this reference, the following rules have been followed.

Long code example lines may be wrapped to next line. In Jerboa however all lines must be on same line. If you use low resolution screen mode you should maximize the window. You can also make the menu at the left smaller by dragging the divider.

<ORIGINAL>

Pseudo variable <ORIGINAL> referes to the application having focus when Jerboa started running the script. It can be used with CONFIRM, FOCUS and TERMINATE so that <ORIGINAL> is expanded to an executable filename of the program that had the focus when script started.

RUN "NOTEPAD.EXE"
FOCUS "<ORIGINAL>"

<UNDER>

Pseudo variable <UNDER> referes to the application that was under the mouse when the user started to draw a sign. <UNDER> is used the same way as <ORIGINAL>.

FOCUS "<UNDER>"
SENDKEY "%A%V115"

CONFIRM

Usage:
IF [NOT] CONFIRM windowtext yestext notext

Used with IF statement.
Displays dialog box with text windowtext. yestext and notext are used in yes and no buttons. If the user presses the yes button, Confirm returns true and if the user presses the no button false.

windowtext may contain pseudo variables <ORIGINAL> or <UNDER>.

IF CONFIRM "TERMINATE <UNDER>?" "YES" "NO"
TERMINATE "<UNDER>"
ENDIF

Even though function name is confirm, it may be used to let the user choose between two choises.

IF CONFIRM "WHICH BROWSER DO YOU WISH TO USE" "IE" "NETSCAPE"
RUN "IEXPLORE.EXE"
ELSE
RUN "NETSCAPE.EXE"
ENDIF

DIALUP

Usage
IF [NOT] DIALUP connectionname

Used to determine if dial-up networking connection named connectionname is currently connected. connectionname is the same as the connection name in the dial-up networking folder (Start/Programs/Accessories/Dial-up Networking).

To connect using dial-up networking you can create a shortcut pointing to the connection (open dial-up networking folder and drag the desired icon with control and shift down to desired folder in harddrive and choose create shortcut(s) here) and then use RUN to execute the shortcut.

IF NOT DIALUP "MYCONNECTION"
RUN "C:\MYCONNECTION.LNK"
ENDIF

EXIST

Usage:
IF [NOT] EXIST exefile

Used with IF statement.
Checks if program with executable name exefile is currently running in system. exefile may contain only executable filename, whole path or part of path in which case exefile is compared to the end part of other applications' executable filename.

IF NOT EXIST "COMMAND.COM"
RUN "COMMAND.COM"
ELSE
FOCUS "COMMAND.COM"
ENDIF

First line could also be
IF NOT EXIST "C:\WINDOWS\COMMAND.COM"
and results would be same (if you have installed Windows to that directory).

If you have two different programs with same executable filename but different path, you should specify path so that Jerboa can recognise which one you are referring.

Using
IF NOT EXIST "OMMAND.COM"
as first line would in most cases still function the same way since the end part of COMMAND.COM matches OMMAND.COM. This is however rather obscure and should not be used.

FOCUS

Usage:
FOCUS targetwindow

FOCUS is used to set an application on foreground (set window and keyboard focus to that window). This brings the window on front and allows sending keyboard macros with SENDKEY to that window. targetwindow is the executable filename of the desired application. If you have multiple instances of the same application open, it will be somewhat unpredictable which one will be set on foreground. Comparsion used between targetwindow and the filnames of applications is similar to the one used with EXIST.

You can get the executable filename by making any sign (actually it doesn't even have to be a sign) when the mouse is on target window. Then open Jerboa dialog and select the signs tab. At the bottom of the dialog is a read-only edit box which displays the executable filename on which the last sign was drawn.

Note that not all applications' executable is of type .EXE . For example dos prompt's executable is WINOA386.MOD .

IF, ELSE, ENDIF and NOT

Usage:
IF [NOT] CONFIRM/ DIALUP/ EXIST
[ELSE]
ENDIF

Introduction to IF statements in general

If you ever have programmed before, you can go straight to IF statements in Jerboa. IF statements are one of the most important parts in programming. IF statements are used very much the same way as in speech. Think of the first sentance in this paragraph. Just the same way we can tell the computer to do something if something else is true. Let's take a look at the following example.

IF EXIST "IEXPLORE.EXE"
FOCUS "IEXPLORE.EXE"
ENDIF

We can divide the first line into two parts: the IF statement and condition. In this case the condition would be " EXIST "IEXPLORE.EXE" ". There must always be a condition with IF statement. This particular condition checks if program with executable name IEXPLORE.EXE exists in the system (FYI. IEXPLORE.EXE is the executeble of Microsoft Internet Explorer). If and only if it exists, all the contents between IF and ENDIF lines is executed. Every IF must have maching ENDIF so that Jerboa will know which part it skips if the IF condition is not true.

Now let's add something to the previous exapmle.

IF EXIST "IEXPLORE.EXE"
FOCUS "IEXPLORE.EXE"
ELSE
RUN "IEXPLORE.EXE"
ENDIF

The new ELSE keyword could often be translated to casual speech as otherwise. So if Internet Explorer is allready up and running the script would set focus to that. Otherwise the script runs Internet Explorer. If the first condition is true the code between IF and ELSE is run otherwise the code between ELSE and ENDIF is run.

To introduce one more keyword related to IF let's change the previous script a bit, but so that it still functions exactly the same way.

IF NOT EXIST "IEXPLORE.EXE"
RUN "IEXPLORE.EXE"
ELSE
FOCUS "IEXPLORE.EXE"
ENDIF

The NOT keyword makes true false and vice versa. So if Internet Explorer is not yet running, run it. Otherwise set focus to it. Just the same thing we did in previous script.

You can also nest IF statements. Let's take a look at the following example, which is actually pretty complex.

IF NOT EXIST "IEXPLORE.EXE"
IF NOT EXIST "NETSCAPE.EXE"
IF CONFIRM "WHICH BROWSER DO YOU WISH TO USE" "INTERNET EXPLORER" "NETSCAPE"
RUN "IEXPLORE.EXE"
ELSE
RUN "NETSCAPE.EXE"
ENDIF
ELSE
FOCUS "NETSCAPE.EXE"
ENDIF
ELSE
FOCUS "IEXPLORE.EXE"
ENDIF

This example also shows the standard operating procedure of indenting complex code so that it is clearer to read. (Or it is supposed to show but because current browsers do not support CSS very well you propably won't see the indenting you may want to look at the same script in a pre formatted text file.) Indenting does not have any effect when running the script. If you wish you could now first try to read that example a couple of times through and see if you can find out what it does.

So here's the spoiler. The script first checks if IE (Internet Explorer) is running. If it is, the script sets focus to it and stops running. Otherwise it checks if Netscape is running. And if it is, it is set to foreground. Otherwise the script asks the user whether (s)he wishes to use IE or Netscape (see more info on CONFIRM) and runs whichever program user selected. Then the scripts stops running.

IF statements in Jerboa

Since there are no variables in Jerboa scripts, IF statements can only be used with built-in functions ( CONFIRM, DIALUP, EXIST ) returning either true or false. See help for each of these to see how they work. IF statements can be nested the same way as in most programming languages. Every IF must have a matching ENDIF even if there is only one line under IF.

PROPERTIES

Usage:
PROPERTIES

PROPERTIES function does not take any parameters. Use it to show and bring up Jerboa dialog. Using PROPERTIES is same as double clicking on the Jerboa icon in the system tray.

PROPERTIES

RUN

Usage:
RUN [MINIMIZED/MAXIMIZED] [DIR workingdirectory] executable [param1] [param2] [...]

RUN is used to execute files. It can be used to execute executables (*.EXE, *.COM, *.BAT,) as well as shortcuts (*.LNK), text documents (*.TXT, *.DOC, ...) or any other associated file or even a folder.

Define MINIMIZED or MAXIMIZED to run in minimized or maximized mode. Use DIR workingdirectory to set the working directory for the program. executable is the file or folder to be run. Parameters are defined after executable every one in their own quotation marks.

MS-DOS provides some rarely used bizarre methods for passing single and double quotation marks (" and ') as parameters that are not supported in Jerboa. If you ever need to use these, write the command in a BAT file and then run that. Passing parameters with white-spaces (like file or folder names with white-spaces) is not affected by this problem since parameters are always in quotation marks in Jerboa.

Following code runs DOS prompt minimized in "c:\program files" folder.

RUN MINIMIZED DIR "C:\PROGRAM FILES" "C:\WINDOWS\COMMAND.COM"

Following code plays "c:\windows\system\msremind.wav" .

RUN "C:\WINDOWS\SYSTEM\MSREMIND.WAV"

SENDKEY

Usage:
SENDKEY keystosend

SENDKEY is used to send keyboard events. Events will be sent to window currently having keyboard focus. Focus can be changed using FOCUS. keystosend is the string containing keys to be sent.

SENDKEY can be used to send several keys with only one SENDKEY. Plain characters in keystosend are sent straight. Following send keystrokes of keys A B C and D to the window currently having keyboard focus.

SENDKEY "ABCD"

%Vnnn and %Nnnn where nnn is a three digit number (must have three digits) can be used in keystosend to send virtual-key codes (%Vnnn) and keyboard scan codes (%Nnnn). This is essential when you want to send for example the F1 key or allmost any other key than plain character or number. The following sends the F1 key (usually opens help window).

SENDKEY "%V112"

It is recommended that you send virtual-key codes rather than keyboard scan codes since keyboard scan codes are device and keyboar layout dependent when virtual-key codes are not. However sending scan codes is somewhat more low-level and may sometimes be used to send non-standard keyboard events.

%S %A and %C may be used to inform Jerboa that next key is to be sent holding down shift (%S), alt (%A) or control (%C). Shift, alt and control states are set to false after key is sent so you must specify them separately to every key. You cannot send plain shift alt or control key-stroke with %S, %A or %C. To do this send virtual-key codes with %Vnnn instead. Following code sends Alt+F4 (usually exits application) (115 is the virtual-key code of F4).

SENDKEY "%A%V115"

%D and %U may be used to inform Jerboa that next key is to be left down (%D) or released (%U). The following code is a longer way to send Alt+F4 (18 is the virtual-key code of alt and 115 is F4).

SENDKEY "%D%V018%V115%U%V018"

All previous can be combined in any way. Following sends first Alt+F (usually opens file menu) and then N (usually opens new file).

SENDKEY "%AFN"

You very often need to first set the keyboard focus with FOCUS to <UNDER> because binding set is determined by the application under the mouse. Still that application doesn't necessarily have the keyboard focus. Also if the binding set to be used is <GLOBAL> the user most likely wants to interact with the window on which the sign is drawn.

Some keyboard events cannot be sent. Control+alt+del for example cannot be sent. Also num, caps and scroll locks can be sent but their effect is somewhat unpredictable. You might also think of sending alt+tab (or actually alt+shift+tab could be more useful) but for some reason it doesn't work well (at least in Win95; haven't tested in Win98).

Using %D to set a key down and not releasing it is not recommended though possible. In some cases it might be useful but results can be unpredictable.

TERMINATE

Usage:
TERMINATE targetapplication

TERMINATE terminates targetapplication. TERMINATE should only be used in extreme conditions because targetapplication will not have chance to save open documents or do any clean-up.

Comparsion between targetapplication and other applications is done the same way as in EXIST.

If you wish to exit application use SENDKEY "%A%V115" (alt+F4) instead. That way the target application will have time to save its open documents.

It would be useful to TERMINATE "<UNDER>", but there are some problems with this. TERMINATE should be used only when an application has stopped responding. When this happens, the application won't process mouse messages posted to it, hence Jerboa will not either get any mouse messages. Therefor Jerboa cannot track mouse movements when mouse is on an application that has stopped responding and cannot terminate that program using TERMINATE "<UNDER>".

IF CONFIRM "TERMINATE PROGRAM <UNDER>" "YES" "NO
TERMINATE "<UNDER>"
ENDIF

WAITFOR

Usage:
WAITFOR application

Waits until the application is up and running in the system. Maximum time WAITFOR waits is 20 seconds, after which running the script is conitinued normally.

WAITFOR is typically used after RUN so that you may continue by for example sending keyboard events to the program you just ran.

Comparsion between application and other applications is done the same way as in EXIST.

You should always use WAITFOR after RUN if you are planning to do something with the program you just ran.

You should use IF EXIST application after WAITFOR application because WAITFOR may exit due to 20 seconds maximum wait time, in which case you may want to stop running the script.

Following opens notepad if not yet open. It then waits for it. Then checks that notepad actually is open. Then sets focus and opens the "open file" dialog.

IF NOT EXIST "NOTEPAD.EXE"
RUN "NOTEPAD.EXE"
WAITFOR "NOTEPAD.EXE"
ENDIF
IF EXIST "NOTEPAD.EXE"
FOCUS "NOTEPAD.EXE"
SENDKEY "%AFO"
ENDIF

While Jerboa is waiting for a program, it may seem like Jerboa has stopped responding. This will only last for 20 seconds or until application shows up in system.