Jump to content
Sign in to follow this  
picea892

Get current window class

Recommended Posts

picea892

I think this may have a short answer but can't seem to land on it. How to you get the current window's class?

WinGetClassList doesn't work. What I want to do, is get the class of the active window and then close all windows of that class. The below works, but I think is sloppy, there has to be a better way.

Thanks in advance for help with this simple question.

func closegroup()

If WinActive("[CLASS:ExploreWClass]") Then $classed="[CLASS:ExploreWClass]"

If WinActive("[CLASS:CabinetWClass]") Then $classed="[CLASS:CabinetWClass]"

If WinActive("[CLASS:AcrobatSDIWindow]") Then $classed="[CLASS:AcrobatSDIWindow]"

If WinActive("[CLASS:IEFrame]") Then $classed="[CLASS:IEFrame]"

If WinActive("[CLASS:XLMAIN]") Then $classed="[CLASS:XLMAIN]"

local $var = WinList($classed)

For $i = 0 to $var[0][0]

WinClose($classed, "")

sleep(400)

Next

EndFunc

This could end up being a really long list and even then you will miss some.

Share this post


Link to post
Share on other sites
Josbe

I think this may have a short answer but can't seem to land on it. How to you get the current window's class?

WinGetClassList doesn't work. What I want to do, is get the class of the active window and then close all windows of that class. The below works, but I think is sloppy, there has to be a better way.

Thanks in advance for help with this simple question.

func closegroup()

If WinActive("[CLASS:ExploreWClass]") Then $classed="[CLASS:ExploreWClass]"

If WinActive("[CLASS:CabinetWClass]") Then $classed="[CLASS:CabinetWClass]"

If WinActive("[CLASS:AcrobatSDIWindow]") Then $classed="[CLASS:AcrobatSDIWindow]"

If WinActive("[CLASS:IEFrame]") Then $classed="[CLASS:IEFrame]"

If WinActive("[CLASS:XLMAIN]") Then $classed="[CLASS:XLMAIN]"

local $var = WinList($classed)

For $i = 0 to $var[0][0]

WinClose($classed, "")

sleep(400)

Next

EndFunc

This could end up being a really long list and even then you will miss some.

Another way could be:

#include <WinAPI.au3>

$hwnd= WinGetHandle("[active]")
MsgBox(4096, "Get ClassName", "ClassName of " & $hwnd & ": " & _WinAPI_GetClassName($hwnd))

Share this post


Link to post
Share on other sites
picea892

Thanks for the fast replies! I knew there was a simple solution but couldn't find it. The below is my final script

func closegroup()

$hwnd= WinGetHandle("[active]")

$classed = _WinAPI_GetClassName($hwnd)

local $var = WinList("[CLASS:"&$classed&"]")

For $i = 0 to $var[0][0]

WinClose("[CLASS:"&$classed&"]", "")

sleep(400)

Next

EndFunc

Share this post


Link to post
Share on other sites
PPCC

Sorry I make comment here late.

Just tell who haven't known.

I've just known the available tool to define class of windows, button and other properties. It's Au3Info, default as "C:Program FilesAutoIt3Au3Info.exe"

Drag and drop Finder Tool into object we need to know, we will have the answer.

Posted Image

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.