[Script] KeypressOSD - Display key press on screen

Post your working scripts, libraries and tools
User avatar
Drugwash
Posts: 567
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

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

04 Jan 2018, 06:44

Well, whatever you work on it should first pay off for yourself, and then if anybody else is happy with your work then that's a bonus. :) And to make everybody (more) happy you may have to give them options when your vision and theirs doesn't quite coincide. ;)

I've just discovered the option for visual clicks and while testing I notice it appears quite off to the left of the cursor, about 30px if not more. Is it intended or a bug? Didn't get to look at that part of the script yet, I'm caught with one of mine at the moment.

Hm, right now I see text is being erased from OSD everytime the lowercase a is being typed in, double-bar appears at the end of text and then it starts all over clean. Weird! [EDIT] It must've been a fluke, after a restart it doesn't do that anymore. Still it's worth investigating, maybe something is triggering that behavior at some point.[/EDIT]

I intend to implement an option to drag the OSD with the mouse instead of having it jump up and down on hover (mentioned that a while back).
I'd also like to fix the mouse halo start position and maybe make it a round shape.
But these are only wishful thinking for now, I already have too much on my plate (not only code-wise).
I've deleted my CloudMe account because of GDPR - the now legal base for privacy invasion and data theft.
robodesign
Posts: 367
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

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

04 Jan 2018, 09:15

Thank you, drugwash. Any help is welcomed.

I'm currently working on an alternative approach for the typing mode which will likely have really full support for dead keys.

The visual mouse clicks option is intended to be that way. Each type of click highlighted, but not exactly beneath. But it suffers from the same "initial start point" issues as the halo.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
My home page.
User avatar
Drugwash
Posts: 567
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

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

04 Jan 2018, 13:26

I got the OSD drag working almost OK but it suffers from a slight lag when movement starts. I'll fiddle around with it a bit more. I see you're using timers to detect when cursor hovers the OSD, instead of monitoring WM_MOUSEMOVE and comparing to Gui Hwnd. I'm using that combination for the drag function so it may be a good idea to combine both drag and toggle position in using the same method. I'll probably try that at some point.
The drag needs some changes in the OSD appearance panel, either a triple radio or a dropdown list, to select Fixed, Toggle or Drag. For now there's only a variable that enables this function and must be manually set in the script.
Visual clicks and halo will have to wait.
I've deleted my CloudMe account because of GDPR - the now legal base for privacy invasion and data theft.
robodesign
Posts: 367
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

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

04 Jan 2018, 15:21

Hey, drugwash! That's great to hear! Thank you very much!

What I suggest is.... having an option at OSD appearances a checkbox: "Handle to drag the OSD".

When this is enabled a gray little box could be placed at its corner. When the user drags it, it drags the whole OSD. What do you think? This would make most sense to me...

Here's today new version:

by Marius Sucan (robodesign.ro)
v3.94 (2018-01-04)
- [new] Secondary/alternative typing mode. Access it with Winkey + Enter. A new approach to the typing mode. Full support for dead keys for any layout.
- The dead key symbol is shown when such a key is presssed and the resulted combination.
- it works even if typing mode is disabled
- On Enter, the text is sent to the current app.

- reduced delays when automatic layout change occurs;
- re-added on request [from drugwash] the option to choose another script when the main file is missing when the script attempts to reload itself

Download AHK file from or use the Update now option:
https://github.com/marius-sucan/KeyPress-OSD
http://marius.sucan.ro/media/files/blog ... ss-osd.ahk
Please use AHK_H v1.1.27 [unicode] to execute this script.


P.S. I still have some bugs to fix [although.... please still report the bugs you find] and options to implement regarding this new mode. I will try to implement ways to facilitate the usage of this alternate mode.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
My home page.
User avatar
Drugwash
Posts: 567
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

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

04 Jan 2018, 16:07

robodesign wrote:a gray little box could be placed at its corner.
Not ergonomic, user would have a hard time to reach that place as opposed to the whole OSD GUI. If they need to move it while typing a long delay could interrupt their flow of thinking so we need to make it as painless as possible. Not to mention if you plan on keeping the hide or toggle active they would most likely start playing "find the OSD, where did it go?" than do their work. My opinion.
robodesign wrote:Secondary/alternative typing mode. Access it with Winkey + Enter.
I don't have a WinKey on my IBM Model M keyboards. Alternatives? :roll:

Thanks for reinstating the missing file handling, for the regular user it shouldn't even feel it's there but for testing/development purposes it's useful. :thumbup:

I also noticed you're using ternaries for toggling variables, when a much simpler (and faster) way would be the boolean negation, i.e.

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

GUIposition := !GUIposition
ForcedKBDlayout := !ForcedKBDlayout
SilentMode := !SilentMode
Capture2Text := !Capture2Text
I've deleted my CloudMe account because of GDPR - the now legal base for privacy invasion and data theft.
robodesign
Posts: 367
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

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

04 Jan 2018, 16:10

oh, that's a good idea/suggestion for coding... thank you, drugwash!

No alternatives yet, ... for now... just change the key binding: Hotkey, #Enter, ToggleSecondaryTypingMode
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
My home page.
User avatar
Drugwash
Posts: 567
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

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

04 Jan 2018, 19:55

Here's two modded files: the main script and the mouse functions.
keypress-osd-ahkH 3.93.1 mods.7z
(33 KiB) Downloaded 12 times

Main file has drag enabled by default (the Drag2Move variable controls it, set to zero to disable).
The other has all halo/flash/clicks fixed (or so I think, at least), plus the halos are round now. This could also be made optional by conditioning the WinSet, Region commands by a new variable.
I chose to show/hide the GUIs instead of constantly creating and destroying them.
The problem was calling GuiGetSize() on nonexistant GUIs, which returned blank parameters for W and H, hence the miscalculations.

Gotta get some sleep, it's almost 3AM.

[EDIT] 2018.01.05 13:15
Here's the modded 3.94 with all changes from 3.93 applied (I changed the hotkey for Secondary Typing Mode to Ctrl+Shift+Enter):
keypress-osd-ahkH 3.94.1.ah1u.7z
(32.41 KiB) Downloaded 14 times
I've deleted my CloudMe account because of GDPR - the now legal base for privacy invasion and data theft.
rommmcek
Posts: 372
Joined: 15 Aug 2014, 15:18

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

05 Jan 2018, 09:29

I tried 3.94.1.ah1u.7z version and it is usable again after pretty long time! Cursor is o.k. and diacritic is displayed at least shortly in OSD even if vowel pressed afterwards appears without it, so it gives enough feed back to user!

P.s.: I wonder if solutions in TypingAid would be of any help for this development?
robodesign
Posts: 367
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

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

05 Jan 2018, 12:47

Hello, drugwash !

WOW, that's impressive to hear! Thank you very much!

But... unfortunately, it does not work here. I tested both files and I went through the code. I was unable to figure why it does not work. I click on the OSD, to drag it and nothing happens. The mouse halo is still square and the initial position of the visual mouse clicks behavior is the same.

rommmcek: Great to hear it is getting better. Please, report the issues you are experiencing with it. It is the only way I can make it better, by learning / hearing what's going wrong.

Ps. Sorry for the late response, but had a hectic day.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
My home page.
User avatar
Drugwash
Posts: 567
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

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

05 Jan 2018, 14:18

Marius, please make sure you used the right files in the right places. It works fine here (but this is XP x86). Can't post a screenshot because those transparent halo GUIs can't be captured (or I don't have the right tools).

Today I've been polishing things a little bit but I wasted a lot of time in vain trying to understand why some function works in a simple test script and it doesn't work in this one. AHK has some quirks like this that drive me crazy. :headwall:

Anyway, here's the new version; it has to work because I'm using it now as I'm typing:
keypress-osd-ahkH 3.94.2.ah1u.7z
(33.24 KiB) Downloaded 10 times

(Use mouse-functions from the 3.93.1 package above for round and fixed mouse halo/flash)

Changelog:
- completely fixed saving/loading of custom colors
- reworked the drag option and included it in the settings panel
- replaced Progress controls with ListViews for control picker (unfortunately they get stuck so function is disabled; any help here?)
- minor code optimizations (boolean instead of ternary)

@ rommmcek: Did you also install the mouse-functions file from the previous 3.93.1 version? If not please try it and report back. What OS/type are you using for the tests?
I've deleted my CloudMe account because of GDPR - the now legal base for privacy invasion and data theft.
robodesign
Posts: 367
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

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

05 Jan 2018, 14:57

My apologies, drugwash....

But it does not work here at all. When I enabled drag-mode, and returned to the preferences, it crashes. I was unable to the drag the OSD and the mouse halo is still square.

I would really like to get this working....

EDIT: I got it working!!!!! I had to remove the textfield control and use the text control. can we get it working with the text field? this flickers toooo much.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
My home page.
robodesign
Posts: 367
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

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

05 Jan 2018, 15:13

Hello!

Today''s new version is here:

by Marius Sucan (robodesign.ro)
v3.95 (2018-01-05)
- [new] option to paste on click the written text when using the alternate typing mode
- [new] option to immediately change to alternate typing mode, when typing
- [new] option to deactivate/activate the keyboard shortcut for alternate typing mode
- changed shortcut from WinKey + Insert to Ctrl + Insert.
- bug fixes

Soon, thanks to drugwash... the ability to drag the OSD and mouse features improvements (@drugwash: I still did not get these to work)... .

Download AHK file from or use the Update now option:
https://github.com/marius-sucan/KeyPress-OSD
http://marius.sucan.ro/media/files/blog ... ss-osd.ahk
Please use AHK_H v1.1.27 [unicode] to execute this script.

@drugwash. should I stop working tomorrow on the script? Now we have two versions that are different. How should we proceed? Do you merge the improvements you made to my version? They still need some work first, to get them working properly, here...

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
My home page.
User avatar
Drugwash
Posts: 567
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

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

05 Jan 2018, 15:43

What textfield are you referring to? Please offer more details. Maybe you meant the Edit control in the OSD, used for OS versions other than XP? In that case I'll have to perform some specific tests, you know it didn't work well with Edit in XP. I'll se what can be done.

Could you please perform a separate test regarding the WinSet, Region command? If the halo shape doesn't get round then maybe the region command is not working. I'll review the code again.

I always merged the changes to the current version. I'll try that with 3.95 too and if I manage to merge everything I'll post it back here a.s.ap. In the mean time, drag can be disabled by simply omitting that option from the DropdownList (and maybe forcing a value of 1 for JumpHover if it's been saved as 3), but only for non-XP, since here everything works as it should. BTW, please test in a separate folder with no ini file, since the values for JumpHover are now 1 to 3, not 0 and 1, so if you have it as zero that may be a reason for the crash.

Mouse halo/flash should not be a problem, if they still appear as before - square, that is - then we leave it as is until we find the problem (and hopefully a solution). I'm afraid most of the testing should be on your side since I don't have either an x64 machine or anything above XP. But please feel free to contact me for details by any means.
I've deleted my CloudMe account because of GDPR - the now legal base for privacy invasion and data theft.
robodesign
Posts: 367
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

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

05 Jan 2018, 15:59

Yes, it's that edit control for Create OSD Gui()... Thank you very much!!! I will wait then for your updated file and then do my best to get everything working. Please test with the edit control.
Gui, OSD: Add, Edit, -E0x200 x%positionText% -multi %textAlign% readonly -WantCtrlA .............


Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
My home page.
User avatar
Drugwash
Posts: 567
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

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

05 Jan 2018, 16:08

I'm on it now. Funny thing is, I have implemented a way of dragging all kinds of controls (including Edit) long ago in SmartGui Mod (unreleased version) but I can't remember anything about that code. :) I'm still digging around.

[EDIT] 2018.01.06 02:26
Darn controls, one would think they were intentionally screwed up by design. I think I nailed it but it took me a lot of time and an extra coffee cup.
Please test this version, not yet merged with the latest - drag should work now with Edit control as well as with Static:
keypress-osd-ahkH 3.94.3 mods.7z
(34.63 KiB) Downloaded 11 times

[EDIT] 2018.01.06 03:09
Merged changes with latest v3.95. Untested, it's too late already.
keypress-osd-ahkH 3.95.1 mods.7z
(35.07 KiB) Downloaded 11 times


Note: in order for the drag to work on non-XP systems, the Edit control must be temporarily disabled and then reenabled, so don't worry if you see that behavior. I found no other (easy) way to capture click'n'drag with an Edit.

No change in regard to halo/flash yet, the mouse-functions file is there just for completeness' sake.

Please test thoroughly and report any unusual issues.
I've deleted my CloudMe account because of GDPR - the now legal base for privacy invasion and data theft.
robodesign
Posts: 367
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

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

06 Jan 2018, 04:10

Hello!

Just a quick update: I got the mouse improvements working here as well. To my bad, yesterday, for some reason I failed to load your mouse functions file. Darn, I feel stupid. I must have been utterly tired or I drunk, lol. All these changes are good. Thank you A LOT!!!

Now... I am looking into the drag OSD feature. Temporarily disabling the edit control sounds fine to me.

EDIT: For the visual mouse clicks, to position the little boxes, I was using GetGuiSize to determine the exact size. It is working with different DPIs. I had to re-use it for these to be positioned correctly with high DPI scale.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
My home page.
User avatar
Drugwash
Posts: 567
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

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

06 Jan 2018, 08:06

Glad you figured it out, happens to me all the time. :) Lucky you, still got "liquid antibiotics" - mine's over (money as well) and sobriety doesn't suit me at all. :lol:

GetGuiSize() should only be used on existing GUIs, otherwise W and H would be returned as zero, which throws the new GUI off at creation time. Didn't know about the DPI issues, I'm using standard DPI here, never ever messed with it not even for testing purposes. I'll see if it can be worked around, unless you already fixed it.

The drag may not be perfect, but what a drag to find a solution! :D The only flaw I see for now is that sometimes it's possible for the last active window not to be reactivated when drag ends, the OSD retaining the Active property. User can refocus the working window with a simple click but still I don't like this unreliability. But if it works close enough to perfection then maybe it'll stay in. Just make sure you don't move around those condition blocks or commands/functions that use JumpHover, or it may all go haywire. :)

Do you have a good diff tool to check the changes? I use Total Commander's built-in function (File > Compare by content), it's not perfect but gets the job done.

Did you notice the ListView controls in the settings, for color picking? They look more stylish than Progress controls, at least here. There's also the Hand cursor on hover. But it didn't work, although some of my scripts have used that trick for years. I was about to give up but then I found the culprit: Critical is in effect! Disabling Critical for that function allows it to work correctly. Modify the code as per below and see it in action:

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


I'm still in recovery after last night (went to bed at 4AM, fell asleep around 5-5:30 because of the second coffee) so I probably won't be messing (much) with the script for now, but expect those Pick buttons to dissapear since they won't be needed anymore - unless for some reason the LV trick won't work for you or other users. But that's to be tested.

Oh and could you please mirror AHK_H 1.1.27.03 for me when it goes out? You know: timeout (or CDN change or whatever). You should check it out too, more vk/sc-related fixes.
I've deleted my CloudMe account because of GDPR - the now legal base for privacy invasion and data theft.
robodesign
Posts: 367
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

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

06 Jan 2018, 08:18

Okay, thank you very much for your infos.

I just finished merging in the DragOSD option/feature. I had to change quite a few things to get it working. But it is all fine now, hopefully for you there as well... I also made sure it is working with the Position presets I already had.

A bit later, I will begin to implement those changes you made for the color pickers.

I also found some messy bugs with the dead keys support. I think I finally realised why dead keys did not work for burque505. I have to work on this as well... Then I will release the new version - probably tomorrow.

I use WinMerge for diffs. Again, many thanks.

Best regards, Marius
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
My home page.
User avatar
Drugwash
Posts: 567
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

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

06 Jan 2018, 09:17

Don't thank me so much, it'll go to my head. :P
Make sure you don't lose the cclvo string variable, it contains the LV styles required for the trick to work.
I'm trying to find an easy way to have tooltips on those color pickers although that might be overkill.
BTW, you may remove Gui, %g%: +OwnDialogs +hwndhC from setColors()

Could you tell/show me what you had to change for the drag function? I'd like to test here on XP, make sure it doesn't break. Didn't the last mod work for you as is, without any changes drag-wise (or otherwise)?
I've deleted my CloudMe account because of GDPR - the now legal base for privacy invasion and data theft.
robodesign
Posts: 367
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

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

06 Jan 2018, 14:59

Hello, people!

Today's new version features a myriad of changes and improvements.

by Marius Sucan (robodesign.ro)
v3.96.5 (2018-01-06)
- [new] option to change color for the alternate typing mode highlight
- MANY bug fixes; the alternative mode for typing was not functioning in many, many scenarios; it was very screwed ;-) .... still got some bugs left to fix
- considerably improved dead keys support

by Drugwash (robodesign.ro)
v3.96 (2018-01-06)
- [new] option to enable the possibility to drag the OSD
- improved UI: removed the buttons to pick colors, you can now click the colors to change them
- mouse halo is now round, when idling, the flashing halo is round as well
- improved the positioning of visual mouse clicks elements

@drugwash: I will upload the new ahk_h version file tomorrow, if it's available. Thanks a lot again for your great work. Let me know if there's anything wrong with the new version.

@rommmcek: I will look into TypingAid. It seems like a good source to learn some things.

Download AHK file from or use the Update now option:
https://github.com/marius-sucan/KeyPress-OSD
http://marius.sucan.ro/media/files/blog ... ss-osd.ahk
Please use AHK_H v1.1.27 [unicode] to execute this script.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
My home page.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: leosouza85 and 23 guests