I want to set the "topmost" attribute for iup.Alarm and iup.message dialogs.
According to people on one of the iup forums, iup.Alarm and iup.Message cannot be set to the topmost window.
Related
In Windows 10 there are several menus/panels that can be opened from the task bar, such as "action center" and "volume panel" etc. Those windows are not enumerated if I try to use EnumWindows(), I found a workaround -- instead of using EnumWindows(), I used FinWindowEx(), and now I'm able to enumerate those panels and other Metro UI specific menus.
The only problem is that I cannot identify whether they are visible or not. If I try to call IsWindowVisible() and pass "action center" HWND as an argument, the function always returns TRUE. The same result I've got for other Metro UI panels (battery usage panel, volume panel, search panel and so on).
I've just found a solution. As there has been no answers so far, I would consider it as a best solution (at the moment I don't know other ways to solve the issue).
So basically in order to identify whether the window is visible, I call DwmGetWindowAttribute() function (in addition to IsWindowVisible()) passing DWMA_CLOAKED as the 2nd argument. This attribute is set to 0 when those Windows 10 specific panels are visible on the screen.
I know about the option for system menu, that is the alt+space one. And it's not pretty it involves looping all open windows through GetNextWindow. But I want to ask in more general way. That is having any menu handle, not necessarily to system menu (that is easy to find for any window) is it possible to get to its parent window ?
In the particular case when hmenu obtained on the fly from an existing menu-window (class #32768):
you can use GUITHREADINFO.hwndMenuOwner via GetGUIThreadInfo(GetWindowThreadProcessId).
"On the fly" means: via SendMessageTimeout(MN_GETHMENU) or via GetMenuBarInfo(OBJID_CLIENT), after WindowFromPoint.
No. Menus can be shared across windows, so there's no unique mapping from menus to windows.
To modify a window of another program, I need to find a specific SysTreeView32 in it using EnumChildWindows API call.
When I inspect the window using Spy++, there are a number of SysTreeView32's in it but all are greyed out except one, which is the one I'm looking for.
The following picture is an example of grey items:
Why are the shown items gray and what API call does Spy++ use to know whether it should grey out an item or not?
Those are just non-visible windows - ie HWNDs that don't have the WS_VISIBLE style bit set. They are often worker windows - windows that just exist to process various messages in the background - or in some cases are UI that's yet to become visible. For example, a window that lets you hide or show a toolbar may just hide it by making it invisible rather than destroying it and recreating it later.
In your specific case, the WorkerW could be a placeholder for some other piece of UI that's not needed right now, while the msctl_statusbar32 looks like it's a hidden status bar.
I've got some code that grabs the TaskBar buttons and their text from the windows TaskBar using User32.SendMessage with the TB_GETBUTTON message to retrieve a TBBUTTON structure (Win32 API via C# P/Invokes). But I'm trying to figure out how to then, once I have the handle to the button, grab the associated context menu text. There is some status information on there for a specific application that I would like to retrieve. The button text gets me some of it, but I need to the context menu text to complete it.
Any ideas?
This is not completely clear... Context menus don't have text, as such - they have menu items, each one of which will have text. By "context menu text", do you mean the text of the menu items in the taskbar button's popup/context menu? For example, "Restore", "Minimize" etc in the screenshot below?
If so, I suspect you're going about this the wrong way:
This menu doesn't belong to the button, but is the system menu of the window represented by the taskbar button. If the button has a context menu, this is probably for a grouped collection of windows, not one specific window (or even windows for one process.)
Making judgements based on the context menu of a window sounds like a dodgy approach to me, especially based on text since that will change depending on where in the world your user is located. Applications can also change the contents of this menu so there's no guarantee it will contain something you expect to be there. It would be better to check the window style, if it's minimized, etc, to find out the information that also affects the contents of the menu.
I'm going to answer this based on what your needs seem to be from the question, not what you've directly asked, since (a) it's not possible as asked and (b) I think you're trying to do something else. (As a general guideline, in a question it's good to state why you're trying to do something - and even maybe ask about that, ie 'how do I achieve X' - in case there's a better method than the one you're using. Here, X is probably 'find out information about this window' not 'get the text of the context menu', because that's probably only one possible method to get to X.) Also I think extracting data from the internals of a third-party application like Explorer (the taskbar is an Explorer window) is fragile and prone to break in future versions of Windows.
The system menu or window information (whichever one) belongs to application windows. Unless taskbar buttons are grouped (and then it's the subitems) one taskbar button corresponds to one specific window in the system. So what you want to do is find these windows. You do this by:
Using the EnumWindows function
Then for each window that is passed to the callback, checking the extended window style using GetWindowLong with GWL_EXSTYLE to see if the WS_EX_APPWINDOW bit is set
In addition, sometimes other windows are shown: these heuristics should help.
Each one of these windows is a window that should appear on the taskbar, Alt-Tab dialog, etc.
You say you're getting the text of the taskbar button - this is probably the window caption of the window, and GetWindowText is the canonical (read: probably a lot more reliable) way to get the caption of a window belonging to another process.
If you really want the popup menu, then:
Use GetSystemMenu to retrieve the handle for the system menu for the window. Applications can customise this, so if your app is doing this (and that's why you want the popup menu) ensure you pass false to the bRevert parameter
You can then get the number of menu items using GetMenuItemCount and for each one call GetMenuItemInfo to get info about each menu item. Pass true to the fByPosition parameter to indicate you're accessing the menus by position (since you know the count, you're getting item 0, 1, 2... count-1).
This fills a MENUITEMINFO structure, which (I think, I haven't ever had to code this so I haven't tested) will tell you the text associated with an item via the dwTypeData field "if the MIIM_STRING flag is set in the fMask member".
If you really want information about the window status, you can get this information using methods like IsIconic to see if it's minimized, GetWindowLong again to get other information, etc. I'd suggest you ask another SO question about how to get whatever specific information about a window for details.
Hope that helps!
Using the accessibility API, I am drilling down through a series of elements and finding a specific AXUIElementRef I am interested in (all in an external application). How do I check if this element currently has keyboard focus? And if not, how do I set it?
Something similar to using AXUIElementSetAttributeValue to set the kAXMainAttribute to true (this works for a window - thanks Peter!).
PS - I have tried kAXFocusedAttribute, doesn't seem to do the job. Maybe it's read only?
PS - I have tried kAXFocusedAttribute, doesn't seem to do the job. Maybe it's read only?
Quite the opposite. Read the header:
Writable? Yes, for any focusable element. No in all other cases.
Make sure you've activated the application (by setting its kAXFrontmostAttribute to true) and made the window key (by setting its kAXFocusedAttribute to true) before you give a control in the window focus (by setting its kAXFocusedAttribute to true).