Jump to content
Sign in to follow this  
djdemarco

Help needed with trying to get information from a ComboListBox into an array.

Recommended Posts

djdemarco

As the title says, I am attempting to create an array from a ComboListBox (specifically SysListView321 within the Dfrg.msc MMC in XP) and then check which array item contains the specific information.

Essentially, I want to select the row containing the C: drive within that list and then defragment it.

I have most areas of the code working (at the moment it will defrag the first item in the list) but am having problems trying to select the drive I would like it to defragment.

The code I have so far is:

Local $drivecheckarray [40]
    Local $searchstring = "C:"
    
    ShellExecute("dfrg.msc")
    WinWaitActive("Disk Defragmenter"); Waits for Program to become active
    WinActivate ( "Disk Defragmenter"); Makes sure that Defrag is the active process

    $drivecheck = ControlGetHandle("Disk Defragmenter", "", "SysListView321"); gets handle for the combobox
    
    $drivecheckarray = _GUICtrlComboBox_GetListArray($drivecheck); gets array from combobox using control handle
    
    For $X = 0 To UBound($drivecheckarray) - 1
        If NOT StringInStr ( $drivecheckarray[$X], $searchstring ) = 0 Then MsgBox(0, "Array Details", $drivecheckarray[$X])
    Next  ; Checks for $searchstring in each section of the array and, if found, display the contents of that array item in a msgbox

The $drivecheck variable correctly gets the handle of the window and the checking routine appears to work when checked with other data but the array seems as though it isn't populated correctly.

When checking the data in the $drivecheckarray (which should consist of a minimum of an index and 6 items) the index shows only one item read (which turns out to be empty).

I am obviously doing something wrong and would appreciate any help or advice that could be given as my concentration is somewhat diminished by my teething 5-month old son.

Cheers in advance. ;)

Share this post


Link to post
Share on other sites
martin

As the title says, I am attempting to create an array from a ComboListBox (specifically SysListView321 within the Dfrg.msc MMC in XP) and then check which array item contains the specific information.

Essentially, I want to select the row containing the C: drive within that list and then defragment it.

I have most areas of the code working (at the moment it will defrag the first item in the list) but am having problems trying to select the drive I would like it to defragment.

The code I have so far is:

Local $drivecheckarray [40]
    Local $searchstring = "C:"
    
    ShellExecute("dfrg.msc")
    WinWaitActive("Disk Defragmenter"); Waits for Program to become active
    WinActivate ( "Disk Defragmenter"); Makes sure that Defrag is the active process

    $drivecheck = ControlGetHandle("Disk Defragmenter", "", "SysListView321"); gets handle for the combobox
    
    $drivecheckarray = _GUICtrlComboBox_GetListArray($drivecheck); gets array from combobox using control handle
    
    For $X = 0 To UBound($drivecheckarray) - 1
        If NOT StringInStr ( $drivecheckarray[$X], $searchstring ) = 0 Then MsgBox(0, "Array Details", $drivecheckarray[$X])
    Next ; Checks for $searchstring in each section of the array and, if found, display the contents of that array item in a msgbox

The $drivecheck variable correctly gets the handle of the window and the checking routine appears to work when checked with other data but the array seems as though it isn't populated correctly.

When checking the data in the $drivecheckarray (which should consist of a minimum of an index and 6 items) the index shows only one item read (which turns out to be empty).

I am obviously doing something wrong and would appreciate any help or advice that could be given as my concentration is somewhat diminished by my teething 5-month old son.

Cheers in advance. ;)

I think _GUICtrlComboBox_GetListArray is intended for controls created in the same script not in an external application. Control handles are unique in a window but not unique in Windows, ie two windows could have controls with the same control handles. I don't know how to get the items from a combo in another application.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
djdemarco

I think _GUICtrlComboBox_GetListArray is intended for controls created in the same script not in an external application. Control handles are unique in a window but not unique in Windows, ie two windows could have controls with the same control handles. I don't know how to get the items from a combo in another application.

That would certainly explain why it wouldn't work and also highlights a need for further learning on my part.

Thanks a lot for your explanation, I shall seek out other options.

;)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.