It's not much, but it gets the job done. This type lets you send complex strings, buttons, and more with a relatively simple syntax similar to that of AHK. Buttons and combinations such as arrow keys, backspace, enter, and more can now be held, released, pressed with ease.
tKeyboard.code(vKey:string)
Returns the specified button's keycode.
This method is used to get the key code of a button. It functions like
getKeyCode(), only it accepts strings such as
backspace,
enter,
del, etc.
Example:
Simba Code:
(*
The following writes:
37
*)
writeLN(
keyboard.code('left')
);
tKeyboard.format(vString:string)
Returns the specified string, formatted to be used with the send method.
This method is used to format a string so that it can be easily parsed by the
send method. It replaces keys with their respective keycodes, grouping them in brackets.
Example:
Simba Code:
(*
The following writes:
{16 down}{72}{16 up}{69}{76}{76}{79}{32}{87}{79}{82}{76}{68}
*)
writeLN(
keyboard.format('{shift down}h{shift up}ello world')
);
tKeyboard.press(vKey:variant;vOption:variant='')
Holds, presses, or releases a specific key.
This method can repeatedly press a key, hold a key, release a key, or press a key once.
vKey can be an integer key code or a name, such as
enter.
Example:
Simba Code:
(*
The following presses enter three times
*)
keyboard.press('enter',3);
(* ...delete once *)
keyboard.press(46);
(* ...holds the left arrow *)
keyboard.press('left','down');
(* ...releases the CTRL button *)
keyboard.press('ctrl','up');
Sending - tKeyboard.send(vString:string)
Holds, presses, or releases a string of keys.
This method functions like the
press method, only it allows for multiple different keys and combinations.
Example:
Simba Code:
(*
The following sends:
Hello world!
*)
keyboard.send('{shift down}h{shift up}e{l 2}o world{shift down}1{shift up}');
(* ...CTRL-s *)
keyboard.send('{ctrl down}s{ctrl up}');
(* ...doubling {legit/trusted} *)
keyboard.send('doubling \{legit/trusted\}');
(* ...HELLO world *)
keyboard.send('{shift down}hello{shift up} world');
(* ...f3 (five times) *)
keyboard.send('{f3 5}');
(* ...world *)
keyboard.send('hello {backspace 6}world');
(* ...right arrow (and holds it) *)
keyboard.send('{right down}');
tKeyboard.state(vKey:variant)
Returns the state, pressed or not, of a key.
This method returns whether or not a key is held.
vKey can be an integer key code or a name, such as
enter.
Example:
Simba Code:
(*
The following writes:
True
*)
keyboard.press('ctrl','down');
writeLN(
keyboard.state('ctrl')
);
keyboard.press('ctrl','up');