Send Keys with a delay

Announcements, questions
Post Reply
Shytoos
Posts: 3
Joined: 03 Aug 2017, 21:21

Send Keys with a delay

Post by Shytoos » 03 Aug 2017, 21:28

Greetings,


I'm trying to figure out how to add a delay between each key pressure with lmc_send_keys() function.
There was apparently such a function on HIDMacros: HIDMacros.SendKeysSlow

I tried googling that but couldn't find anything so according to this file (https://github.com/me2d13/luamacros/blo ... ndKeys.pas) I tried to work around line 203

Code: Select all

//Function SendKeys(SendKeysString : PChar; Wait : Boolean; ToWindow : string = ''; Delayms: Integer = 0) : Boolean;
So I tried:

lmc_send_keys('^+{F1}', _, _, 500)
lmc_send_keys('^+{F1}', false, '', 500)
lmc_send_keys('^+{F1}', true, '', 500)

None of those lines worked and they all instantly press the three keys.

Is there an existing solution for this problem ? I actually want:
Ctrl DWN -> Wait 50ms -> Shift DWN -> Wait 50ms -> F1 DWN -> Wait 50 ms -> Ctrl, Shift, F1 UP
Thanks !

Shytoos
Posts: 3
Joined: 03 Aug 2017, 21:21

Re: Send Keys with a delay

Post by Shytoos » 05 Aug 2017, 09:31

I ended up using HidMacros which actually works!

EDIT:

Still not good, now my custom keys from HidMacros work, but it breaks my main keyboard ^ key.
When I press it, it instantly outputs ^^, so I can't make ê, â, û, ô, etc.. It only occurs when the software is running, and nothing is set on this keyboard.

It's also the case with ¨¨, is there a way to fix that ? I would rather like this to get fixed, or a way to use SendKeysSlow with LuaMacros.

Thanks!

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

Re: Send Keys with a delay

Post by admin » 06 Aug 2017, 22:00

There's no delay feature in lmc_send_keys.

But see this howto and try (haven't tested myself)

Code: Select all

lmc_send_input(17, 0, 0) -- press ctrl
lmc_sleep(50)
lmc_send_input(16, 0, 0) -- press shift
lmc_sleep(50)
lmc_send_input(112, 0, 0) -- press F1
lmc_sleep(50)
lmc_send_input(112, 0, 2) -- release F1
lmc_send_input(16, 0, 2) -- release shift
lmc_send_input(17, 0, 2) -- release ctrl
Petr Medek
HIDmacros author

Shytoos
Posts: 3
Joined: 03 Aug 2017, 21:21

Re: Send Keys with a delay

Post by Shytoos » 07 Aug 2017, 12:53

It works! Thank you so much :)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest