How can I obtain the window "id" - unique number associated with a Win32 window?
Can I obtain the id within a NSIS script(.nsi file)? If not what outside program can I use? ResHacker is not showing me the correct dialogs when I run my installer for some reason. I've heard of GDISpy or something with a name similar to that.
What I am trying to do is change the z index of some windows within a MUI2 pages and to set checkboxes backgrounds to transparent within a custom page.
What your easiest method for finding out a windows unique id?
EDIT
Sorry I'm not familiar with the correct term is for what I am talking about. I am not talking about the HWND variable/handle I am talking about that windows unique window id thats an integer.
# In NSIS
GetDlgItem $R0 ${parentHWND} 1012 # the 1012 is what I am referring to as the window ID
The ids for a dialogs child controls can be found with a spy tool like Winspy++ (This tool displays it in hex so convert with calc.exe or prefix the number with 0x in the .nsi)
NSIS has two nested dialogs, the outer dialog hosts the next, back and cancel buttons. The inner dialog hosts the controls for the current page.
To get the handle to a button in the outer dialog:
GetDlgItem $1 $hwndparent 1
And for the inner dialog:
FindWindow $0 "#32770" "" $HWNDPARENT ;Find inner dialog first
GetDlgItem $1 $0 0x666
For a custom page, the id (and z-order) depends on the order you create the controls in...
Related
Currently there are several ways to get a ChildWindow handle; FindWindowEx (uses parent handle, plus window caption), GetWindow (uses parent handle, and Z-Order), and EnumChildWindows. None are satisfactory for my application.
Would like to use something like FindWindowEx, but this requires knowledge of the contents of the TextBox (caption) that's used by FindWindowsEx. This works if the TextBox contents is static, but in most cases the contents change and and would be unknown to the Application trying to find the TextBox handle.
Does anyone know of a Win32 API that would function like FindWindowEX, using the Parent Handle, but instead of the ChildWindow caption, looks for a user specified TAG property for the ChildWindow that would remain static?
The GetDlgItem function accepts the parent window handle and child item ID.
It is not limited to dialog boxes despite the name.
You can use the GetDlgItem function with any parent-child window pair, not just with dialog boxes.
I need to find the control's name to which its tooltip is linked.
I'm asking this because I need to control click within TeamCenter 10, but the control names keep changing just as you click on any of them. This makes it difficult to keep my code running smoothly when I need to repeat tasks.
If there is a better way of doing this (in Autohotkey), please let me know.
You can try this (Replace title of TeamCenter 10 with the exact title of the TeamCenter window as shown in Window Spy):
F1::
; Retrieve the control name for each control in a window:
WinGet, List, ControlList, title of TeamCenter 10
; Examine the individual control names one by one, using a parsing loop:
Loop, Parse, List, `n
{
If InStr(A_LoopField, "SWT_Window02") ; use only the part of the control name that is always shown in Window Spy
ControlClick, %A_LoopField%, title of TeamCenter 10
break
}
return
https://autohotkey.com/docs/commands/WinGet.htm#ControlList
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 want to change the color of the outer dialog window in NSIS. I have created pages using NSDialogs.
I recently change the size of this using
System::Call 'user32::SetWindowPos(i$hwndparent,i,i,i,i 629,i 400,i 0x16)'
IS there similar way of changing the border/title bar color of this outer dialog windows?
You can change the inner and outer dialogs with SetCtlColors:
Function myPageCreate
nsDialogs::Create 1018
Pop $0
SetCtlColors $hwndparent 000000 ccff00
SetCtlColors $0 000000 ff00cc
nsDialogs::Show
FunctionEnd
To change the non-client areas like titlebar and borders you need to use a 3rd-party plugin. I personally don't think this is a good idea but you can probably find several different NSIS skinning plugins if you want to force such things on your users...
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!