I'm trying to do some P/Invoke stuff and need the handle of the current window.
I found Getting the handle of window in C#
But it appears that only works in WPF. Is there a winForms equivalent?
However, you can obtain the window handle by calling FindWindow() . This function retrieves a window handle based on a class name or window name. Call GetConsoleTitle() to determine the current console title. Then supply the current console title to FindWindow() .
The proper way, in my humble opinion, is handle=FindWindowW(NULL, L"Calculator"); (using UNICODE) or handle=FindWindowA(NULL, "Calculator");(using ANSI). Even better, use instead FindWindow macro to avoid know what character set is used in the project, so make your code "agnostic" to character set.
A window handle is a short length of material that attaches to a window in order to aid rotation of the hinge and therefore opening and closing of the window.
Once the Selenium WebDriver instance is instantiated, a unique alphanumeric id is assigned to the window. This is called window handle and is used to identify browser windows. Since the id is unique, it is used by the Selenium WebDriver to switch between different windows (or tabs).
Control.Handle
An
IntPtr
that contains the window handle (HWND) of the control.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With