Recent

Author Topic: Reset keyboard  (Read 3815 times)

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Reset keyboard
« 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
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Reset keyboard
« Reply #1 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.
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

paweld

  • Hero Member
  • *****
  • Posts: 970
Re: Reset keyboard
« Reply #2 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
Best regards / Pozdrawiam
paweld

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Reset keyboard
« Reply #3 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

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Reset keyboard
« Reply #4 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 :(
« Last Edit: May 18, 2021, 09:23:23 am by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Reset keyboard
« Reply #5 on: May 18, 2021, 09:28:51 am »
Windows 10 sticky keys feature works for me - I just tested it.

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Reset keyboard
« Reply #6 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.
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

 

TinyPortal © 2005-2018