Jump to content

[SOLVED] Accessing a list view in another app, odd behavior (accessing 32-bit apps from 64-bit code)


Vadtec
 Share

Recommended Posts

Greetings all.

I am trying to extract some information from a call agent application, specifically from Cisco. The information is presented in a SysListView32 list view. When I run the AI window info tool, i see the following:

>>>> Window <<<<
Title: Not Ready - Cisco Agent Desktop
Class: AGENT_DESKTOP
Position: 250, 114
Size: 1017, 425
Style: 0x14CF4000
ExStyle: 0x00000100
Handle: 0x00000000000B0A44

>>>> Control <<<<
Class: SysListView32
Instance: 3
ClassnameNN: SysListView323
Name:
Advanced (Class): [CLASS:SysListView32; INSTANCE:3]
ID: 59649
Text:
Position: 261, 37
Size: 736, 327
ControlClick Coords: 260, 182
Style: 0x50008001
ExStyle: 0x00000000
Handle: 0x0000000000030CBA
>>>> Mouse <<<<
Position: 521, 219
Cursor ID: 0
Color: 0xFFFFFF

>>>> StatusBar <<<<
1: User
2: x1234
3: User
4: Not Ready  00:10:49
5:
6: In Service
7: 15:31
8:
9:
>>>> ToolsBar <<<<

>>>> Visible Text <<<<
xtpBarTop
Miscellaneous
ACD
Call Control
xtpBarBottom
xtpBarLeft
xtpBarRight

>>>> Hidden Text <<<<
Scrolling text here

I am using the following code:

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>

$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()
    Local $lvhandle = ControlGetHandle("[CLASS:AGENT_DESKTOP]", "", "SysListView323")
    ConsoleWrite("Handle: " & $lvhandle & @CRLF)

    Local $colcount = _GUICtrlListView_GetColumnCount($lvhandle)
    ConsoleWrite("Columns: " & $colcount & @CRLF)

    Local $itemcount = _GUICtrlListView_GetItemCount($lvhandle)
    ConsoleWrite("Items: " & $itemcount & @CRLF)

    Local $i = 0
    Local $item
    Local $items

    While $i < $itemcount
        $item = _GUICtrlListView_GetItemTextString($lvhandle, $i)
        ConsoleWrite("Item " & $i + 1 & ": [" & $item & "]" & @CRLF)
        $items = StringSplit($item, "|")
        For $r In $items
            If IsString($r) Then
                ConsoleWrite(@TAB & ": [" & $r & "]" & @CRLF)
            EndIf
        Next
        $i += 1
    WEnd
EndFunc   ;==>_Main

When I run the above code, I see the following output:

Handle: 0x00030CBA
Columns: 4
Items: 4
Item 1: [1234|Route Point|Route Point 1234|00:00:02]
    : [1234]
    : [Route Point]
    : [Route Point 1234]
    : [00:00:02]
Item 2: [4|CSQ|The_CSQ|00:00:00]
    : [4]
    : [CSQ]
    : [The_CSQ]
    : [00:00:00]
Item 3: [12345|Agent ID|Tech Support|00:00:08]
    : [12345]
    : [Agent ID]
    : [Tech Support]
    : [00:00:08]
Item 4: [||Total|00:00:10]
    : []
    : []
    : [Total]
    : [00:00:10]

The problem I am having is this: the above code and output works just fine when run as it is. When I cut the code out from _Main() and put it into a function that is called when a button is clicked in my GUI (simple GUI with buttons for various actions), the code does not run. The GUI has the necessary includes and the call back function is being called normally.

I am using the following code for the GUI (minus the stuff that is not relevant, I get the same results either way):

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=new_ticket.exe
#AutoIt3Wrapper_Outfile_x64=new_ticket_x64.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_Fileversion=0.0.0.27
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Run_Obfuscator=y
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
Opt("MouseCoordMode", 0) ; Mouse relative to the current window
Global $title = "List View Tester"

; Create the GUI window
Local $mainwindow = GUICreate($title, 500, 250)
; Layout the GUI
Local $test = GUICtrlCreateButton("Test List View", 5, 5)

; Set GUI control events
GUICtrlSetOnEvent($test, "CLICKTest")
; Set GUI window options and events
GUISetOnEvent($GUI_EVENT_CLOSE, "PROGRAMExit")
GUISetState(@SW_SHOW)

; This is the "main loop" for the program
While 1
Sleep(1000)
WEnd
Func PROGRAMExit()
If @GUI_WinHandle = $mainwindow Then
  Exit
EndIf
EndFunc   ;==>PROGRAMExit

Func CLICKTest()
;~  WinActivate("[CLASS:AGENT_DESKTOP]")
$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work

Local $lvhandle = ControlGetHandle("[CLASS:AGENT_DESKTOP]", "", "SysListView323")
ConsoleWrite("Handle: " & $lvhandle & @CRLF)
Local $colcount = _GUICtrlListView_GetColumnCount($lvhandle)
ConsoleWrite("Columns: " & $colcount & @CRLF)

Local $itemcount = _GUICtrlListView_GetItemCount($lvhandle)
ConsoleWrite("Items: " & $itemcount & @CRLF)
Local $i = 0
Local $item
Local $items

While $i < $itemcount
  $item = _GUICtrlListView_GetItemTextString($lvhandle, $i)
  ConsoleWrite("Item " & $i + 1 & ": [" & $item & "]" & @CRLF)
  $items = StringSplit($item, "|")
  For $r In $items
   If IsString($r) Then
    ConsoleWrite(@TAB & ": [" & $r & "]" & @CRLF)
   EndIf
  Next
  $i += 1
WEnd
EndFunc   ;==>CLICKTest

When I run the above, I get the following:

Handle: 0x0000000000030CBA
Columns: 4
Items: 4
Item 1: [|||]
: []
: []
: []
: []
Item 2: [|||]
: []
: []
: []
: []
Item 3: [|||]
: []
: []
: []
: []
Item 4: [|||]
: []
: []
: []
: []

As you can see, when run from the GUI the code is seeing the correct number of columns in each row, but it is not getting any of the text from those rows.

Can anyone shed some light on why this works in a non-GUI but when run in a GUI it blows up? I've been searching the forums and haven't come up with anything useful at this point. Any help is greatly appreciated.

- Vadtec

Edited by Vadtec
Link to comment
Share on other sites

I think I just figured the issue out. I ran the 32-bit version of the app I'm building and was able to see the correct output from the program. When I ran the 64-bit version of the app, I could not see the output. Knowing that Windows isolates 32-bit and 64-bit programs from each other when using DLLs, and that the list view code is mostly DLL stuff, this makes sense.

When I changed

#AutoIt3Wrapper_UseX64=y

to

#AutoIt3Wrapper_UseX64=n

the un-compiled app ran just fine. Guess I get to use 32-bit only.

Maybe this post will help someone.

- Vadtec

Edited by Vadtec
Link to comment
Share on other sites

What version of AutoIt3 are you using? There was a bug in the versions prior to Beta 3.3.7.2 for the _GUICtrlListView_GetItemText when using x64 that might affect what you're doing.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

What version of AutoIt3 are you using? There was a bug in the versions prior to Beta 3.3.7.2 for the _GUICtrlListView_GetItemText when using x64 that might affect what you're doing.

According to the compile settings I'm using, 3.3.8.0, hope this helps.

- Vadtec

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...