Resolved Click through

Gloops

Well-known member
Joined
Jun 30, 2022
Messages
137
Programming Experience
10+
Hello everybody,

I intend to provide a (new version of a) form to show the state of the keyboard, when the Windows taskbar is not visible : caps lock, num lock, ins, scroll lock.

It will have an opacity adjustable with a slider.

When the user clicks on it, I should like the click to be transmitted to the element that is visible through the form (except, for instance, if the shift key is down). It can be either a web site or a document in a text editor. Perhaps the slider could be accessible to the click, and thus be an exception to the "click through" rule.

I saw some years ago that this exists, but I do not have a too precise idea of how to implement that.
 
Solution
Anyway, here's a quick simple way for you to play with the TransparencyKey, and see how it acts with a button on the form:
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Drawing;

namespace WinForms
{
    class MainForm : Form
    {
        MainForm()
        {
            Text = "Main";
            Size = new Size(800, 600);
            BackColor = Color.Green;
            TransparencyKey = Color.Green;

            var button = new Button() { Text = "Press me!", Dock = DockStyle.Left, BackColor = Color.Red };
            button.Click += (o, e) => MessageBox.Show("Got it.");
            Controls.Add(button);

            CenterToScreen();
        }

        [STAThread]...
After line 16, add Opacity = 0.25;. See if that provides a partial solution with regards to visual clutter, or just confuses the user more.

Do a Google search on "WinForms movable borderless forms". It may offer some ideas.

As an aside, my Logitech keyboard came with software that briefly shows the status of the various lock keys by flashing a 75% opaque 96x96 icon in the middle of screen with a symbol showing the status (ex. "Num" if the NumLock is being enabled, or "Num" with a slash across it if NumLock is being disabled), for about 2 seconds and then fades away. (I hate this feature of the Logitech software, but I put up with it because it has a bunch of other features I find very convenient.) I know your goal is to show a constant status, rather than a brief status change, but this may give you some ideas.

As an aside, I don't really understand the utility of this program you are making. Most keyboards have a status light for their various lock keys. I know that Logitech had that software feature because they were starting to do away with some of those status lights on some of their keyboard models. Ironically, they didn't have a hotkey to re show the status on screen on demand. You would figure that if someone wanted to see the status, there should be a way to invoke it, instead of pressing the lock key again to see if it will switch on or off. Anyway, newer Logitech keyboard models are coming back with status lights again. If the answer is that touch typists don't look at the keyboard so they won't see the current status lights, my response is that professionly trained touch typists are always start with a known keyboard state and then recall whether they have changed modes or not. So once more the utility of the feature seems moot. Maybe it is for the user pretending to be a pro touch typist?
 
I shall try that, but in fact, we want to deal with what happens when the cursor is on a control. So, if the background of the form appears more clearly, I am not sure how it helps.
Some years ago, every new laptop had LEDs on the keyboard, to inform the user about the keyboard status concerning caps lock, num lock, and scroll lock. I wrote user documentation to tell about that, so I know.
This was very handy.
Now that competition has led to propose less and less expansive laptops, if you want LEDs on your keyboard you have to explicitly ask for them when buying the laptop, and you are not sure you get them. I have a laptop with 32 GB of RAM and 3 TB of storing capacity, so I could select options. I have a back light on the keyboard and a numeric keypad mode, but was explicitly answered that LEDs on the keyboard were not available. And I had to stop procrastinating, as my previous laptop was about to be quite saturated and blocked by the Windows updates. It was high time, two weeks later my "old" laptop (three years) was at the point I needed assistance to know in which order restart the services after suppressing important applications to let place.

My mother's machine was planed to have back light on the keyboard, but as there was a problem with the camera, they eventually proposed a (normally) more expansive model, where the camera worked quite well and Anydesk also, but I realized there was no back light. So, never mind I bought her a light to clip over the screen.
She has no LEDs on the keyboard, and no physical numeric keypad. And this needs to be addressed.

Some sort of the same problem appears with Internet access. Some years ago, every ISP proposed an nntp newsgroup access, an SMTP server, and some other commodities. Now you find much cheaper subscriptions, but you have to find those elements elsewhere.
 
Last edited:
Ah, I see. It's for the laptop user, not for the regular keyboard user.
 
My suggestion: Just create a tray icon(s) app. Have a tray icon for each of the lock buttons. Basically like the way the old PerfMon would have 4 animated icons: CPU, memory, disk, network. Each of the icons would give a bar graph of the current usage status of those particular resources.
 
My suggestion: Just create a tray icon(s) app. Have a tray icon for each of the lock buttons. Basically like the way the old PerfMon would have 4 animated icons: CPU, memory, disk, network. Each of the icons would give a bar graph of the current usage status of those particular resources.

addLEDS makes that very well. And others even better, with a better visibility.

But for a user with a bad view, it is current to show the browser full screen, and in such conditions the system task bar is not visible.

Right that proposing something that displays on the status bar of Firefox would be nice. For yes, I spent energy on this, but Firefox has a status bar.
 
Ah, I see. It's for the laptop user, not for the regular keyboard user.
Yes, on an external keyboard you still have the LEDS. I intend to install a docking station, but I do not yet know when, and an advantage of the laptop is that you can take it at another place.
Well, since she has a laptop, the user is much less reluctant to go to the office where there was a tower PC before. Perhaps the reasons invoked were not the real ones.
 
Funny aside: If you want a flash from the past, try turning on the Windows "Toggle Keys" feature. :)
 
Right that proposing something that displays on the status bar of Firefox would be nice. For yes, I spent energy on this, but Firefox has a status bar.
By the way, I searched "TitleBar" in the properties of the form, but I did not find.
I presume there is a way to hide the title bar?
 
It's a matter of changing the form border style.
 
Funny aside: If you want a flash from the past, try turning on the Windows "Toggle Keys" feature. :)
Oh yes, that is very handy. On my machine I have OSD, that displays a tooltip when changing the keyboard state, so I lost the habit to activate the toggle keys sound.
 
It's a matter of changing the form border style.
And ... It begins with an F 😁
Oh yes, with None it has no title bar.
A new perspective.

(I was pretty sure I had posted this. And then I noticed the "Preview" and "Post reply" buttons".)
 
I have written a new version. Which is much lighter as it does not have to manage its position several times.
Then I came back to the forum.
I needed a moment to remember what I had to do ...

Then I realized: oh yes, I depress the Caps Lock key : "Caps" was then written on status bar of Firefox.

Perhaps some more tests can be useful, and I think this will bring some practical progress. Thanks for your tips.

I intended the program to display under the system clock, so it begins like this:

Positionning the program in the down-right corner of the screen:
            using (Graphics graphics = this.CreateGraphics())
            {
                int dpix = (int)graphics.DpiX / 96;
                int dpiy = (int)graphics.DpiY / 96;
                this.Left =
                    (Screen.PrimaryScreen.Bounds.Width
                        * dpix)
                    - this.Width / 2 - 20;
                this.Top =
                    (Screen.PrimaryScreen.Bounds.Size.Height
                        * dpiy)
                    - this.Height;// - 20;
            }

Horizontally it is strange that I have to divide the width by 2, but otherwise it was too far on the left.
But vertically, it seems I did not understand ...
I understood PrimaryScreen.Bounds as the whole dimensions of the screen, and PrimaryScreen.WorkingArea as the dimensions of the client area.

I have put Bounds, and I am in the corner of the screen only if I hide the task bar, otherwise I am on the client area. Said more simply, I am always on the client area, and that is the corner of the screen if the client area takes all the screen.

Seems I missed something.
 
Oh, I think I got it. I evaluate the position in Form_Load, so the client area is evaluated at that moment.
If I put the positioning in the Timer_Tick, then it gives something much more understandable.
As I did it it is quite nice for Firefox, probably for other applications I have to improve.
 
How is the best way to get the background color at a certain point?
Call the APIs?
Otherwise if I ask the form backcolor I do not really get it, as it is a transparency key.
 
Oh, I still have got a question.
When you put an application in full screen mode display, you do not see the Windows task bar. How is the best way to detect that?
Must I do a treatment application by application, or is there something generic?
As I presume the task bar parameters do not change.
 
Back
Top Bottom