Jump to content

ControlGetText() Bug?


ChrisL
 Share

Recommended Posts

I have a control called Edit2 on an external GUI

I can use

ControlSetText("Frontier","","Edit2","12")

And change the text, but I can't read it ControlGetText("Frontier","","Edit2") and neither can AU3info, I assume Au3info uses the same procedure as Autoit. (is it written in autoit?)

For some reason it always returns blank even after I have just set the text.

Why would this be?

Link to comment
Share on other sites

Sorry Valuater but I don't think I'm using it wrong. It just wont read this specific Edit control. Neither will Au3info!

Chris... You know, I believe you are not a "newby" and recognize that you have not given enough info to help you

right????

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

There's more than one way to skin a cat

... as far as i can see, you are sending text to a control... so

Run("notepad.exe")

WinWaitActive("")

ControlSend("Untitled", "", "Edit1", "This is a line of text in the notepad window")

Sleep(2000)

Send("^a")

Sleep(1000)

$variable = ControlCommand("Untitled", "", "Edit1", "GetSelected", "")

MsgBox(0x0, "Test", $variable)

Sleep(5000)

; close notepad

... but, no more guessing for me!

8)

NEWHeader1.png

Link to comment
Share on other sites

If you see the attached screen shot, you will see the second control from the left has a number 12 in.

You will see that Au3info can not read this text. However with Autoit you can edit the text, you can enable disable the control but you just can not read it.

Manually I just highlighted the text and used Ctrl C to copy it to the clipboard and then Ctrl V to paste it in to notepad and that also returned a blank string, so I guess there is something strange about this control. What I don't understand is why, I thought that maybe it was an issue with Autoit's controlGetText() but maybe not hey.

The actual code line was

$sort = ControlGetText("Frontier","","Edit2")
Msgbox(0,"Debug",$sort)
If $sort <> "0" then Return
Link to comment
Share on other sites

If anyone is interested this is how I got round this issue..

First I found the control position and size.

Then I checked the colour of the 4th pixel in and the 4th pixel down and recorded it in $startPixel because it knew it was blank

Then i checked each pixel in each row of the size of the edit control, if it matched the $startPixel I recorded it as 0 if it didn't match I recorded it as 1 (I had to run this function first to get my $ZeroSort Value when writing the function)

Once I have checked all of the pixels and created a new string of 0's and 1's in $pixelString I then compare this to my known value of what the edit box looks like when it only contains a Zero and this way I know that it a Zero in the box or something else.

Luckily I only need to know if it is 0 or something else. I'd still like to know why I can't just read it normally though :)

Func _CheckZeroSortSP3000()
    $ZeroSort = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

0000000000011100000000000000000000000000000000001000100000000000000000000000000000000010001000000000

0000000000000000000000001000100000000000000000000000000000000010001000000000000000000000000000000000

1000100000000000000000000000000000000010001000000000000000000000000000000000100010000000000000000000

00000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000"
    $pos = ControlGetPos("Frontier","","Edit2")
    If IsArray($pos) then 
    $pixelString = ""
    $startPixel = PixelGetColor($pos[0]+3,$pos[1]+3)
;ConsoleWrite($startPixel & @CRLF)
    For $i = 4 to $Pos[3]-3
        For $j = 4 to $pos[2]-3
            $pixel = PixelGetColor($pos[0] + $j, $pos[1] +$i)
            If $pixel = $startPixel then 
                $pixelString &=0
            Else
                $pixelString &=1
            EndIf
            
            ConsoleWrite($pixel & @crlf)
        Next
    Next
ConsoleWrite($pixelString)
    If $PixelString <> $ZeroSort then Return 1;Means that the sort is not zero
    EndIf
    Return 0;Sort is zero
Endfunc
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...