Sign in to follow this  
Followers 0
fisofo

Get the Last Active Window

10 posts in this topic

I have a button on a gui that performs an action on a window IF it is the "next" active window. However, I seem to be having tons of trouble finding out what the last active window was... the window that was active before I clicked on my GUI.

any ideas on a way to do this efficiently?

Share this post


Link to post
Share on other sites



I have a button on a gui that performs an action on a window IF it is the "next" active window. However, I seem to be having tons of trouble finding out what the last active window was... the window that was active before I clicked on my GUI.

any ideas on a way to do this efficiently?

Well since you've provided no trial and error on your part, here's something for you to look at rather than me sitting down to figure it out myself.

http://www.autoitscript.com/forum/index.ph...t+active+window


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Well since you've provided no trial and error on your part, here's something for you to look at rather than me sitting down to figure it out myself.

http://www.autoitscript.com/forum/index.ph...t+active+window

well i feel like a moron... i guess i misspelled something in my hasty search cause i didn't get many good hits...

thanks.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Okay, I think i'm getting somewhere, but I have a general question on dll calls:

On this page, there's a description of the GetWindow function, and I figured out the dll call from someone else's post:

$Response = DLLCall("user32.dll", "HWnd", "GetWindow", "HWnd", $HWnd, "Int", 2)

What I want to know is, how do you figure out that the "Int" for GW_HWNDNEXT is 2?!? Everything else makes sense, but if I want to make my own dll calls, i really need to figure that part out :P

thanks.

Edited by fisofo

Share this post


Link to post
Share on other sites

If you know the preprocessor directive, search the MSDN for it. You should get a table of values somewhere including that value. If you have Visual C++ or Visual Studio, just make a new C++ project and type GW_HWNDNEXT, put your mouse over it, and see what it is defined as. I keep an extra project around called testing just to find values and test very small pieces of code.

Share this post


Link to post
Share on other sites

If you know the preprocessor directive, search the MSDN for it. You should get a table of values somewhere including that value. If you have Visual C++ or Visual Studio, just make a new C++ project and type GW_HWNDNEXT, put your mouse over it, and see what it is defined as. I keep an extra project around called testing just to find values and test very small pieces of code.

Sorry for my noobishness on this, but... "preprocessor directive" ??? Ya lost me on that one :P

I don't have either apps you listed, closest thing would be Visual Basic for office apps, but I know that won't have it.

I did do a search for GW_HWNDNEXT on msdn and I get a ton of hits, but it doesn't appear any of them have the table you mention... could you give me an example? Perhaps that would clear it up a bit for me.

thanks for the help.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

You can download Visual C++ 2005 Express for free, if you feel like learning or just messing around. At least, you can download if you have a valid Windows key.

Well, no I cannot find you an example table because I have always had to dig myself when trying to find things that I could not have Visual Studio find for me.

I found GW_HWNDNEXT in winuser.h which is a header file as part of the Windows platform SDK.

Edit: Preprocessor directives are C++ things that you write as

#define GW_HWNDNEXT 2

and then you can use GW_HWNDNEXT which is similar to a constant. The difference between a preprocessor directive and a constant is that the preprocessor will replace everywhere you put GW_HWNDNEXT with a 2 instead of having a static value wasting a couple bytes of RAM.

Edited by Mr Icekirby

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

You can download Visual C++ 2005 Express for free, if you feel like learning or just messing around. At least, you can download if you have a valid Windows key.

Well, no I cannot find you an example table because I have always had to dig myself when trying to find things that I could not have Visual Studio find for me.

I found GW_HWNDNEXT in winuser.h which is a header file as part of the Windows platform SDK. Do you dabble in C++?

it's valid, no worries there :P that may be the best option, thanks for the tip...

I took programming classes in college a few years back (C, Java, blah blah... wtf, scheme?!?) but never did C++ (CompEng degree). Header files are typically easy though, i just need to get access to it.

Anywho, I just saw This Link, so that will probably be my next step. Anything else that might be helpful to me?

thanks for the pointers!

edit: this could prove useful as well

Edited by fisofo

Share this post


Link to post
Share on other sites

I may be using old header files. I am still using Visual Studio 2002 for C++. I'm thinking of upgrading to 2005 soon though. I only downloaded C# 2005 so far.

"This Link" is for Windows Vista, which is not what you want yet, I don't think. The second link could be helpful to you, but some of us already have it.

Share this post


Link to post
Share on other sites

I may be using old header files. I am still using Visual Studio 2002 for C++. I'm thinking of upgrading to 2005 soon though. I only downloaded C# 2005 so far.

"This Link" is for Windows Vista, which is not what you want yet, I don't think. The second link could be helpful to you, but some of us already have it.

yup, you're right on that being vista, i'll have to find the old one...

anyway, sounds good. thanks again.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0