[Gambas-user] Sending key code (macro recorder)

Benoît Minisini g4mba5 at gmail.com
Tue Nov 3 21:43:27 CET 2020


Le 03/11/2020 à 19:08, Bruce Steers a écrit :
> Hi all.
> I'm trying to make a macro recorder to record keyboard events and play 
> them back.
> 
> Got a problem though.
> 
> the recorder can record the Key.Code fine (for things like up and down 
> arrow that do not have Key.Text)
> But i cannot send it back that way.
> 
> According to the wiki SendKeys page it says  this..
> *What is sent is not a string, but the internal key codes associated 
> with them. *
> Yet i try to send a Key.Code and it complains i sent an integer not a 
> string.
> 
> Am i going to have to map out a complete list of strings to match all 
> codes that Don't have Key.Text ?
> 
> Or can someone suggest a better way to record key events them play them 
> back?
> 
> And yes i read the warning about not using Key.Code as they differ 
> between gtk and qt but for a macro recorder i do not see it matters 
> unless i want to save the macros and use them on a different system.
> 
> Many thanks.
> Bruce
> 
> 
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
> 

Have you read the doc? The key names used by Desktop.SendKeys are the 
X11 one. They are nothing to do with Key class constants. So, yes, you 
have to integrate by hand the contents of the X11 key names include file 
and make the conversion.

Note that this works only on X11. Wayland forbids sending key events to 
application, at least freely.

Regards,

-- 
Benoît Minisini


More information about the User mailing list