how to find type of GDI - winapi

i am beginner in win 32 api . i try use win 32 api for create an onscreen keyboard . I can give handle of window and components by click but how to realize type of these and i want set text only on text box and editable components
i try to use GetWindowInfo() and try use atomWindowType of window for realize type of that but this is not use full for this goal because this change on each restart of OS.
(click is handle of window)
WINDOWINFO pwi = new WINDOWINFO(); USER32INST.GetWindowInfo(click, pwi); if (pwi.atomWindowType != -15891) { setLastclick(click); } tnx

You are not going to be able to achieve what you desire, in full generality it is not realistically possible.
A window's type (or class) is essentially determined by its WndProc. You can use GetClassName and its ilk to help you identify some standard window classes, but as you have already discovered, most real-world apps will not use these standard classes.
So, although in theory, you could analyse the code behind the WndProc at runtime, in practice this is not remotely feasible.

Related

how to define window stacking order?

I'm trying to write my own window manager. One issue I faced is that I don't understand how to define in which order windows should be displayed. The only means I found is to use xcb_configure_window. But it looks very limited to me: it only allows either to rise the window on top of all, or put it to the very bottom (no notion of layers or something). What a limited functionality :(.
What I really would like to do is to define the window order and tell X about it. Or to define multiple layers of windows (e.g, normal, above all, below all). So I could rise (or lower) the window with respect to its layer. So windows from lower layers will not ever cover windows from upper layers.
So, is there any other library function to define the order of windows apart from xcb_configure_window? Or I need to live with it? That would mean I have to track the order of windows in my window manager.
Link to relevant XCB documentation: https://www.x.org/releases/X11R7.6/doc/libxcb/tutorial/index.html#winstack
X11 only gives you the absolute minimum. There are no layers or always-over or always-under windows. You implement all the fancy stuff yourself, typically in the window manager, which is what you are writing.
There is no raw protocol request to change the stacking order of windows at once. Xlib has a function XRestackWindows which does that, but it uses one configure request per window. The pseudocode is just
for each window in the list except the first
change the stacking order to be under the previous window
That's it. Nothing more fancy than that.
You do need to track the stacking order in your WM in order to implement layers, so that when a program tries to restack a top level window, you intercept the request and only restack it within its layer.
Another possible way to implement layers is to have several transparent full-screen windows and reparent users' top-level windows to those, instead of to the root window. I'm not totally sure it will always work though, and you need to deal with transparency in one way or another, which requires transparency supporting hardware or the composite extension or possibly both.
It is the responsibility of the window manager to order the windows. A window gives hints about which type it is (popup dialog, menu window, splashscreen, toolbox, etc), the window manager then decides how to display this on the screen. This includes keeping track of the order and deciding which gets priority.
There is a X11 call to change the order (XRestackWindows), but I don't know the Xcb equivalent.

Interact with Windows windows programmatically

I wonder if there is any way to somehow interact with windows that are currently open on a Windows system. I am interested in getting some of their properties, namely:
Location
Dimension
is in background?
possibly window title
Preferably, I would like to do that in Java but any suggestions are welcome.
A comment by theB linked to good resources for Java. I'll run through the relevant Windows APIs, in case you want to go native with C++.
To enumerate all the top-level windows in the system, use EnumWindows. You give it a callback function with the signature of EnumWindowsProc, so it will receive each window handle as the first parameter.
You can get the window location (in screen coordinates) and dimensions with the GetWindowRect function. Pass in the window handle you received and get an LPRECT (pointer to RECT) out.
To determine whether a window is maximized, use GetWindowPlacement and check the showCmd field of the WINDOWPLACEMENT structure you receive.
Finally, to get a window's caption, use GetWindowText. (As an aside, if you want to get the text of a control in another process, you'll need to send the WM_GETTEXT message yourself.)

Using WinApi invocation to set mask property masked text control from another program

I'm trying to change the mask property in editMask control in vb6 with another program using WinApi function or message and can't find a message that do it.
what WinApi message is used when the mask is set?
Thank you
What Winapi message is used when the mask is set?
A masked edit is not a Windows control. Windows EDIT controls do not offer mask functionality. If you are going to influence this from outside you will first need to know exactly what this control is. After that, it's likely that you would need to inject into the target application in order to make the change. That is, assuming that the target application does not support enough automation to avoid such egregious hacking.

Create a program that alters the execution of a windows application

I have a windows application which has several sub-forms. i have to navigate through 5 or 6 forms to reach the form i need. this is time consuming since i have to open it several times through the day and i do it daily.
my need: i dont have the source project for this application, i got it as an executable program, but i need to create some application that does these steps for me automatically. In other words i need to find a way to automatically click the buttons that navigate through the forms and opens the form i need from step one.
is there any way i can do this ?
There is indeed, though generic solutions already exist to perform just this kind of function to arbitrary programs.
You can use Spy++ or a resource-editor, like ResHack or ResEdit to look at the program and get the control ids of the navigation buttons.
Once done, you can get a handle to the program itself and then send messages to it's WindowProcedure that would be generated if the user clicked the controls with a mouse,
Another alternative, is to get the position of the running target application, after you've got it's HWND, by using the GetWindowRect function. You could then use this position along with vert/horiz distances to generate mouse events.
The two have more-or-less the same result, though some applications won't work with approach #1.
In one instance, you need to use Spy++ to get the control IDs.
In the other instance, you need to use an image editor to get the pixel offsets of the controls.
In both instances, you'll need to use FindWindow, along with the window's title-text in order to get a HWND handle.
You could use a combination of the two - asking the program itself with GetDlgItem for the handle of the controls you need to click. You could then query the control for its position, before using mouse_event to position the mouse above it and again to click it.
Quite a few ways to skin this cat, actually.
Pre-existing solutions like AutoIt are said to be very easy to use and will be much easier than coding a new program for each target.

How can I produce an OSD in Windows?

I want to create an on-screen display, i.e. text or simple graphics that appear on top of everything else being displayed. I know in Linux this is achieved with xosd, but how do you do it in Windows? (Assume XP and up if it makes it easier, and I would also be interested in knowing if the method is different in Vista/7)
You can use NativeWindow to do this as described here.
The article explains how to create an
OSD window with
animation/semi-transparent effects, in
C#, using the NativeWindow class.
Use the WS_EX_LAYERED style to make the window transparent, and SetWindowPos(..., HWND_TOPMOST, ...) to make it float above other windows.
You can call SetForeGroundWindow

Resources