Properties of current active window

F

Frank Uray

Hi all

I need to get informations about the current active window.
For example:
When the user is in explorer, I need to get the currently
selected path/file, or when the user is in word, I need to know
the path of the opened document.

I have tried to using
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern int GetForegroundWindow();

[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern int GetWindowText(int hWnd, StringBuilder text, int
count);

But these functions dont have enough informations.

Thanks for any help.

Best regards
Frank Uray
 
I

Ignacio Machin ( .NET/ C# MVP )

Hi all

I need to get informations about the current active window.
For example:
When the user is in explorer, I need to get the currently
selected path/file, or when the user is in word, I need to know
the path of the opened document.

I have tried to using
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        static extern int GetForegroundWindow();

        [System.Runtime.InteropServices.DllImport("user32.dll")]
        static extern int GetWindowText(int hWnd, StringBuilder text, int
count);

But these functions dont have enough informations.

Thanks for any help.

Best regards
Frank Uray

Hi,

There is no way of knowing that, it's application dependent.
 
J

Jesse Houwing

Hello Frank,
Hi all

I need to get informations about the current active window.
For example:
When the user is in explorer, I need to get the currently
selected path/file, or when the user is in word, I need to know
the path of the opened document.
I have tried to using
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern int GetForegroundWindow();
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern int GetWindowText(int hWnd, StringBuilder text,
int
count);
But these functions dont have enough informations.

You need to query these applications very specifically and each will have
their own interface (or none) to do this. It is no easy task. And it is not
something you're going to succeed in without a large load of blood sweat
and tears.

Why do you need this, are there alternatives you might have?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top