Recent

Author Topic: Reset keyboard  (Read 3093 times)

pcurtis

  • Hero Member
  • *****
  • Posts: 636
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
Laz 2.0.10
FPC 3.2.0

pcurtis

  • Hero Member
  • *****
  • Posts: 636
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
Laz 2.0.10
FPC 3.2.0

paweld

  • Sr. Member
  • ****
  • Posts: 306
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
paweld

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1584
  • 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
Lazarus 2.3 2021-08-10 FPC 3.3.1 r49223 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.3 r65500 FPC 3.3.1 r49634 macOS 11.5.2 aarch64 Xcode 12.5.1
Lazarus 2.3 2021-08-11 FPC 3.2.2 FreeBSD 13.0 amd64 VMware VM
Lazarus 2.1 r61574 FPC 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 FPC 3.2.0 Win10 Parallels VM

pcurtis

  • Hero Member
  • *****
  • Posts: 636
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
Laz 2.0.10
FPC 3.2.0

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1584
  • 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.
Lazarus 2.3 2021-08-10 FPC 3.3.1 r49223 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.3 r65500 FPC 3.3.1 r49634 macOS 11.5.2 aarch64 Xcode 12.5.1
Lazarus 2.3 2021-08-11 FPC 3.2.2 FreeBSD 13.0 amd64 VMware VM
Lazarus 2.1 r61574 FPC 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 FPC 3.2.0 Win10 Parallels VM

pcurtis

  • Hero Member
  • *****
  • Posts: 636
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
Laz 2.0.10
FPC 3.2.0

 

TinyPortal © 2005-2018