Several utilities exist to make windows go transparent when inactive, but can an AHK script (or something else) be used to replicate Windows' show-desktop transparency effect on only inactive windows? I've not found a utility that does this.
Here is an example of what I want to achieve:
Related
The bounty expires in 7 days. Answers to this question are eligible for a +50 reputation bounty.
codeling wants to draw more attention to this question:
Give concise information (and ideally code) on how to detect dark theme on KDE and Gnome desktop environments using Qt, or if there is no direct way with Qt, using plain C++ (or at least as little additional libraries as possible).
In our Qt-based C++ application, I'm trying to automatically switch application styles based on whether the user has configured dark or bright theme.
I have figured out the notification of when a change happens (see below, for other's reference).
My main problem is the reliable detection of whether currently a dark or bright theme is used on linux (for windows see below); on XFCE, the check for QPalette color roles as mentioned in this answer works, but this does not work on Gnome and KDE Plasma for me (tested under both Ubuntu 22.04 and Fedora 36, my app built against Qt versions 6.5beta2 and 6.4.2, respectively); there the colors still seem to be taken from what I've set as XFCE theme on the same machine (and when starting xfce4-appearance-settings and changing the theme there, my app picks up the change). I would however like to adapt to the current desktop's dark mode setting.
So, my question is: How do I reliably detect application dark mode of the currently used desktop on Qt? I'm not averse to implementing a little custom platform-specific code if nothing is available directly in Qt, but it would be great if it would work without using additional libraries.
A note I saw for QApplication::setPalette I thought might be relevant here, namely "Some styles do not use the palette for all drawing, for instance, if they make use of native theme engines.", what are these all about? I did not see a link to a documentation for this feature, and a quick search for the term "qt native theme engine" also didn't seem to yield any useful results.
Since on Linux, some events are reliably triggered whenever a system theme change happens (see below), I suppose Qt can detect the theme change, it just doesn't expose data about it publicly?
Getting notified of theme changes
On Linux: via listening for QEvent::StyleChange events of the application's QMainWindow; two caveats and one side note:
That event does, despite QWidget::changeEvent documentation explicitly mentioning it, not trigger a changeEvent (for me), but has to be caught via the more generic QWidget::event
StyleChange only seems to be triggered since some Qt 6.4 version (in my tests, it was not triggered by 5.15.2 and 6.3.1, but triggered for 6.4.2 and 6.5.0beta2).
I've also noticed that there's a ThemeChange event that is also triggered (at the same time as the StyleChange; not sure what the difference is between these two though, and in what case one would be triggered but not the other... I suppose StyleChange is used for any change to the style of a widget, so that it's also called when applying some style sheet settings, while ThemeChange really indicates a change of the system theme? Though ThemeChange seems to be considered a non-public Event type, at least it doesn't appear in the documentation (marked \omitvalue)
On Windows, via checking for changes to the registry key HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize (the StyleChange unfortunately isn't triggered there at all - a Qt bug?). .
Detecting dark theme on Windows
Application bright/dark mode determined by registry key HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize\AppsUseLightTheme (1 for bright, 0 for dark). This check is also done in Qt's plugins/platforms/windows/qwindowstheme (queryDarkMode`), but I think this is not exposed publicly as generic interface anywhere?
When you open up Steam or something like the Blizzard Launcher, you'll notice quickly that they don't use the default Operating System window style. Their window frame, buttons, etc. are all custom and fancy.
I understand more or less how to create a window in C++ using the tools given by Microsoft (for Windows) or equivalent for other OSes, but I've not a clue how these fancy custom windows are created.
My brain is telling me that it must be some fancy trick using borderless windows, but that feels to much like a hack to me, something a big fancy tech company wouldn't have to cheat to pull off.
Thus I ask, assuming we're on Windows (just cuz bring in other OSes will complicate things), what exactly are these companies doing to achieve this fancy custom window affect? Is it some super low level thing a casual C++ hobbyist like me will never be able to do, or is it some fancy part of the windows tool set I can just look up on MSDN?
I am trying to make a simple app that would work with the Corsair SDK to change the colors of my keyboard programmatically. I've developed a simple one that uses straight Win32 API that uses a notification icon to hold the process and allow me to stop it.
I'm trying to make a UWP equivalent of the application using C++ as well. The thing I am looking for is the appropriate trigger so that I can run it in the background as soon as I have it installed much like the "Mail" app that runs in the background and can create notifications (which I won't be doing yet).
Also I would like it that I don't have any forms (or at most have it integrated with Settings)
However for now, I would just like to figure out which trigger should I use?
I was thinking of SystemTrigger::userPresent and SystemTrigger::userNotPresent (to show a different lighting effects on my keyboard depending on whether the user is present or not).
The only thing different between the two modes if when the user is present, I will take in the keyboard states and read some user specific settings.
I am writing an C++ Application and have to read if an arrow key is pressed or not.
I only found some function that are only working on Windows.
You have such problem because you just ask the wrong question. If you application is a command line tool and is accessible from a terminal, than it's just impossible to know which keys are pressed at the moment because the terminal can be far away from the machine where your application runs and which is more important, there is no reason for terminal to send you the arrow key presses because terminal can use them for text navigation.
So you may search how to make the terminal to send you key presses. Not every terminal will support it, but, I think, most of modern terminals in modern OS do.
If you has a gui application that is for running locally and assuming that you control it from the keyboard that is plugged in. Than you should search for the documentation for your gui toolkit. (Qt, wxWidgets, raw xorg, windows API, etc.)
So there are just no native C++ solution for this problem because you question just has no sense in many situations.
So you can use some console library like ncurses or gui toolkit like Qt or search for a native solution in your particular situation, but don't expect this last way will work without any additional code on other machines.
Or just search for other libraries that can allow you to do it.
As you say you only found material for Windows, I assume you are looking for a Linux-Unix way. Old dinosaurs like me remember the time when we only had true consoles (only a keyboard and a 80x25 display). And in these early times existed low-level libraries to interpret keypad transmitted keys and position cursor on screen on almost any terminal, and higher level ones to use the screen as a (text only) GUI.
You should look for curses or ncurses for high level libraries, and terminfo for the low-level capabilities.
Several console based applications like vim or lynx offer a rich user interface which enables the user to navigate freely around the console, manipulate data directly on screen, access menus and much more, similar to "modern" gui applications.
How is that being achieved in principal on Unix/Linux with C++? Do you directly manipulate some kind of character buffer or is the screen constantly cleared and reprinted to stdout?
Is there a set of libraries to implement such behavior or even some kind of a "modern" event-driven GUI toolkit for the console?
The ncurses library.