Sikuli Variables

sikuli keystrokes

How Do I Use Variables in Sikuli?

Sikuli works just the same as python with variables. If you do not know what variables are, they are “containers” that can store numbers, letters, symbols, spaces, etc. You can store any type of data to use later on in the code as a reference. Think of variables as ways of saving time and not having to repeat yourself. Variables in Sikuli follow the same rules and syntax as Python so if you have some experience with Python, using Sikuli should be a piece of cake. We do not have to define what the data type is and Python automatically assumes what it is based on what is entered.

Here is a finance-related scenario that is handling budget information using variables.

Mark has a budget of $5,910,149 for his business. He spends $92,000 per month and wants to find out how much he has left in his budget in month 24.

Solving this problem using variables is very easy.

First, we create a variable called “Budget” and store “5910149” by making it equal to Budget.

Budget = 5910149

Note: When you are defining a variable, you will need to use one = sign. Using two == is for when applying logic to define a statement as true or false.

Now every time we reference the variable ‘Budget‘, it should return ‘5910149’.

You can easily check this by using the print command.

print(Budget) would print the number out in the message log when the script has been run.

Since we know the variable can be referenced, we can create some calculations to see how much money Mark has left in month 24. We know he spends $92,000 per month.

Since we have to reference month 24, we can make a month variable by defining it as

month = 24

Since we know Mark plans on spending $92,000 per month, we can also store that number in a variable.

monthspend = 92000

The last thing we need to do is create a variable to tell us what is remaining in the budget after x months.

We can create a variable called ‘RemainingBudget’ and equal it to Budget – (monthspend * month).

This translates to 5910149 – (92000*24)

If we print RemainingBudget, the answer should be 3702149.

sikuli variables


We can make this even more sophisticated by making the variables be defined by whatever is entered in an input box or even ask the user to select the month and year from the dropdown menu. Variables save a lot of time by not having to repeat or calculate multiple times. Check out our section on Sikuli input boxes and dropdown menus if you are interested in learning more about defining variables with user interaction.









Related Articles

Sikuli Input Boxes

Sikuli User Input Boxes Sikuli has many advantages what automating Digital Finance processes. When building automations, the main objective is to make the user be…


Your email address will not be published. Required fields are marked *