Hi there! Today, I'll show you how to easily use loops and variables with a simple macro example: creating the 2-times multiplication table. Simple Hotkey is a really easy and convenient macro program, so you can practice right away with this example!
How to Create a 2-Times Table Macro
To type the 2-times table into Notepad with a macro, you need to repeat the calculation and key entry from '2 x 1 = 2' to '2 x 9 = 18' nine times. You can do this very simply using a loop.
Script Example:
<string,a=2>
<string,b=1>
<repeat,9>[
<calc,c=a*b>
<sendkey,a>X<sendkey,b>=<sendkey,c>⇒
<calc,b=b+1>]
Script Explanation:
<string,a=2>
: Stores the number2
in variablea
. This represents the fixed '2' in the multiplication table.<string,b=1>
: Stores the number1
in variableb
. This is the number that will be multiplied, starting from 1.<repeat,9>[ ... ]
: This command tells the macro to repeat the commands inside the brackets[
and]
a total of 9 times.<calc,c=a*b>
: Calculates the product of variablesa
andb
and stores it in variablec
. This is the result of the multiplication.<sendkey,a>X<sendkey,b>=<sendkey,c>⇒
: Types the results (variablesa
,b
, andc
) into Notepad in order. For example, it will type '2X1=2'. The⇒
symbol represents an Enter key press, which creates a new line.<calc,b=b+1>
: Each time the loop runs, this command adds 1 to the value of variableb
. This makesb
increase from 1, to 2, to 3, and so on, completing the multiplication table.
How to Use This Example
This example is great for:
Practicing repetitive tasks: It’s the best way to get comfortable with using loops and variables.
Automating simple calculations: You can use the
calc
command whenever your macro needs to perform a quick calculation.Practicing data output: It helps you practice how to output calculated values to a file or onto the screen.
It’s a simple but incredibly powerful way to use macros! Try making and running the script yourself to see how easy and convenient Simple Hotkey is.
댓글 없음:
댓글 쓰기