views:

425

answers:

2

Writing some test scripts in IronPython, I want to verify whether a window is displayed or not. I have the pid of the main app's process, and want to get a list of window titles that are related to the pid.

I was trying to avoid using win32api calls, such as FindWindowEx, since (to my knowledge) you cannot access win32api directly from IronPython. Is there a way to do this using built-in .net classes? Most of the stuff I have come across recommends using win32api, such as below.

.NET (C#): Getting child windows when you only have a process handle or PID?

UPDATE: I found a work-around to what I was trying to do. Answer below.

A: 

It's like asking if you can swim without going in to the water. If you need information from windows, the only option is to use the win32api. There are lots of examples to find on how to do so.

If you don't like this answer, just leave a comment in your question and I will remove this answer, so your question will remain in the unanswered questions list.

Frans
+2  A: 

The article below shows how to access the win32api indirectly from IronPython. It uses CSharpCodeProvider CompileAssemblyFromSource method to compile an assembly in memory from the supplied C# source code string. IronPython can then import the assembly.

Dynamically compiling C# from IronPython

Tom E