Modify

Opened 11 years ago

Closed 11 years ago

Last modified 9 years ago

#2356 closed Bug (Works For Me)

ControlGetText return blank string, but Window Info tool work without fail

Reported by: anonymous Owned by:
Milestone: Component: AutoIt
Version: Other Severity: None
Keywords: Cc:

Description

ControlGetText and Window Info tool seems work differently and while second get result without fail, fist return blank string.

>>>> Control <<<<
Class: Static
Instance: 5
ClassnameNN: Static5
Name:
Advanced (Class): [CLASS:Static; INSTANCE:5]
ID: 1002
Text: ftp1-zlb.vips.scl3.mozilla.com, HTTP (TCP:80) <--------------- this string
Position: 196, 102
Size: 284, 24
ControlClick Coords: 60, 10
Style: 0x50024000
ExStyle: 0x00000004
Handle: 0x00C805F6

>>>> Visible Text <<<<
Static
Static
Static
Static
Static
Button
Button
Button
Button
ComboBox
Button
Button
Static
Button
Button
Static
SysLink

discussion can be seen here:
http://www.autoitscript.com/forum/topic/150535-getting-text-from-control-the-window-info-tool-way/?hl=controlgettext#entry1077799

script that reproduces the problem:

#include
#include
$a = WinList ( "Outpost Firewall Pro" )
For $i = 1 To $a[0][0]
Var_GetAllWindowsControls2($a[$i][1])
Next

Func Var_GetAllWindowsControls2($hCallersWindow)
; Get all list of controls
$sClassList = WinGetClassList($hCallersWindow)
; Create array
$aClassList = StringSplit($sClassList, @CRLF, 2)
; Sort array
_ArraySort($aClassList)
_ArrayDelete($aClassList, 0)
; Loop
$iCurrentClass = ""
$iCurrentCount = 1
$iTotalCounter = 1
For $i = 0 To UBound($aClassList) - 1
If $aClassList[$i] = $iCurrentClass Then
$iCurrentCount += 1
Else
$iCurrentClass = $aClassList[$i]
$iCurrentCount = 1
EndIf
$hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]")
;$text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl),"[\n\r]","[email="{@CRLF"]{@CRLF[/email]}")
$text = ControlGetText($hCallersWindow, "", $hControl)
$aPos = ControlGetPos($hCallersWindow, "", $hControl)
$sControlID = _WinAPI_GetDlgCtrlID($hControl)
If IsArray($aPos) Then
ConsoleWrite("ControlCounter=[" & $iTotalCounter & "] ControlID=[" & $sControlID & "] Handle=[" & $hControl & "] ClassNN=[" & $iCurrentClass & $iCurrentCount & "] XPos=[" & $aPos[0] & "] YPos=[" & $aPos[1] & "] Width=[" & $aPos[2] & "] Height=[" & $aPos[3] & "] Text=[" & $text & "]." & @CRLF)
Else
ConsoleWrite("ControlCounter=[" & $iTotalCounter & "] ControlID=[" & $sControlID & "] Handle=[" & $hControl & "] ClassNN=[" & $iCurrentClass & $iCurrentCount & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF)
EndIf
If Not WinExists($hCallersWindow) Then ExitLoop
$iTotalCounter+=1
Next
EndFunc

Attachments (0)

Change History (4)

comment:1 Changed 11 years ago by TicketCleanup

  • Version set to Other

Automatic ticket cleanup.

comment:2 Changed 11 years ago by Jon

  • Resolution set to Works For Me
  • Status changed from new to closed

ControlGetText() and Au3Info use the same engine in the next beta. If not resolved then reopen. But I will need an example script that I can use to repo.

comment:3 Changed 11 years ago by anonymous

While testing beta 11 run into some regress:

WinGetClassList($hWnd)

Help: Class names are linefeed (@LF) separated. - actually not.

#2356 it seems its not work for me (for outpost window)

#include <Array.au3>
$a = WinList("Outpost Firewall Pro")
#cs
$a :
[0]|2|
[1]|Outpost Firewall Pro|0x00190712 <<<<< this window
[2]|Outpost Firewall Pro 7.6|0x00010202
#ce

$hWnd = WinGetHandle("Outpost Firewall Pro")
ConsoleWrite("$hWnd = "&$hWnd&@CRLF)
ConsoleWrite("Title = "&WinGetTitle($hWnd)&@CRLF)


$hControl = ControlGetHandle($hWnd, "", "[CLASSNN:Static5]")
ConsoleWrite("$hControl by $hWnd = "&$hControl&@CRLF)

$hControl = ControlGetHandle("Outpost Firewall Pro", "", "[CLASS:Static; INSTANCE:5]")
ConsoleWrite("$hControl by Title = "&$hControl&@CRLF)

$text = ControlGetText($hWnd, "",$hControl)
$err = @error
ConsoleWrite("$text = "&$text&@CRLF)
ConsoleWrite("ControlGetText @error = "&$err&@CRLF)

#cs
>Running:(3.3.9.11):C:\Program Files (x86)\AutoIt3\beta\autoit3.exe "E:\Auto-it scripts\Test\test_17.au3"    
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
$hWnd = 0x00190712
Title = 
$hControl by $hWnd = 0x004306CE
$hControl by Title = 0x004306CE
$text = 
ControlGetText @error = 1
+>21:42:39 AutoIt3.exe ended.rc:0
>Exit code: 0    Time: 0.420
#ce

#cs
>>>> Window <<<<
Title:	E:\Auto-it scripts\Test\test_17.au3 - SciTE [27 of 27] <<< strange, its title of SciTE window behind Outpost window
Class:	#32770
Position:	165, 150
Size:	496, 630
Style:	0x14C008CC
ExStyle:	0x00010509
Handle:	0x00190712

>>>> Control <<<<
Class:	Static
Instance:	5
ClassnameNN:	Static5
Name:	
Advanced (Class):	[CLASS:Static; INSTANCE:5]
ID:	1002
Text:	ftp2-zlb.vips.scl3.mozilla.com, HTTP (TCP:80)
Position:	196, 102
Size:	284, 24
ControlClick Coords:	109, 14
Style:	0x50024000
ExStyle:	0x00000004
Handle:	0x004306CE
#ce

comment:4 Changed 9 years ago by ROSELLE DOUGHERTY

Helpful writing , With reference to which , if anybody requires to rearrange PDF or PNG files , I saw notice here http://goo.gl/LnvmUF

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.