Sign in to follow this  
Followers 0
Rorax

Getting selected item from a listbox (see image)

8 posts in this topic

#1 ·  Posted (edited)

Hello,

What I'm trying to do is get the selected item from the listbox (see image)

alternative picture host: clicky

Posted Image

I've tried to use different types of currenttab and getcurrentselection but it doesnt seem to work. Is there any way to select/get information of a selection in that listbox?

Basically I want to make a automated script to scan for me using those two options. I got one working using the wizard XP have built in but need to make one that dont use that also. But kind of stuck at the beginning.

Tried to use commands like:

ControlCommand("Hp Smart Document Scan Software", "", "SysListView321", "CurrentTab", "")
ControlCommand("Hp Smart Document Scan Software", "", "SysListView321", "GetCurrentSelection", "")
[/code)

And then using a msgbox to display the result, but always get the result to either blank or 0. Any help would be appreciated!

Regards,
Rorax


            
                


    Edited  by Rorax
    
    

            
        

        
            
                

    
        
            
        
    


            
        

        
            
                
                
                
            
            
                
            
        
        
    

    
        
            Share this post
            
Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    


    

                    
                        





(adsbygoogle = window.adsbygoogle || []).push({});




                    
                
                    
                    
                    






    
    
        
mcgill   

    
        
    
             0
    
        
    

        
            
                Wayfarer
            
            

            
                

    
        
    

            
            Active Members
            
            
                

    
        
    
             0
    
        
    

                54 posts
                
                

            
        
    
    
        


    

    
        
            
            
                
            
            
        

        
    #2 · 
            Posted 
            
            
            
        
    

    


            
        
            Here is an example of getting the selected item from a listbox.  I hope this is what you are looking for.  

#include <GUIConstants.au3>

GLOBAL $MESSAGE = "The following buttons have been clicked"
GUICreate("My GUI list",280, 100) ; will create a dialog box that when displayed is centered

$Add=GUICtrlCreateButton ("Add", 0,0,75,25)
$Clear=GUICtrlCreateButton ("Clear", 0,25,75,25)
$MyList=GUICtrlCreateList ("buttons that have been clicked",75,0,205,110)
GUICtrlSetLimit(-1,200) ; to limit horizontal scrolling
GUICtrlSetData(-1,$MESSAGE)
$DisplayText = GUICtrlCreateButton ("Display", 0,50,75,25)
$Close=GUICtrlCreateButton ("Close", 0,75,75,25)

GUISetState ()

$msg = 0

While $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()

Select
    Case $msg = $Add
            GUICtrlSetData($mylist,"You clicked button No1|")
    Case $msg = $Clear
            GUICtrlSetData($mylist,"")
    Case $msg = $DisplayText
            msgbox(4096,"TEST", GUICTRLRead($mylist))
                Case $msg = $Close
            MsgBox(0,"", "the closing button has been clicked",2)
            Exit
EndSelect
Wend


            
        

        
            
                

    
        
            
        
    


            
        

        
            
                
                
                
            
            
                
            
        
        
    

    
        
            Share this post
            
Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    


    

                    
                
                    
                    
                    






    
    
        
Rorax   

    
        
    
             0
    
        
    

        
            
                Seeker
            
            

            
                

    
        
    

            
            Active Members
            
            
                

    
        
    
             0
    
        
    

                41 posts
                
                

            
        
    
    
        


    

    
        
            
            
                
            
            
        

        
    #3 · 
            Posted 
            
            
            
        
    

    


            
        
            Sort of, but that code makes a GUI itself and set events for what to happen when you click a button. I need to read the info in a listbox thats already made from another program (named SysListView321)


            
        

        
            
                

    
        
            
        
    


            
        

        
            
                
                
                
            
            
                
            
        
        
    

    
        
            Share this post
            
Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    


    

                    
                
                    
                    
                    






    
    
        
Rorax   

    
        
    
             0
    
        
    

        
            
                Seeker
            
            

            
                

    
        
    

            
            Active Members
            
            
                

    
        
    
             0
    
        
    

                41 posts
                
                

            
        
    
    
        


    

    
        
            
            
                
            
            
        

        
    #4 · 
            Posted 
            
                (edited)
            
            
            
        
    

    


            
        
            I've tried the latest beta now to just get anything from the listbox:
$ID is either 1003 or "SysListView321", tried using both (and I know $ID isnt declared in the code here but I have it of course declared in the code I'm trying)

#Include <GuiListView.au3>
WinActivate("HP Smart Document Scan Software")
WinWaitActive("HP Smart Document Scan Software")
$Selected = _GUICtrlListViewGetItemCount($ID)
msgbox(4096, "Listbox", $Selected)

Selected is displayed as: 0

#Include <GuiListView.au3>
WinActivate("HP Smart Document Scan Software")
WinWaitActive("HP Smart Document Scan Software")
$Selected = _GUICtrlListViewGetCurSel($ID)
msgbox(4096, "Title", $Selected)

Selected is displayed as: 0

----------------------------------------------------------------

I'm probably using this wrong, but I'm kind of new to autoit so hoping someone with more experience them me can shed som light on this.

Edited by Rorax

Share this post


Link to post
Share on other sites

Have you tried

#Include <GuiListView.au3>

_GUICtrlListViewGetSelectedIndices($h_listview[, $i_ReturnType=0]))

i dont know if it works though. I remember having a problem with getting info from a similair control classname:SysListView321

Share this post


Link to post
Share on other sites

You can use the ListView library in Auto3Lib to manipulate external controls. It was designed specifically for this purpose.


Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

Ah yes, ControlListView worked perfectly. Thank you very much.

Share this post


Link to post
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
Sign in to follow this  
Followers 0