How do I know if a dialog box is a warning or confirmation or prompt using the VB.Net Winform application?

I can get the Window handle using "GetForegroundWindow" from "user32.dll" and by matching its class name with "# 32770", I can verify that it is a dialog.

Now my question is, how do I know if this is a dialog box and it warns, confirms or requests a dialog?

Please note that I am working outside the Internet Explorer process using VB.Net.

+5
source share
2 answers

There are many possible dialogs. MessageBox and shell dialogs such as OpenFileDialog, PrintDialog, ColorDialog, etc. are standard. Many non-standard ones, such that a programmer who uses his own code to write a Windows program, are created using the resource editor. Displayed by winapi DialogBox () function.

You will need to learn more about the dialog box, use the Spy ++ utility . If this is a general dialog, you will see that each control in the window has an identifier. You find them back at runtime by calling GetDlgItem (). EnumChildWindows () may be required if they are nested in another child window. If the function does not work, returns IntPtr.Zero, then you know that you do not have the dialog box you need. You also need pinvoke GetClassName () to verify that this is the type of control you are hoping to find.

Remember that it can never be 100% accurate; programmers tend to choose identifiers that are very common. How simple it is to number them sequentially, starting with 1. Doing this at the right time, when it is very likely that a particular dialog box is shown, is very important.

And be careful that Microsoft can easily break your code. They do not promise to keep the dialogs in the next version of Internet Explorer.

And be careful, but not least, that programmers are usually interested in this because they want to bother with a hint to confirm the download of the file. Recalling the path name and pressing the OK button automatically. Of course, a very attractive target for malware, they built countermeasures to defeat this easy target. Advanced Protected Mode, included in later versions of IE, is another counter measure that will give you a throbbing headache.

+3
source

You can list window elements with EnumChildWindow and count buttons, and which buttons to open, and also check the icon. There are 6 button configurations and 9 different icons if this is a standard mailbox.

0
source

Source: https://habr.com/ru/post/1202050/


All Articles