I need to give a Chrome window focus over all other running applications. Javascript's window.focus() only gives focus over other windows of the same browser.
When my Chrome extension executes:
chrome.windows.update(theWindowId, {focused: true});
I experience different behaviors on Mac versus Windows 7:
On a Mac, the intended window gains focus over all other running applications.
In Windows 7, the intended window gains focus only over other Chrome windows, but not over other running applications.
Does anyone know a way to reliably give the intended window focus over all applications on Windows?
Unfortunately, the chrome.windows.update() API is still very unreliable in how it handles window focus cross-platform. I've even noticed inconsistencies at various times in the same platform. A lot of this has to do with the varying security policies that different OSes use for window management, so there really isn't much that you can do about it in terms of how it functions for the end user who may or may not have applied the appropriate registry hack.
Related
I would like my Win32 application to be able to detect if a window is actually running in Dark Mode. I know about this answer, which suggests reading a registry key for the user setting. That's fine, and it works for me. But many applications do not honor that setting.
I would like to find out which appearance my actual window has. My program is a 3rd-party plugin that runs inside an application I do not control. Currently that host application does not support Dark Mode on Windows, but a new version could potentially start supporting it. I would like to allow my program to detect if it does. I would also like to continue to support older versions of the app, without having to resort to a manual list of versions that do or don't support Dark Mode.
For readers that know something about macOS APIs, I am hoping to find something similar to the effectiveAppearance property on macOS views.
Individual windows do not have light/dark modes, as far as the OS is concerned, so there is nothing you can query for that. A window doesn't report back to the OS whether or not it is honoring the user's display setting. If it honors the user's setting, it simply draws its UI using appropriate colorings as it deems fit. If it don't honor the user's setting, it simply draws itself using whatever normal/custom colors it wants.
Context: our desktop application is used predominantly by users with significant access issues and therefore some of them use the Windows on screen keyboard. One bit of feedback we've had is that the software is awkward to use with the OSK as too many important bits of the UI get covered up. If we could detect the presence of the keyboard we could adapt the UI to some extent.
Therefore is it possible in code to detect that the Windows in-built OSK is open? And is it possible in code to detect the location of the keyboard?
The application is in WinForms and usually runs on full desktops/laptops - not smaller touchscreen machines.
This library does exactly what I am talking about on Linux systems: http://ichi2.net/pyosd/
My knowledge of Win32 API is limited but it seems to me that unless you create a window and enter the win32 main loop, you cannot do it. Some Googling also confirmed that.
Even so, are they newer GUI frameworks or technologies that would make it happen on windows?
Thanks
You don't need no stinkin' GUI frameworks. You can either:
Draw directly on the desktop. Of course, this is not generally considered a good idea, since it's mucking around with the internals of another application. Drawing this way is also quite fragile because your changes are erased each time the desktop repaints itself.
Create a transparent, layered window that you draw onto, which will appear over the desktop. If you specify that this window should be a top-level window, you could also have it appear over all of the other windows on the desktop.
There is absolutely nothing that forces windows to be rectangular gray-colored boxes, and since each window provides a device context that you can draw into, you can let your imagination run wild.
I've only ever done server, web, and database programming, never any desktop programming. I now want to learn and have a small project I want to attempt, but am not sure which library/framework to use.
I'd like to create a small cross-platform app that runs in the system tray (and whatever the OSX equivalent is), and listens for changes to windows on the Desktop. Specifically:
Windows XP, Vista, 7, Gnome, KDE, OSX. BSD, Android, and/or iOS would be nice too but not required.
Listens for when any window gains focus, loses focus, is opened or closed, or if the window title changes (for example when switching tabs in a tabbed browser). Any other information it can scrape from the window would be useful as well.
Can store these events, preferably in an embedded database like SQLLite.
The lighter-weight the better.
Includes an options GUI accessible via a right-click menu from the system-tray icon.
Preferably FOSS, but if you know any non-FOSS please list too.
Is there a single library or framework that can do all that across multiple platforms? QT? Python? Java? Something else? TIA.
Almost any GUI framework can easily let you know when your own application gains or loses focus (or the other operations you mention). However, listening for these events for other arbitrary applications is definitely platform-specific and may or may not even be possible.
One framework for doing this on Windows is the CBT callback hook. See the question CBT Hook not working in Windows Vista for information about possible limitations on using this technique.
We have a Linux based system that does not use a Window manager. When we start certain applications (for instance Firefox) from a terminal window (e.g. Firefox &) we find that no matter what we do, we can't get the application to display full screen.
If we run xrandr, it shows the default resolution is 1280x1024, but when we try to maximize Firefox (by pressing F11) the application is only sized to 1203x650.
Another application that seems to have the same problem is the evince PDF reader.
Our application is not configured to run a window manager (and we don't want to add one), so I'm wondering if there is something else that we can do to get these applications to render full screen.
Thanks...
Although you don't want to use a window manager, you might need to use a window manager.
I haven't dug into the X server sources around this, so I can't definitively say X requires a window manager to run properly. But as somebody who writes X client code, and hacks the X server, on minimalist embedded devices with small screens, low CPU power and no GPU... let's just say, all the major players in that space use one, and have good reasons for it.
If you want to avoid chewing up a lot of disk space, RAM or CPU power doing window management, you should check out matchbox. It's a low-footprint window manager designed to meet those criteria, and it's what many folks in that minimalist embedded space are using. My employer uses it on cell phones, configured so that only one app at a time is visible to the user, and the foreground app takes up the whole screen with no window borders. But you can use it other ways, too - Nokia uses it for their Maemo-based network tablets.
You could use xwit(1) to forcibly resize and place the windows. But as as far as I know, X11 in itself does not have the concept of a "maximized" window; the very idea is only added by most window managers and/or applications (like Firefox).
Does passing the "-geometry=1280x1024+0+0" option to Firefox help?
Oh, also... if you don't explicitly set a window manager, you might be unexpectedly falling back to the default X11 window manager. If you're not absolutely positive there's no window manager, you should check into this possibility.