Windows OS is full of windows, even objects inside windows as we know them are also windows. Each window has a handle that is a pointer to the memory in which information about the window is stored.
Questions tagged [window-handles]
252 questions
76
votes
5 answers
Check if any alert exists using selenium with python
I'm trying to write a test with selenium in python language for a web page that manages users. In this page someone can add role for users and if a role exists while adding it, an alert raises. I don't know if the alert is a javascript alert or an…

Zeinab Abbasimazar
- 9,835
- 23
- 82
- 131
72
votes
10 answers
Winforms issue - Error creating window handle
We are seeing this error in a Winform application. Can anyone help on why you would see this error, and more importantly how to fix it or avoid it from happening.
System.ComponentModel.Win32Exception: Error creating window handle.
at…

leora
- 188,729
- 360
- 878
- 1,366
54
votes
7 answers
How do I get the handle of a console application's window
Can someone tell me how to get the handle of a Windows console application in C#? In a Windows Forms application, I would normally try this.Handle.

Grant
- 11,138
- 32
- 94
- 140
23
votes
3 answers
Mac OS X: Can one process render to another process's window?
Greetings!
I'm currently porting a web browser plugin from Win32 to MacOSX. One of the features of the plugin is that when the plugin is loaded, it spawns a separate process that serves as the "engine" of the plugin and executes drawing operations…

fixermark
- 1,261
- 1
- 14
- 19
16
votes
3 answers
C# Process.MainWindowHandle always returns IntPtr Zero
this is my code:
using (Process game = Process.Start(new ProcessStartInfo() {
FileName="DatabaseCheck.exe",
RedirectStandardOutput = true,
CreateNoWindow = true,
UseShellExecute = false }))
{
…

Kfir Eichenblat
- 449
- 2
- 8
- 27
15
votes
1 answer
WinForms main window handle
In my winforms application I am trying to get a main window handle, so I can set it as parent to my wpf modal window. I am not too experienced with winforms, so after a bit of googling I found two ways to get it.…

Nikita B
- 3,303
- 1
- 23
- 41
15
votes
3 answers
How to convert IntPtr to int
A window handle sometimes of type int and other times of type IntPtr
int example:
[DllImport("user32.dll")]
static extern uint GetWindowThreadProcessId(int hWnd, int ProcessId);
IntPtr example:
[DllImport("user32.dll", CharSet =…

E Mett
- 2,272
- 3
- 18
- 37
14
votes
4 answers
C# window positioning
Using Windows Forms I wanted to position window into specific coords. I thought it can be done in a simple way, but following code does not work at all:
public Form1()
{
InitializeComponent();
this.Top = 0;
this.Left = 0;
}
However,…

Fremen
- 141
- 1
- 1
- 5
13
votes
3 answers
Get all window handles for a process
Using Microsoft Spy++, I can see that the following windows that belong to a process:
Process XYZ window handles, displayed in tree form just like Spy++ gives me:
A
B
C
D
E
F
G
H
I
J
K
I can get the process, and the…

Jeremy
- 44,950
- 68
- 206
- 332
11
votes
4 answers
C# get window handle after starting a process
Is there a way to get the window handle (IntPtr) for a window after its launched from a C# app with Process.Start()?

James Cadd
- 12,136
- 30
- 85
- 134
10
votes
4 answers
Why using IntPtr for handle?
When using PInvoke, I noticed that we need to use IntPtr to refer to Windows handles. I am wondering why not just use int for the handle? My understanding of a handle is that it is just an integer value.

user705414
- 20,472
- 39
- 112
- 155
10
votes
3 answers
Python Selenium take screenshots and Save as PDF for windows opened with document.write()
I'm using Selenium with Python (in Jupyter notebook). I have a number of tabs open, say 5 tabs (with all elements already finished loading) and I would like to cycle through them and do 2 things:
Take a screenshot,
(As a bonus) Print each to PDF…

fortuneRice
- 4,214
- 11
- 43
- 58
8
votes
5 answers
Are window handles (HWND) unique, or do they ever get reused?
I am thinking if there are handles of the same value ?
To clarify my question, let's say I open Notepad, type in some text, save it and then close Notepad. If I repeat this a thousand times (or even more), will I ever have a chance to see the same…

Aussay Marshal
- 157
- 2
- 10
8
votes
4 answers
Get window handle from window class name
I'm trying to get a window handle on a child window in my process and the only information I have is the window class name. Are there any win32 functions I can use for that? I'm doing this from C#.
A bit more detail: This is a Visual Studio plugin,…

Einar Egilsson
- 3,438
- 9
- 36
- 47
8
votes
1 answer
how do I close window with handle using win32gui in Python
I have obtained the handle of a window I want to target, with win32gui library in Python
How do I close the window?
I have the following code, the second line did what I intended to do
but the last line seems to be wrong.
handle =…

vikingshore
- 165
- 1
- 2
- 6