STATIC SUB SendKeys ( Keys AS String )Send fake keyboard events to the window having the focus.
Keys is the list of keys that are sent successively.
Each key name must be enclosed between '[' and ']', but you can send any ASCII or LATIN-1 character as is. You can send the '\n' character for the RETURN key, and the '\t' for the TAB key.
All key names are defined in the /usr/include/X11/keysymdef.h X11 header file.
If several keys must be pressed simultaneously, they must be enclosed between '{' and '}'. To send the '{' ASCII character, use '{{}'.
![]() | What is sent is not a string, but the internal key codes associated with them. Hopefully, this function automatically takes care of sending the needed modifiers before sending an ASCII character. |
To send a new line, you can do:
Desktop.SendKeys("\n")
or
Desktop.SendKeys("[RETURN]")
To send the string "Gambas Almost Means BASic", you can do:
Desktop.SendKeys("Gambas Almots Means BASic")
What is done behind the scene is the following:
Desktop.SendKeys("{[SHIFT_L]G}AMBAS {[SHIFT_L]A}LMOST {[SHIFT_L]M}EANS {[SHIFT_L]B}{[SHIFT_L]A}{[SHIFT_L]S}IC")