[Script] KeypressOSD - Display key press on screen

Post your working scripts, libraries and tools for AHK v1.1 and older
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

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

07 Dec 2017, 13:15

Hello!

Today's new version:

v3.69 (2017-12-07)
- more bug fixes related to dead keys support and AltGr
- [new] option to not bind dead keys at all @ typing mode preferences window.
- added complete support for Setswana and Sesotho sa Leboa and made small fixes for other layouts

@burque505. Please test Spanish and Russian. I want to know if I managed to fix the dead keys issues. If you still encounter issues using the dead keys, test the new option from the Typing mode window: Ignore dead keys.

Download AHK file from or use the Update now option:
http://marius.sucan.ro/media/files/blog ... ss-osd.ahk

@drugwash: I never encountered such Windows bugs, luckily. The exit jingle was silly ;-).

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
burque505
Posts: 1734
Joined: 22 Jan 2017, 19:37

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

07 Dec 2017, 15:25

Hi Marius,
Still the same problems with Spanish related to any dead key that is shifted. Non-shifted dead keys work. Again, not only does it not show in the OSD, it also kills the key combination. I tried every combination in typing mode without success. Russian has only a few errors with shifted number keys, which I use so seldom it is not an issue for me. In general, Russian is working better than Spanish!
Dragoș's link above seemed like something worth investigating, although I'm not sure what the AHK implications are. I haven't had time to go through your code (nearly 5000 lines now! That's a lot of work), but would it be worth checking to see if there are places where ~Shift might be useful? Because it seems all the problems I'm having with Spanish now are related to the shift key.
Sorry I don't have more time to look at this, I will this weekend.
Regards,
burque505
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

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

07 Dec 2017, 15:33

I am sorry to hear this...

You cannot use the dead keys even if you checked ..... Ignore dead keys in Typing Mode window?

The function where I bind to keys is CreateHotkey().

When the option " Ignore dead keys in Typing Mode window" is checked.... I simply ignore those keys, they are not attached to my AHK script. I would be amazed if they do not work when this option is checked, must be something fishy there.

I even installed Windows XP, in virtual box, to try to discover the bug, but still I cannot reproduce it. So, for me it works in XP, Win 7 [both in VMs] and on two different PCs with Windows 10.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

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

08 Dec 2017, 03:24

Maybe the virtual machine does something that the "real" hardware doesn't, thus preventing the bug.
Have you tried installing the RO layout (or any other layout you're comfortable with that uses dead keys) in XP/7, setting it as default, then reboot - a few times, if needed - and test if dead keys still work? Maybe go as far as deleting any other layouts and only keep the RO (or whatever you chose) - as I did on this XP - and test again. Because here even without your script running I still can't use dead keys, all the diacritics (ˇ^˘°˛`·´˝¨¸) appear immediately when pressing the AltGr+numbers combination and I strongly suspect it's because I only have RO layout so it's obviously set as default.
I can't test adding/changing layouts because I hate reboots and try to avoid them as much as possible - my uptime now is 6 weeks 1 day. This is real hardware, not VM; unfortunately I don't have enough resources for that, not even on the Linux machine, otherwise I would've performed tests myself.
Part of my AHK work can be found here.
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

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

08 Dec 2017, 08:59

Oh, that's bad.... Maybe this is what burque505 is experiencing too...

Anyways, drugwash, I am migrating the script to toASCII api for shift and AltGr. I'm almost done...I hope to work out all the kinks I still have with it... If I succeed, the script will no longer rely on hard-coded shift and AltGr pairs. THANK YOU VERY MUCH FOR your help and feedback. The link yesterday was enlightening.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
burque505
Posts: 1734
Joined: 22 Jan 2017, 19:37

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

08 Dec 2017, 09:08

Best of luck with it, Marius! I'm looking forward to seeing your results.
Regards,
burque505
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

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

08 Dec 2017, 09:32

Thank you, burque505.

Please tell me, do the dead keys work for you when the option " Ignore dead keys in Typing Mode window" is checked? It's very important that I know this.

If they still don't, please make sure they work when the script is not running.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
burque505
Posts: 1734
Joined: 22 Jan 2017, 19:37

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

08 Dec 2017, 11:08

Hi Marius,
With or without "Do not bind (ignore) known dead keys", with typing mode only checked or unchecked. the dead keys work unshifted. They don't work shifted. So 'éé' appears instead of 'éë' in Notepad.
One difference between "typing mode only" checked and unchecked - when "typing mode only" is checked, the first time I use a dead key (unshifted, that is), the accent doesn't appear. I have tried every combination I can think of in preferences, but the results are always the same - shifted dead keys don't work. Unshifted dead keys do.
Everything works as intended when the script isn't running.
Regards,
burque505
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

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

08 Dec 2017, 15:13

Thank you very much for the clarifications. I appreciate it a lot.

I am almost done with the new version.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

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

08 Dec 2017, 15:54

@burque505:

please test this version:
http://marius.sucan.ro/media/files/blog ... s-test.ini
http://marius.sucan.ro/media/files/blog ... 9-test.ahk

Both files are required.

To be tested only with 040a = SPANISH (traditional)

Thank you.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
burque505
Posts: 1734
Joined: 22 Jan 2017, 19:37

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

08 Dec 2017, 16:39

Hi Marius, it works in Notepad 100% in Spanish SOMETIMES, as far as the correct characters being typed in Notepad, but sometimes it fails. If the keyboard is switched in the OS to Spanish before the script starts, the characters don´t display correctly in Notepad. If I switch to English and back again to Spanish, it works. Sometimes. Sometimes not. Sometimes nothing I do will make the dead keys work.

All the shifted and unshifted characters in the numbers row display correctly. Accented characters appear in the OSD either without an accent or, sometimes, with a grave accent in front of the letter.
All I can say, is sometimes the dead keys work just fine, and sometimes it kills the dead keys.

HOWEVER: If in the typing mode settings I have these checked: "Show single keys in the OSD, not just key combinations"; "Typing mode only"; "Enter and Escape keys erase texts from the OSD"; "Enable Ctrl+Alt/AltGr support"; "Make beeps when typing with CapsLock turned on"; and "Do not treat dead keys as a different character (generic symbol)", it is working. When I switch to English and back to Spanish, it fails for the first one or two characters, but then starts working again. Then it will fail without any apparent reason.

AND: I use a script to keep a window always on top if required. When I keep the preferences dialog on top, it seems to always work. Once I hit "Apply" or "Cancel", it generally works for a while, and then quits. I don't know what to make of this. It's very difficult to troubleshoot intermittent failures.

Regards,
burque505
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

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

08 Dec 2017, 17:10

Thank you very much for your detailed report. One last question.... Does AltGr+4 work? It's a dead key.

For you, it works as it did for me, but when I was in the very early stages of coding this script.

When you are at any preference window, the script suspends itself, that's why the dead keys work.

Please note, this test version is not the new version with non hard-coded shift and AltGr pairs.

Change the line that reads "sleep, 40" from onletterprressed().... to sleep, 125 and test again the dead keys with this, longer delay. Please let me know how this goes. Try even longer delays if it still doesn't work.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

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

09 Dec 2017, 09:39

Hello!

The new , major release is here:

Download AHK file from or use the Update now option:
http://marius.sucan.ro/media/files/blog ... ss-osd.ahk

Change log:
v3.71 (2017-12-09)
- bug fixes and improvements; cursor navigation should feel more fluid

v3.70 (2017-12-08) - major release
- many thanks to Helgef and Drugwash
- shift and AltGr hard-coded symbol pairs are now obsolete
- the new version uses toUnicodEx() DLLcall to get the proper key name based on Shift, AltGr and Capslock.
- added support for 3 additional Cyrillic based keyboard layouts.

Please report any problems.

@burque505: I made no major changes to the way i deal with dead keys... However, Russian should work in its entirety fine. Please test Russian and Spanish and let me know if the dead keys bug or if Russian does not work fully....

According to some people on StackOverflow, calling ToAscii or ToUnicode twice is the answer to fix dead keys. I did this. I see no change, perhaps it does work for you.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
burque505
Posts: 1734
Joined: 22 Jan 2017, 19:37

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

09 Dec 2017, 11:26

Hi Marius, I haven't found any glitches at all in Russian. In Spanish, everything works almost all the time. There is occasionally a failure to display an accented character in both the application and the OSD, but the next attempt has always been successful so far. It's very useable now in Spanish.
Best regards,
burque505
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

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

09 Dec 2017, 11:51

ooowww, that's really surprising to hear!!!

I updated the version to 3.71.1 which adds simplistic dead keys detection for unknown layouts. And probably, now, the dead keys work each time, reliably, for you as well. If somehow they no longer work...., let me know ^^

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
burque505
Posts: 1734
Joined: 22 Jan 2017, 19:37

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

09 Dec 2017, 12:45

Hi Marius, everything now seems to working 100% in Spanish, provided I make sure the Spanish keyboard is checked in "Installed keyboard layouts". It still works fine in English and Russian leaving Spanish checked, by the way. For German to work 100%, i.e. to get 'ß', I have to check German in the "Installed keyboard layouts". Spanish, I found, also works if German is checked in installed keyboard layouts.
In Russian, one time the keyboard started beeping with every key (I always have sound turned off), but I went into Preferences and back out and it went away.
Regards,
burque505
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

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

09 Dec 2017, 15:30

Wow!!! Great to hear it works well!!!

As a side note:

When you select a keyboard from the list of installed KBDs, the layout is enforced and automatic detection is turned off.

Shift and AltGr work without the need to reinitialize the script, because they are no longer hard-coded.

The detection of keyboard layouts is now relevant only for dead keys and keys to bind, because if you.start, for example in Spanish and switch to Latvian or Vietnamese, AHK may not be binded/bound to some regional keys and the script wont know what dead keys are present. So... Keyboard detection is relevant for refreshing the list of keys to bind to and update the dead keys list.

Automatic keyboard detection should work fine in Win 7.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

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

10 Dec 2017, 06:13

Glad to see good progress here. Keep up the good work! ;)
Part of my AHK work can be found here.
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

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

10 Dec 2017, 07:10

Thank you very much.... Next is... Fix mouse related features on Win 7/XP.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

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

10 Dec 2017, 13:18

Holla!

The work never ends...

v3.72 (2017-12-10)
- bug fixes related to mouse halo, idling mouse and visual mouse clicks; they should be properly positioned on different Windows versions.
- improvements regarding the detection of dead keys for unsupported layouts

IDEAS for the future [by priority]:
- make coffee button
- implement further support for caret navigation: ctrl+delete, ctrl+bksp, ctrl+left/right and even Ctrl+V; ignore ctrl+a, ctrl+z (done)
- write/add HELP
- detect kbd layout without reloads; dynamically unload/remove all hotkeys, and set new ones
- make the OSD text field non-selectable
- [add?] Customize keyboard shortcuts?
- text caret locator/highlighter on screen
- window spy, get texts underneath the mouse using Narrator's accessibility APIs
- [minor bug] it does not detect keyboard layout changes when a Metro app is active; I tried to fix it... but failed; or in different IE tabs
- OSD is never on top of Start menu in Windows 10
- make it reliably work with sticky keys; if user presses once Ctrl and another key afterwards, it rarely detects the combination on Winndows 7;
- make use of onMessage WM-deadchar ??!
- show what the dead key combination is in the OSD ?!
- pay the bills button

Download AHK file from or use the Update now option:
http://marius.sucan.ro/media/files/blog ... ss-osd.ahk

Please vote for the features you want ;-).

Best regards, Marius.
Last edited by robodesign on 20 Dec 2017, 14:01, edited 2 times in total.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 243 guests