Simulate keyboard input to active application

Documentation. First post is always kind of manual page, being continuously updated by author. Following posts are discussion about the topic.
Post Reply
admin
Site Admin
Posts: 424
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Simulate keyboard input to active application

Post by admin » 12 Jul 2017, 22:02

LuaMacros use lmc_send_keys function to simulate key presses to active application. This feature was transferred from HidMacros and uses special format of input string. The format is described at HidMacros help file or at LuaMacros wiki. However this function have limitations (unicode chars), bugs (who said that? :-)) and uses obsolete windows function to simulate keyboard input.

So from LuaMacros version 0.1.1.9 released on July 12th 2017 there's new function lmc_send_input which is very flexible. It is answer to many requirements like unicode support, sending just key press (and release later) and so on. In fact this is just wrapper around windows function SendInput. It takes 3 numeric parameters
  • virtual key code
  • scan code
  • flags
These parameters are described at MSDN page.

Simple scripts that waits 2 seconds and then sends ABc to active application is

Code: Select all

lmc_sleep(2000)
lmc_send_input(16, 0, 0) -- press shift
lmc_send_input(65, 0, 0) -- press A
lmc_send_input(65, 0, 2) -- release A
lmc_send_input(66, 0, 0) -- press B
lmc_send_input(66, 0, 2) -- release B
lmc_send_input(16, 0, 2) -- release shift
lmc_send_input(67, 0, 0) -- press C
lmc_send_input(67, 0, 2) -- release C
Petr Medek
HIDmacros author

sdasda7777
Posts: 1
Joined: 31 Jul 2017, 14:51

Re: Simulate keyboard input to active application

Post by sdasda7777 » 31 Jul 2017, 14:54

Any way to simulate gamepad (like X360 controller)?
Your program is really cool, and Id be rather using this one program then two separate.
Thanks,
XOXO z Pardubic.

admin
Site Admin
Posts: 424
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: Simulate keyboard input to active application

Post by admin » 02 Aug 2017, 16:19

No, currently not possible and not planned.
Petr Medek
HIDmacros author

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest