Jump to content

ControlGetText


shyron
 Share

Recommended Posts

Hi, i want to get the XXX

ControLGetText("Window Name" , "XXX",'static11')

like $text = "XXX"

But it always says me your Variable is undeclared etc.

Welcome to th eAutoIt Forums :)

I'm not sure what you mean, but perhaps you need

$text = WinGetText("WIndow Title")

If not you need to explain a bit more.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Hi, i want to get the XXX

ControLGetText("Window Name" , "XXX",'static11')

like $text = "XXX"

But it always says me your Variable is undeclared etc.

The second parameter is window text to use if more than one window titles match the first parameter. It is part of the window ID, nothing to do with the control. If you want to specify it with a variable, then you need to declare it and give it a value before using it:
$sTitle = "Window Name"
$sText = "XXX"
$sContText = ControLGetText($sTitle, $sText, 'static11')
MsgBox(64, "Result", "Control text = " & $sContText)

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Shyron..

You don't want to display $sText.. u want to display $sContent

see, if I understand correctly what u get from WinGetText is what u want to display in msgbox..

So first put it in a variable.. $sContent

And then use that variable in ur msgbox..

LIke this:

$sContText = ControLGetText($sTitle, "", 'static11')
MsgBox(64, "Result", "Control text = " & $sContText)

$Title is the name of ur window.. which u can get from Autoit window info tool..

[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com
Link to comment
Share on other sites

I want to display $sText in a msgBox, when i do it your way Psalty, ill get XXX in the msgBox, because at the start i said its XXX :)

That's not true. My code displays $sContText, not $sText, in the MsgBox(). Once again, $sText is window text, not control text, used help identifying the window. It is optional and can be left empty if the title is enough to ID the window:
$sTitle = "Window Name"
$sText = ""
$sContText = ControLGetText($sTitle, $sText, 'static11')
MsgBox(64, "Result", "Control text = " & $sContText)

Note again that what gets displayed in the MsgBox() is $sContText which was retrieved from the control.

but why is it empty?

look i made a screenshot

You can see that there is "connected" not nothing

The control in your screen shot is Static9 vice Static11, but that is an easy adjustment to make:
$sTitle = "Window Name"
$sText = ""
$sContText = ControLGetText($sTitle, $sText, 'static9')
MsgBox(64, "Result", "Control text = " & $sContText)

The text "Connected" should be read into $sContText and displayed by the MsgBox() if the window title matches. If the window title did not match, or matched a different instance with the same title, then you get nothing back.

Some error checking will help detect that:

$sTitle = "Window Name"
$sText = ""
If WinExists($sTitle, $sText) Then
    $sContText = ControLGetText($sTitle, $sText, 'static9')
    If @error = 0 Then 
        MsgBox(64, "Result", "Control text = " & $sContText)
    Else
        MsgBox(16, "Error", "Failed to get control text.")
    EndIf
Else
    MsgBox(16, "Error", "Did not match window.")
EndIf

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...