Lazarus

Programming => Operating Systems => Windows => Topic started by: pcurtis on May 18, 2021, 07:24:30 am

Title: Reset keyboard
Post by: pcurtis on May 18, 2021, 07:24:30 am
Two things.

1. I am playing with SendInput, when I make a mistake (keys get stuck as pressed) I usually have to restart my PC to reset the keyboard.
Can I reset it programmatically?

2. Anyone know how to send, for example, ALT+0149 (numeric keypad) or CTRL+ALT+DELETE
Title: Re: Reset keyboard
Post by: pcurtis on May 18, 2021, 08:06:24 am
A little more info. I am disabled and only have one arm. It is impossible for me to perform complex key strokes, so I was thinking of an app with three toggle buttons - CTRL ALT SHIFT that I could press that would press and hold each respective key. So for example I could click ALT then press 0 1 4 9,  on the numeric keypad, release the ALT key to enter the character.
Title: Re: Reset keyboard
Post by: paweld on May 18, 2021, 08:42:35 am
https://wiki.freepascal.org/MouseAndKeyInput
or
Code: Pascal  [Select][+][-]
  1. uses Windows;
  2.  
  3. keybd_event(VK_MENU, 0, 0, 0); //alt down
  4. keybd_event(VK_0, 0, 0, 0);
  5. keybd_event(VK_0, 0, KEYEVENTF_KEYUP, 0);
  6. keybd_event(VK_1, 0, 0, 0);
  7. keybd_event(VK_1, 0, KEYEVENTF_KEYUP, 0);
  8. keybd_event(VK_4, 0, 0, 0);
  9. keybd_event(VK_4, 0, KEYEVENTF_KEYUP, 0);
  10. keybd_event(VK_9, 0, 0, 0);
  11. keybd_event(VK_9, 0, KEYEVENTF_KEYUP, 0);
  12. keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0); //alt up
Title: Re: Reset keyboard
Post by: trev on May 18, 2021, 08:49:26 am
The operating system already provides this facility: see, for example, https://www.isunshare.com/windows-10/3-ways-to-turn-on-and-off-sticky-keys-in-windows-10.html
Title: Re: Reset keyboard
Post by: pcurtis on May 18, 2021, 09:13:27 am
@trev How can I send ALT 0149 with sticky keys? The ALT key is released when I press 0, MS not very sticky  :(

@paweld VK codes do not work, I must use scan codes (0x38 = VK_MENU), but the same problem, the ALT key is released when I press another key :(
Title: Re: Reset keyboard
Post by: trev on May 18, 2021, 09:28:51 am
Windows 10 sticky keys feature works for me - I just tested it.
Title: Re: Reset keyboard
Post by: pcurtis on May 18, 2021, 10:34:37 am
I know, it works here also but out of interest  I would like to try my own app and solve the issue as described above.
TinyPortal © 2005-2018