[Script] KeypressOSD - Display key press on screen

Post your working scripts, libraries and tools
denyerec
Posts: 4
Joined: 25 Jul 2017, 12:26

Re: [Script] KeypressOSD - Display key press on screen

26 Jul 2017, 02:36

As you may have gathered I'm rather new at this - I didn't even realise that was an option. I'll go and look up how to do that now and see if it resolves things!

EDIT:

OK so I have run the scripts separately (Generating two instances of AHK) and it's now working as I would expect, so thankyou for that! Now my challenge is to restrict the keypress detection to two applications only. As I only want to show the keypresses in Photoshop & Lightroom (The two applications I produce tutorials for).

EDIT 2:

I am trying to restrict the key display to a couple of applications, I have created the following group:

Code: [Select all] [Download] GeSHi © Codebox Plus

GroupAdd, TutorialApps, ahk_class #32770
GroupAdd, TutorialApps, ahk_class Photoshop
GroupAdd, TutorialApps, Adobe Photoshop Lightroom - Library
GroupAdd, TutorialApps, Adobe Photoshop Lightroom - Develop
GroupAdd, TutorialApps, ahk_exe Photo Mechanic.exe


But so far have not managed to isolate the display code with a #IfWinActive, ahk_group TutorialApps block. If anyone can help, that'd be awesome!

Edit 3:

Got it :)

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

tmplinshi
Posts: 1087
Joined: 01 Oct 2013, 14:57

Re: [Script] KeypressOSD - Display key press on screen

26 Jul 2017, 09:18

@denyerec Or you can simply add Hotkey, IfWinActive, ahk_group TutorialApps before CreateHotkey():

Code: [Select all] [Download] GeSHi © Codebox Plus

Hotkey, IfWinActive, ahk_group TutorialApps
CreateHotkey()
j_fayez
Posts: 2
Joined: 05 Aug 2017, 11:59

Re: [Script] KeypressOSD - Display key press on screen

05 Aug 2017, 12:05

How to display pressed keys through this virtual Keyboard?

https://autohotkey.com/board/topic/9470 ... -keyboard/
j_fayez
Posts: 2
Joined: 05 Aug 2017, 11:59

Re: [Script] KeypressOSD - Display key press on screen

05 Aug 2017, 12:05

How to display pressed keys through this virtual Keyboard?

https://autohotkey.com/board/topic/9470 ... -keyboard/
robodesign

Re: [Script] KeypressOSD - Display key press on screen

19 Sep 2017, 10:51

When I run this script, using the International English layout, the dead keys do not work anymore.... any idea why?

Dead keys are ` and ' , these help with adding accents in combination with other letters.

Any fix possible for this?

Very nice script. Thank you very much. It should count any repeated letter or button, not just key combinations.
robodesign

Re: [Script] KeypressOSD - Display key press on screen

21 Sep 2017, 13:32

I made various improvements to the code, together with Saiapatsu on IRC (thank you very much). It is highly usable now. I use it most of the times.

todo:
; - make key combinations with space and backspace work again, e.g. Ctrl-bksp
; - make it work again with sticky keys; if i press once Ctrl and after another key, no combo detected
; - make dead keys work; now they show up only in the OSD
; - when user enables CapsLock or NumLock or ScrollLock, capitalize the key, when they turn off, lower case
; - make it count Otherkeys, not just key combinations, e.g. how many times I pressed PgUp or Enter.

Script here:
http://p.ahkscript.org/?p=34fce847

If anyone here is willing to help, I would be glad. I use it because it helps me with my visual impariments.

Thank you very much.
robodesign

Re: [Script] KeypressOSD - Display key press on screen

23 Sep 2017, 10:25

Hello!

I made fixes and improvements to the new version.

Change log (highlights):
; by Marius Sucan (robodesign.ro)
; v2.58 (2017-09-23) - Numpad keys have friendly naming, based on the numlock state. Combinations with space and backspace work again.
; v2.56 (2017-09-22) - more fixes for space usage and key combinations; now it capitalizes ScrollLock, NumLock and Capslock when turned on.

; by Saiapatsu from irc.freenode.net #ahk
; v2.54 (2017-09-21) - Scrolls through n recently typed characters instead of just the latest word

; by Marius Sucan (robodesign.ro)
; v2.50 (2017-09-20) - Changed the OSD positioning and sizing. Now it is always fixed in a specific place. Added Capslock beeper.

To do (sorted by priority):
; - add keyboard shortcut to disable/activate loop 95, if dead keys issue persists
; - make dead keys always work; with the current work around the special keys show up only in the OSD and rarely in the text field you type
; - when numlock is on, all numpad keys should initiate typing mode
; - if OSD is not visible or if previous key combinations were pressed, when user presses shift + letters or other keys covered by Loop 95, display it as a combination
; - when user types single letters, display shift + (sign or number) keys as signs, respecting the influence of the shift key, eg. Shift + 0, should be displayed as )
; - make it count mouse clicks, Otherkeys, not just key combinations, e.g. how many times I pressed PgUp or Enter
; - friendly names for mouse clicks
; - make it work reliably with sticky keys; if user presses once Ctrl and another key afterwards, it rarely detects the combination
; - always make beeps for volume keys
; - add option for making a beep at every key press or when capslock is on
; - on mouse hover, hide the OSD
; - automatic resizing of the GUI, the OSD

Any help is welcomed. I am no programmer and implementing the functions I need is very difficult for me.

Script at: http://p.ahkscript.org/?p=fd7a9b26

Thank you very much.
User avatar
Drugwash
Posts: 241
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: [Script] KeypressOSD - Display key press on screen

23 Sep 2017, 13:20

Have you ever tried this thing with a RO layout? It doesn't work at all for the diacritics (ăîşţâŞĂÎŞŢÂ), neither do combinations using Shift or AltGr. It desperately needs a different approach altogether. Same as all those virtual keyboard-wannabe scripts.
robodesign

Re: [Script] KeypressOSD - Display key press on screen

26 Sep 2017, 10:51

Hello, again!

Thank you very much for your reply. I did not test it with the Romanian keyboard, even if I am a Romanian :) .... I have my own keyboard layout, with dead keys based on ENG US keyboard layout.

I will test the romanian layout. I hope to be able to fix the problems. In general, yes, I agree, the code needs a refactoring, but I am not that skillful.

Anyways... I managed to make considerable improvements by myself to the script these past few days.

; CHANGELOG:
v2.60 (2017-09-26) - Fixed many issues with counting keys;
* reimplemented the feature to see the previous key combination, if quickly a new one is pressed;
* added options/settings to toggle previous keys, counting keys and delay;
* added shortcuts to toggle ShowSingleKey option and to reinitialize the OSD;
*added option for automatic resizing of the OSD; it can be turned off in the settings section; it is a fishy implementation, but if one adjusts it, can make it to suit personal needs;
* added option to beep when key is released or when writing with capslock

v2.58 (2017-09-23)
* Numpad keys have friendly naming, based on the numlock state.
* Combinations with space and backspace work again.

v2.56 (2017-09-22)
* fixes for space usage and key combinations;
* now it indicates when ScrollLock, NumLock and Capslock are activated.

Script available here:
http://p.ahkscript.org/?p=0b2dbf32

; to-do list (sorted by priority):
; - make dead keys always work; with the current work-around, the special keys show up in the OSD and sometimes in the text field the user types in
; - when numlock is on, all numpad keys should initiate typing mode
; - if user presses capslock when writing, the text should not be removed
; - when user types single letters, display Shift + (sign or number) keys as signs, respecting the influence of the shift key, eg. Shift + 0, should be displayed as )
; - if OSD is not visible or if previous key combinations were pressed, when user presses Shift + letters or other keys covered by Loop 95, display it as a combination; please see CreateHotkey()
;
; less important
; - on mouse hover, hide the OSD
; - make it work reliably with sticky keys; if user presses once Ctrl and another key afterwards, it rarely detects the combination
; - make it count mouse clicks as well
; - friendly names for mouse clicks
; - always make beeps for volume keys
; - insert mode; detect

Best regards, Marius
User avatar
Drugwash
Posts: 241
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: [Script] KeypressOSD - Display key press on screen

26 Sep 2017, 13:35

Please do, thank you. For more info check https://drugwash.wordpress.com/tutorial ... -romanesc/
robodesign

Re: [Script] KeypressOSD - Display key press on screen

26 Sep 2017, 16:50

Drug wash, are you a coder?

As a side note, this is not a virtual keyboard. It's just an on-screen display to help visualise what keys the user presses. It helps with my visual impairment.
User avatar
joedf
Posts: 5832
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: [Script] KeypressOSD - Display key press on screen

26 Sep 2017, 19:53

Drugwash is a very talented and knowledgeable programmer! :+1:
User avatar
Drugwash
Posts: 241
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: [Script] KeypressOSD - Display key press on screen

27 Sep 2017, 08:14

Thanks, Joe, but that's an overstatement. I'm just a simple guy playing with ones and zeroes sometimes. :)

Marius, the OSD and the virtual keyboards share the same principle: they have to understand, read and display the actual keys on the current layout. I offered the link to the OSK page just to show the RO layout which may help in testing this script. It is not only about RO but any other layout out there that is not EN. All the OSD and virtual keyboard scripts 've tested so far failed to retreive and display the correct characters because authors used a wrong approach. Even AHK_L itself fails in GetKeyName(Key) when fed with the scancodes (same as with MapVirtualKeyEx() for that matter), it requires the vk codes or the entire lParam fom related WM_* messages in GetKeyNameText() plus a few other tricks to get the right keys and combinations.

I wish I could help more but my 98SE machine is off pending a thorough hardware checkup and fix, and I never code anything until it first works in 9x.
Oh and please do not misspell my nickname, Drugwash stands for Dragoş, my real name. Thank you.
User avatar
joedf
Posts: 5832
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: [Script] KeypressOSD - Display key press on screen

27 Sep 2017, 21:55

;)
robodesign

Re: [Script] KeypressOSD - Display key press on screen

28 Sep 2017, 11:15

Hello, again!

I am back with a new and improved version.

; CHANGELOG:

by phaleth from irc.freenode.net #ahk
v2.67 (2017-09-28)
; - dead keys improvements

by Marius Sucan (robodesign.ro)
v2.66 (2017-09-28)
; - key combinations with Shift work better.

v2.65 (2017-09-27)
; - Fixed a bug with counting modifier keys;
; - improved the dead keys work-around
; - friendly names for mouse clicks
; - when pressed, volume keys always generate beeps
; - added option to differentiate between left and right modifiers
; - now it detects AltGr key
; - the key beeper now also makes a beep for modifiers.
; - capslock no longer erases text you are typing displayed by the OSD
; - now you can toggle between two different OSD positions with Ctrl + Alt + Shift + F9

; to-do list (sorted by priority):
; - if numlock is on, all numpad keys should initiate typing mode
; - when user types single letters, display Shift + (sign or numeric keys) as signs/symbols, eg. Shift + 0, should be displayed as )
; - after pressing Shift + [letter] if the following key is a single letter, remember the first Shift + [letter]
; - show Shift as a modifier, as Ctrl and Alt; Shift does not behave as the other two
; - make dead keys 100% work, always; with the current implementation, the special keys show up seemingly random in the OSD and sometimes in the text field the user types in
;
; less important
; - on mouse hover or click, hide the OSD
; - always count mouse clicks; it sometimes does, other times it does not count them; no idea why
; - counting of key fires is not initiated after OSD is hidden for awhile when the user presses the first key
; - make it work reliably with sticky keys; if user presses once Ctrl and another key afterwards, it rarely detects the combination on Winndows 7;
; - test Romanian kbd layout as suggested by drugwash

Script at: http://p.ahkscript.org/?p=eb51d9d2 .

If someone can help me with the to-do list, I would be really happy. The first ones are the most important - the first section of the to-do list. Thank you.

Best regards, Marius
robodesign

Re: [Script] KeypressOSD - Display key press on screen

29 Sep 2017, 11:12

Hello!

A new version is here:

; CHANGELOG:
; by Marius Sucan (robodesign.ro)
; v2.68 (2017-09-29) - numpad keys now work in typing mode as expected; they appear as symbols or numbers
;
; by phaleth from irc.freenode.net #ahk
; v2.67 (2017-09-28) - dead keys improvements

; TO-DO:::::::::::::::::::::::::::::::::::
; Features to implement:
; - when user types single letters, display Shift + (sign or numeric keys) as signs/symbols, eg. Shift + 0, should be displayed as )
; - on mouse hover or click, hide the OSD
;
; Glitches to fix:
; - after pressing Shift + [letter] if the following key is a single letter, remember the first Shift + [letter]
; - after a Numpad key is pressed, typing mode should begin if the second one is another numpad key
; - show Shift as a modifier, as Ctrl and Alt; Shift should behave as the other two; it is never displayed alone and countable
; - show a generic symbol for ignored dead keys; helps to clarify one was pressed
; - always count mouse clicks; it sometimes does, other times it does not; no idea why
; - once a key is pressed, counting of key fires is not initiated after the OSD was hidden for a little awhile
; - make dead keys 100% work, always; with the current implementation, the special keys show up seemingly random in the OSD and sometimes in the text field the user types in
; - make it work reliably with sticky keys; if user presses once Ctrl and another key afterwards, it rarely detects the combination on Winndows 7;
; - test Romanian kbd layout as suggested by drugwash

Best regards, Marius
robodesign
Posts: 24
Joined: 30 Sep 2017, 03:59

Re: [Script] KeypressOSD - Display key press on screen

30 Sep 2017, 04:09

I forgot to paste the code, sorry:
Link at: http://p.ahkscript.org/?p=158825d3

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

robodesign
Posts: 24
Joined: 30 Sep 2017, 03:59

Re: [Script] KeypressOSD - Display key press on screen

30 Sep 2017, 16:17

A newer version here:

http://p.ahkscript.org/?p=db5cfc58


; CHANGELOG:
; by Marius Sucan (robodesign.ro)
; v2.69 (2017-09-30) - OSD / GUI hides when mouse is over it. Many thanks to phaleth!
; v2.68 (2017-09-29) - numpad keys now work in typing mode as expected; they appear as symbols or numbers

; TO-DO:::::::::::::::::::::::::::::::::::
; features to implement:
; - when user types single letters, display Shift + (sign or numeric keys) as signs/symbols, eg. Shift + 0, should be displayed as )
;
; and numerous glitches to fix....

Best regards, Marius
robodesign
Posts: 24
Joined: 30 Sep 2017, 03:59

Re: [Script] KeypressOSD - Display key press on screen

03 Oct 2017, 14:18

Hello!

New version available.

Script at: http://p.ahkscript.org/?p=585f9e18

; CHANGELOG:
; by Marius Sucan (robodesign.ro)
; v2.70 (2017-10-03)
- added option to toggle dead keys support / work-around.
- added option to hide annoying keys that usually get in the way: Left Click and Print Screen.
- redraw improvements, reduced flickering
- disabled OSD transparency to reduce flickering

; TO-DO:::::::::::::::::::::::::::::::::::
; features to implement:
; - when user types single letters, display Shift + (sign or numeric keys) as signs/symbols, eg. Shift + 0, should be displayed as );
; - after pressing Shift + [letter] if the following key is a single letter, remember the first Shift + [letter];
; - show a generic symbol for ignored dead keys; helps to clarify one was pressed;
; - after a Numpad key is pressed, typing mode should begin if the second one is another numpad key;
;
; glitches to fix [by priority]:
; - show Shift as a modifier, as Ctrl and Alt; Shift should behave as the other two; it is never displayed alone and countable;
; - always count mouse clicks; it sometimes does, other times it does not; no idea why;
; - once a key is pressed, counting of key fires is not initiated after the OSD was hidden for a little awhile;
; - if dead keys support / work-around enabled, once you typed a caret [^], sometimes user gets randomly inserted carets when typing;
; - automatic resizing of the OSD/GUI is just a silly hack based on the default font size and the number of typed chars; it often fails to resize properly;
; - redraw issues; it still flickers too much;
; - make dead keys 100% work, always; with the current implementation, the special keys show up seemingly random in the OSD and sometimes in the text field the user types in;
; - make it work reliably with sticky keys; if user presses once Ctrl and another key afterwards, it rarely detects the combination on Winndows 7;
; - test Romanian kbd layout as suggested by drugwash;


Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Best regards, Marius.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Delta Pythagorean and 11 guests