[Script] KeypressOSD - Display key press on screen

Post your working scripts, libraries and tools for AHK v1.1 and older
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, 15:40

Well, I'd settle for a faithful shadowing of whatever I'm typing, including dead keys, regardless of whether they're working as dead keys or just as normal keys. ;)
Applying changes without reload would be a plus, of course.

Mouse halo/flash are now centered in XP but first appearance of the flash rectangle is off (down-right) everytime it idles, then it jumps to the correct position. Not a biggie, just reporting.

I'm not that lazy to let a script make coffee for me but it'd be quite nice for it to pay the bills with its own money, because I ain't got any. :D
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, 17:10

I'm already working on the pay the bills! It's coming along nicely. Microsoft has nice APIs for this :-) ....

On a serious note, I'm trying to shadow dead keys better, indeed.

Do you know how I can get onMesssage work with a non active ahk window? I got it to work when the script window is active and detects precisely dead keys and chars obtained with dead keys, but I must make it work when it's not an active window. That is, it should work everywhere.


PS. I'm aware of the issue with the initial placement. But it's minor.

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

11 Dec 2017, 02:02

You'd need a low level keyboard hook for a better script operation but that's in the grey area, at best. The StackOverflow page linked before refers to the callback procedure where there's reference to SetWindowsHookEx. Dunno if you can make it without that and I believe OnMessage() won't work on an inactive window.
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

11 Dec 2017, 07:54

Actually, it is possible, please see my post:

https://autohotkey.com/boards/viewtopic.php?f=5&t=41230

If anyone reading here, knows how to write the DLL Calls, I would be happy. Thank you very much.

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

11 Dec 2017, 08:50

Please read very carefully the documentation for SetWindowsHookEx() on MSDN.
[…] hMod - [in] - Handle to the DLL containing the hook procedure […]
and
As most of you might know, a system wide hook must be implemented using a DLL.
means the procedure must reside in a separate library (DLL). And it must be very fast in order to process all keyboard messages in real time. Not to mention some of those messages may come from scripts and may be very fast.

The documentation at MSDN makes it clear there must be two DLLs - a 32bit and a 64bit - when running on a 64 bit system and they both must be handled by the calling application (that'd be the AHK script) in order to hook both 32bit and 64 bit applications that receive keyboard input.
Moreover, the UWP apps require for the hook to be handled by UIaccess applications. So all in all this is tough.
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

12 Dec 2017, 13:49

Hello!

Here's today's new version:

v3.75 (2017-12-12)
- [new] option to make Up/Down behave like Home / End or Left / Right, at Typing mode window
- [new] option to make Page Up / Down behave like Home / End, at Typing mode window
- [new] support for Ctrl + a / c / x / z

v3.74 (2017-12-11)
- [new] support for selections with Shift + Left / Right / Home / End.

I implemented support for selections with Shift and... Ctrl + Z and others.

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

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: 1731
Joined: 22 Jan 2017, 19:37

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

12 Dec 2017, 18:56

:bravo:
Hi Marius, all good here! Everything is working for me - Spanish, Russian, German, English -- bravo!
Regards,
burque505
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

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

13 Dec 2017, 04:06

Yaaaaayyy!!!! great to hear!!!! And thank you very much for your feedback!

Last night, I came up with an idea on how to make it always show the correct dead key symbol when pressed even if it's with Shift or AltGr. I hope I can implement it and that it will work. But today I will continue to work on caret/cursor improvements. I have to finish this *chapter*. Caret jumps with CTRL + left/right are still missing :)

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

14 Dec 2017, 15:02

Hello!

Today's new version:

v3.77 (2017-12-13)
- [fixed bug] the features implemented yesterday were not working with Default settings. Ctrl + C/V/A/X worked only if Sticky keys were enabled. Now these should work for anyone.
- [new] implemented support for text cursor/caret navigation jumps with Ctrl + Left/Right and Backspace/Delete
- bug fixes and improvements for OSD caret navigation

Next is:
- implement support for caret jumps with ctrl+shift+left/right
- get the proper dead keys symbols at start.

and then AutoHotkey_h migration to add multi-threads for key beepers and the mouse features and separate the script into different files. This willl make it more responsive and fluid.

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

Please note, there is no application out there that implements the same way how the caret jumps between words. Therefore, there's a real inconsistency across applications. I tried to nail the basic moves only, in particular ... from the Chrome browser.

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: 1731
Joined: 22 Jan 2017, 19:37

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

15 Dec 2017, 14:58

Hi Marius,
For me on Win7 64bit, a couple of new twists. In Spanish, typing '?' shows up as '¡' for one keystroke, then changes in the OSD to '?' again. This only seems to happen at the beginning of a line.
In German, at the beginning of a line only,'Ü' shows up in the OSD as Shift + 'Ü'. Then it goes to 'Ü' on the next keypress.
Regards,
burque505
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

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

15 Dec 2017, 16:50

Thank you very much for your feedback. I'll investigate this tomorrow.

I also discovered some bugs that need fixing.

I hope to release a new version tomorrow.

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

17 Dec 2017, 07:52

Hello!

Finally, the new version is here. I managed to implement an alternative set of rules [available as an option] to jump between words, with Shift or not. And I also implemented two features with shortcuts that should enable a smoother usage on a daily basis: to get or send text from/to the host app. This facilitates easier synchronisation between the OSD and the host app.

@burque: I hope I fixed the nuissance you reported.

Please watch the new demo.
Image

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

by Marius Sucan (robodesign.ro)

v3.80 (2017-12-17)
- bug fixes and overhauled the layout of Typing mode windows settings.

v3.79 (2017-12-16)
- [new] paste OSD content into active window / text field with Ctrl + Shift + Insert
- [new] synchronize OSD content with the current active window / text field with two modes of operation; shortcut: Winkey + Insert
- [new] alternate mode for caret/text cursor jumps
- bug fixes and improvements

v3.78 (2017-12-15)
- Implemented support for Ctrl + Shift + Left / Right

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.
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

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

18 Dec 2017, 02:42

Just to thank you again for your work ;)
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

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

18 Dec 2017, 03:47

Thank you, ozzii. I am happy when people write me, even about bugs. I was wondering if you still follow the thread ;-).

Please let me know if you have any suggestions or bugs to report.

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

18 Dec 2017, 06:30

offtopic:
I have a big big problem, but it's not with the script. It's your GIFs. Please please please don't post them as images but as links, if possible - for some reason (probably a bug in the browser) your GIFs (in conjunction with page scrolling, maybe) open a huge memory leak that can lead to complete system crash unless browser is forcibly closed as soon as possible.
This happened before a few times, but never (noticeably, at least) with small GIFs on random pages - only with yours, so large size may be the culprit.
Sorry for being such a PITA. :(

[EDIT] No, it's not (only) the browser. 1456 frames at a size of 1139x358 px can bring many (old) systems to their knees. And you said you had a modest system…
I'm curious what application you use for creating those GIFs because here my image renderer (Imagine by Chun Sejin) shows this one as being 1bpp which is not accurate. And it took it 166.81 seconds to actually load that GIF. FastStone Image Viewer loaded it more quickly and sees it as 32bit images, frames appear to be progressive, which most likely neither my QtWeb browser nor Imagine have knowledge of. Goddamn progress…
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

18 Dec 2017, 10:01

Hello, amigos!

@drugwash: Ugh, that sucks big time!!! can you please suggested a way to convert it into something more accessible? I capture the screen with something called LICEcap. Any suggestions?

@everyone: New version is here with the promised improvements for dead keys support.

Change log:

v3.81 (2017-12-18)
- [improved] the exact dead key symbols for Shift and AltGr automatically detected; hopefully the correct ones for everybody :)
- bug fixes related to caret navigation.

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


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

18 Dec 2017, 12:50

Just downloaded and tested that application, it doesn't have any useful settings, except maybe for "Use .GIF transparency for smaller files", but that may lead to worse performance in large files. But I've performed some tests and it still creates 32bit frames despite the GIF transparency setting so it'd be of no use.

Frankly I don't know what formats this browser accepts, I know I don't have (nor want) Flash on my system so there may be no other feasible option for displaying animations directly in the/this browser. I also don't know of other (free) screen capturing applications that could create old-style GIFs (8bpp frames), if that could somehow avoid the memory leak. [EDIT] See here for a few screen capture applications. [/EDIT] That's why I suggested - at least for the moment - the simpler option of placing a link to the GIF rather than embedding the image: people can open it in a new window/tab or download and view locally in an appropriate image viewer. I know it wouldn't be catchy but it would be safe. It's up to you.

On a brighter note, dead keys appear correctly now in the OSD with v3.81. :) The only minor issue - if I can call it like that - is that in OSD they're behaving correctly as dead keys, that is they wait for a valid character to follow to form a composed character otherwise the caret doesn't advance, while in the typing window they're being placed directly and the caret advances - that is they don't actually behave like dead keys but like normal keys. I've mentioned this before in relation to layouts being set as default, seems to be a system issue. I'm not sure if the script should strictly follow system's behavior or it's just fine the way it works now. Thought I should mention it, is all.

Anyway, good job, you finally nailed it (at least for the RO layout) . :)

[EDIT] There still is one minor issue: OSD will not appear if user starts typing with a dead key right after script start. So if I wanted to type ˇ^˘°˛·´˝¨¸ for a demo I'd have to type whatever other regular character first, otherwise there would be no OSD.

Something else that bugged me while trying to test some screencap applications: how on earth would one clear the OSD history? Everytime I tried to capture a demo a large string of whatever I typed previously would interfere. I want a clean OSD - how do I do it, apart from restarting the script?

Oh and while at that, Don't bother with GifCam, it yields same 32bit frames too despite the apparently useful menu at the Save button (split button is not available in XP, must right-click the button to get it) and its logic is stupid, it works in 'pause' mode so if you click Start/Stop a few times without saving it'll add to the frames, ending up with a huge, possibly unrelated pile of frames. No way to discard unwanted previous frames other than restarting it.

Others on the page linked above are .NET, either incompatible with XP or cloud-based. Apparently nobody can create plain old 4/8bpp GIFs nowadays. :(
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

18 Dec 2017, 15:04

Thanks for the feedback and list of alternatives for LiceCap.

To erase what you have written, there's an option at Typing mode for Erase on Escape or Enter.
@burque505: Please test v3.81. I want to know if the dead keys still work fine for you ;-). Thank 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.
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

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

18 Dec 2017, 17:00

robodesign wrote:To erase what you have written, there's an option at Typing mode for Erase on Escape or Enter.
Not good. One may hit Enter many times during typing but may only want to erase text at certain moments of their choosing. Escape may have unwanted effects depending on the application so it would usually be avoided.
Something else in needed, a 'clear on demand' option. If OSD would not be hidden on hover we could have a small context menu including this option and other useful ones. ;)
Gonna hit the sack now. Good luck! :)
Part of my AHK work can be found here.
burque505
Posts: 1731
Joined: 22 Jan 2017, 19:37

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

18 Dec 2017, 18:10

Hi Marius, dead keys are --well-- dead! In Spanish, accent shows up in the OSD, but not in the application. :(
Regards,
burque505

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 131 guests