Jump to content

IF ClassnameNN exists


copyright
 Share

Recommended Posts

is there a way to check if Class exists such as Edit1 within notepad? and how would i going about:

If Class = Exists Then

close that class or control right click then control click (close) on the popup menu. ?

Endif

i know that code wouldnt work but.. how would i do such a thing?

Link to comment
Share on other sites

See WinGetClassList in the docs. However, the function does not return the numbers of the classes; just the names.

The code in the following post (in a select case block...) contains a way to append the class number to the classname...

http://www.autoitscript.com/forum/index.ph...wtopic=3523&hl=

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

Actually, you can just do something like this:

$classes = WinGetClassList()
If StringInStr($classes, "Edit", 0, 1) Then
; Do whatever
EndIf

By using StringInStr()'s 4th parameter, occurence, you can determine if a specific control exists. This could present an issue if the control you search for is a sub-string of a different type of control, but that's not too likely.

Link to comment
Share on other sites

Actually, you can just do something like this:

$classes = WinGetClassList()
If StringInStr($classes, "Edit", 0, 1) Then
; Do whatever
EndIf
Hey Valik, would you care to write some GUI conversion scripts? Your text processing insights are a lot better than mine :ph34r:
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

From the manual conversions I've done so far, it shouldn't be that hard to write a converter. Most of the functions seem to have a 1:.75 conversion factor (The first parameter of GuiSetControl needs stripped when replaced with GuiCtrlCreateXXX). A couple other functions may not correspond directly, either, but shouldn't be much more than minor tweaks.

I've decide I'll just port my scripts by hand. I only have a half dozen GUI scripts, and only one of which is somewhat complicated. I know I'd spend more time in creating a converter than it would to just do a manual update.

About the example I posted, I actually used that in some test code I was using last week, so it was still somewhat fresh in my mind. Using something like that in a loop is a good way to be sure the controls you are interested in exist. .NET controls are created rather slowly; the window exists quite a long time (in computer terms) before all the controls are created, I had to have a way to wait until the specific control instances I wanted existed.

Link to comment
Share on other sites

there is one problem.. when it gets the classlisti noticed.. its not showing the true and full class name for that class.. such as:

TTntEdit.UnicodeClass

TTntEdit.UnicodeClass

TTntEdit.UnicodeClass

TTntEdit.UnicodeClass

as you notice there are four that are the same. actually there is a number after that and they should look like:

TTntEdit.UnicodeClass1

TTntEdit.UnicodeClass2

TTntEdit.UnicodeClass3

TTntEdit.UnicodeClass4

.. . please suggest, explain, or help me with this problem.. *thanks ahead of time*

Link to comment
Share on other sites

I think the problem is lack of comprehension. It is showing the true and full classname. The numbers are something AutoIt-specific. I digress...

  • CyberSlug already stated the numbers would not be returned in this thread.
  • My method searches to be sure that a specific numbered instance of a control exists. That means if you are interested in the 3rd control of that type, fix up the code I posted to look for the 3rd instance of the string in the class list. If it exists, then manually append a 3 onto the end of the control name and you're done.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...