Simple Auto Typer
In this article, I will be showing you how to use simba to type and perform an action on key press.
This will come in handing on pausing, starting, and ending a script.
If you don't know how to set up a custom function/ procedure, or use default parameters then check out my article on custom procedures/functions.
1: Basic Auto Typer
This will be the basic code, to type a single line of text.
program new;
procedure AutoTyper(Text:string);
begin
SendKeys(Text, 100, 30);
PressKey(13);
end;
begin
activateclient;
AutoTyper('Line of text');
end.
We start by creating a procedure call auto typer, with a parameter text. Which will be the thing we want to auto type.
Then within that procedure, we send the text string with a key wait of 100ms, this is how long to hold the key for, and a keywaitmod of 30.
After that, we tell simba to press the key 13, which is the enter key.
The last thing ,is to run the procedure down in the main loop, and fill in the parameter. In this case 'Line of text'.
Results:
As you can see, it writes the text once.
2: Looped Auto Typer
Now if we want to run this multiple times, we just add a basic loop.
program new;
procedure AutoTyper(Text:string);
var
i:integer;
LineNumber:string;
begin
for i:= 1 to 5 do
begin
LineNumber:= Text + Tostr(i);
SendKeys(LineNumber, 100, 30);
PressKey(13);
end;
end;
begin
activateclient;
AutoTyper('Line of text ');
end.
To adjust the code from before we:
- Add two vars to the procedure. An i as integer and LineNumber as a string, so I can show you what the loop does.
- Then we add in, for i:= 1 to 5 do send the keys.
The for to do loop automatically increments the i var so we dont have to do that.
Results:
The results show that that the script typed the text var 5 times.
But lets say you want to run the auto typer till you press a key
3: Infinite Auto Typer
To run this script for an infinite amount of times, and end it on a key press, lets adjust the code once again.
program new;
procedure AutoTyper(Text:string);
var
i:integer;
LineNumber:string;
begin
while not(isKeyDown(27)) do
begin
LineNumber:= Text + Tostr(i);
SendKeys(LineNumber, 100, 30);
PressKey(13);
inc(i);
end;
end;
begin
activateclient;
AutoTyper('Line of text ');
end.
The changes made from the previous example:
- We change the loop type to a while do loop
The loop will run the script till the key 27 is pressed, which is the escape key.
Results:
The only flaw i found with this method, is you will have to hold the escape key till the script stops.
A full list of key key codes and keyboard/mouse related functions can be found on Simba's keyboard and mouse documentation.