Jump to content
Sign in to follow this  
Fantast

How to get a control text in the active window?

Recommended Posts

Sorry, I have read the help, but can't find an answer.

ControlGetText ( "title", "text", controlID )

But the controlID changed everytime my window is opened.

ClassNameNN of the control is the same one, so I want to know how to get text of such control?

And here is my problem:

I want to set this text as a condition to choose what will be sent to the window.

$text = ControlGetText("windowtitle", "", controlID )

If $text = A

    Send("!1")

ElseIf $text = B

    Send("!2")

Else

    Send("!3")

EndIf

How can I do this?

Edited by Fantast

Share this post


Link to post
Share on other sites

You can also do ControlGetText ( "title", "text", "ClassNameNN" ). It allows that.

Example:

WinWaitActive("Untitled - Notepad")
MsgBox(0, ControlCommand("Untitled - Notepad", "", "Edit1", "GetLineCount", ""), "", 1)

This will return the number of lines in an untitled notpad window. ClassNameNN is used rather than ControlID.

Hope that helps!

Share this post


Link to post
Share on other sites

It doesn't work in my window.

But it do work in notepad:

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("^o")
WinWaitActive("Open")
MsgBox(0,"", ControlGetText("Open", "", "Button2"))

I don't know why.

Anyway, thanks.

Share this post


Link to post
Share on other sites

Likely the window you are using does not use Windows controls:

Note: AutoIt only works with standard Microsoft controls - some applications write their own custom controls which may look like a standard MS control but may resist automation. Experiment!

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...