Basics
Simkey functions are functions that are made within a Simkey program. They are declared in the FUNCS
section and have a block which contains code that gets compiled the same way as in the MACRO
section.
They are useful for particular things you want to do repeatedly throughout the code, and can have parameters, which will be discussed in the next page.
Declaring Simkey functions
All functions start with an @
and are declared within the FUNCS
section. They also all have a block, with opening and closing curly braces. Here's an example of declaring them:
<FUNCS>
@walk {
|w # Holds w, to walk #
}
You must separate the name and the bracket by a line or space. Otherwise, they will be interpreted as one name, and having a bracket in the name is illegal. The closing one must also be by itself.
Using Simkey functions
To use these functions all you need to do is write its name out in the MACRO
section or within a Simkey function, separated by some sort of whitespace or newline:
<FUNCS>
@walk {
|w
}
<MACRO>
@walk # Same as if |w was written instead #
As mentioned in the comment, it will work as if the |w
was simply written out in the MACRO
section. Here's an example of using a function within another function:
<FUNCS>
@click {
@delay [50,50] # NOTE: this changes the delay globally #
[MB_LEFT]
}
@double_click {
@click
@click
}
<MACRO>
@double_click # Will click twice, with delay (50,50) #
This is a straightforward example, but a very important note to make before moving on, is that these functions aren't running in some sort of special environment. The code is exactly as if it was written out, so when having a line like @delay [50,50]
within a function, it will change it globally.