Jump to content

SyslistView32 and subitems


Recommended Posts

Hello AutoIt forums,

I have some problems with Syslistview32 and subitems and came here to ask for some help. I am trying to force some changes upon a very old software that uses Syslistview32 as default.

Using the "AutoIt Window Info" I recieve the following information from regarding the area I am interested in:

>>>> Window <<<<
Title:  Nanoscope - ibm.007
Class:  Afx:400000:8:10003:0:1039a
Position:   -4, -4
Size:   1374, 748
Style:  0x15CF8000
ExStyle:    0x00000110
Handle: 0x000103BE

>>>> Control <<<<
Class:  SysListView32
Instance:   1
ClassnameNN:    SysListView321
Name:   
Advanced (Class):   [CLASS:SysListView32; INSTANCE:1]
ID: 1636
Text:   List1
Position:   565, 116
Size:   407, 179
ControlClick Coords:    223, 170
Style:  0x50014645
ExStyle:    0x00000204
Handle: 0x00040568

Using this I have sucessfully been able to get information such as itemcounts and columncounts. I even managed to use _GUICtrlListView_GetItemText to get information from the correct item and subitem. I even managed to use SetItemText sucessfully on the subitem. The problem is that when you highlight the subitem for editing it changes class. Here's the output from "AutoIt Window Info":

>>>> Window <<<<
Title:  Nanoscope - ibm.007
Class:  Afx:400000:8:10003:0:1039a
Position:   -4, -4
Size:   1374, 748
Style:  0x15CF8000
ExStyle:    0x00000110
Handle: 0x000103BE

>>>> Control <<<<
Class:  Edit
Instance:   1
ClassnameNN:    Edit1
Name:   
Advanced (Class):   [CLASS:Edit; INSTANCE:1]
ID: 4660
Text:   
Position:   815, 188
Size:   150, 17
ControlClick Coords:    45, 10
Style:  0x50000080
ExStyle:    0x00000000
Handle: 0x000601C2

Which means that any changes to the Sublistview32 class using SetItemText do not seem to matter to the application. I've confirmed the value change made by SetItemText using GetItemText but there are no changes in the application, neither visual nor logical.

So this class switch makes things slightly messy. I have 3 questions regarding my problem:

1. Can I select the Edit1 class directly? (I am already assmuing this isn't possible.)

2. Can I highligt a subitem using something similar to _GUICtrlListView_ClickItem? Which does not seem to have subitem support.

3. Can I in some way find out the position of a subitem in a way similar to _GUICtrlListView_GetItemPosition? Which also does not seem to have subitem support.

Yours Sincerely

Ordeith

Link to comment
Share on other sites

You can get the handle of the item's edit control with _GUICtrlListView_GetEditControl(). See help file.

:unsure:

Oh, and here I thought I had gone through all the ListView functions. I apologize for the silly question in that case. I am stuck regarding the use of the GetEditControl though, code snippet:

Func Open_File()
    WinActivate("Nanoscope - ibm.007")
    WinWaitActive("Nanoscope - ibm.007")
    local $handle, $var
    local $title, $classDetails
    $title = "Nanoscope - ibm.007"
    $classDetails = "[CLASS:SysListView32; INSTANCE:1; ID:1636; CLASSNN:SysListView321]"
    $handle = WinGetHandle($title)
    local $listview,  $header
    $listview = ControlGetHandle($title,"", $classDetails)
    $header = _GUICtrlListView_GetHeader($listview)
    ;$hWnd = GUICtrlGetHandle($listview)
    local $rowcount
    $rowcount = _GUICtrlListView_GetItemCount($listview)
    ;ConsoleWrite($rowcount)
    local $columncount
    $columncount = _GUICtrlListView_GetColumnCount($listview)
    $test=_GUICtrlListView_GetEditControl($listview)
    ;_GUICtrlListView_SetItemText($listview, 6, "Hello!",1)
    ConsoleWrite($test)

Was reading up regarding the function and the only indata should be the window handle, $listview should suffice but I seem to be missing something obvious. $test only returns 0.

A picture of the controller I want to edit, the first column count as the item and the second as the subitems:

http://imgur.com/kd6vl

Link to comment
Share on other sites

A return of 0 is expected if there is no item edit in progress. Try it something like this when you have an item edit in progress:

Func Open_File()
    
    ; ...
    
    $classDetails = "[CLASS:SysListView32; INSTANCE:1]"
    $hLV = ControlGetHandle($title, "", $classDetails)
    $iRows = _GUICtrlListView_GetItemCount($hLV)
    $iCols = _GUICtrlListView_GetColumnCount($hLV)
    $hEdit = _GUICtrlListView_GetEditControl($hLV)
    
    ConsoleWrite("Debug:  $hLV = " & $hLV & "; $iRows = " & $iRows & "; $iCols = " & $iCols & "; $hEdit = " & $hEdit & @LF)

    ; ...

EndFunc   ;==>Open_File

:unsure:

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

This is really silly but using the following code to highlight the control I want to edit

Func Edit()
    WinActivate("Nanoscope - ibm.004")
    WinWaitActive("Nanoscope - ibm.004")
    local $handle, $var
    local $title, $classDetails
    local $hwnd
    $title = "Nanoscope - ibm.004"
    $classDetails = "[CLASS:SysListView32; INSTANCE:1; ID:1636; CLASSNN:SysListView321]"
    $hwnd = "[CLASS:Edit; Instance:1]"
    $handle = WinGetHandle($title)
    local $listview,  $header
    $listview = ControlGetHandle($title,"", $classDetails)
    $header = _GUICtrlListView_GetHeader($listview)
    $hWnd = GUICtrlGetHandle($listview)
    local $rowcount
    $rowcount = _GUICtrlListView_GetItemCount($listview)
    local $columncount
    MouseClick("left",715,357)
    Sleep(500)
    $columncount = _GUICtrlListView_GetColumnCount($listview)
    $test=_GUICtrlListView_GetEditControl($listview)
    ConsoleWrite("Debug:  $listview = " & $listview & "; $rowcount = " & $rowcount & "; $columncount = " & $columncount & "; $test = " & $test & @LF)
EndFunc

Still returns me a 0. I assumed that item edit in progress meant a highlighted control so it changed classes to "Edit". Am I wrong here?

/Ordeith

Link to comment
Share on other sites

Using the helpfile, which was recommended earlier :unsure:

I managed to get it to work, only gave me item handles though and not subitems. Might have found a workaround using _GUICtrlListView_GetSubItemRect though.

Might return but until then, thank you for all the help

Cheers,

Ordeith

Link to comment
Share on other sites

Update: Using _GUICtrlListView_GetColumnWidth and _GUICtrlListView_GetItemPosition I created my own SelectSubitem function which seem to suffice for the moment. Another question that popped up though was the use of AutoIt in python. Been over to the AutoItX and can successfully run simple AutoIt commands from python. I am running into problems using UDFs though (Such as _GUICtrlListView).

import win32com.client

Auto = win32com.client.Dispatch("AutoItX3.Control")
    
def Start_Veeco():
    Auto.Run("C:\Veeco\Z.exe")
    Auto.WinWaitActive("Nanoscope")

def Close_Veeco():
    Auto.WinClose("Nanoscope")

Using Auto._GUICtrlListView_*random choice* just returns AttributError: AutoItX3.Control._GUICtrlListView_*random choice*. Something to do with the included au3 files that are needed for the UDFs?

I posted this here since I already have a thread, can take it to the AutoItX forum though if you want.

/Ordeith

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