Sign in to follow this  
Followers 0
vatobeto

Getting Item count/list of combo box of Win32 App

6 posts in this topic

I am a neophyte to AutoIt, but I've already used it to solve several 'hung-up' programs. Then I came to this one. I"m using AutoIt scripts in combination with a multimedia design program, which has an extremely limited scripting facility built-in. This particular problem involves scripting a freeware micro cd burner to burn disc images. I need to determine from the program what the available disc drives are (more than one, etc.), allow the user (me) to pick drive to use, and choose that drive from a combo box in the app window. I've read what I could find in the forums and in the help files, but after several days of fiddling, still can't get it right. A test program for this feature is below, including some commented-out alternative code that didn't work either. Any help is appreciated.

#include <GUICombo.au3>
#include <GuiConstants.au3>

$CWD = @ScriptDir
$AutoExec = $CWD & "\Portable_Micro20.exe"
$wndTitle = "SilentNight Micro CD/DVD/ISO/AUDIO Burner version 4.1.2 - Unregistered version"
$ctrlName1 = "Edit1"
$ctrlName2 = "TAdvComboBox1"
$winText = "CD/DVD"
$winHand = WinGetHandle ($wndTitle, $winText)
$ctrlID = 1001

Run($AutoExec, "")
Sleep(13000)
If Not WinActive($winHand) Then
    MsgBox(0,"","Window was NOT active")
EndIf
$hwndComboBox = ControlGetHandle($wndTitle, $winText, $ctrlName2)
ControlFocus ( $wndTitle, $winText, $ctrlName2 )

;ctrlID = _GetDlgCtrlID($hwndComboBox)
;MsgBox(0,"",$ctrlID)
;MsgBox(4096, "", _GUICtrlComboGetList($ctrlID))

ControlFocus ( $wndTitle, $winText, $ctrlID )
$Count = GUICtrlSendMsg($ctrlID, $CB_GETCOUNT, 0, 0)
MsgBox(0,"",$Count)

Exit


Func _GetDlgCtrlID($hwnd)
    $ID = DllCall('user32.dll', 'int', 'GetDlgCtrlID', 'hwnd', $hwnd)
    if IsArray ($ID) Then Return $ID[0]
    Return $ID
EndFunc  ;==>GetDlgCtrlID

I just keep getting empty strings, when I request a list of the items in the combo box, or '0' as the list length. The values for the control ID and control names I got with AU3Info, even though I certainly know it's bad style to hardwire such potentially variable data into a program. Desperation overcame me.

Thanks for all the help these forums have already provided.

Vatobeto.

Share this post


Link to post
Share on other sites

Not sure exactly what you want, but you could create a GUI that will ask the user to select a Drive, and then have the script select that drive in the multimedia design program.

Here's a function i just whipped up to ask the user for a drive:

Func _ChooseCDDrive()
    #include <GUIConstants.au3>
    Dim $dDrives = DriveGetDrive("CDROM")
    Dim $dGui = GUICreate("Choose a Drive...", 232, 79, 193, 115)
    Dim $dChoose = GUICtrlCreateCombo("Choose one of " & $dDrives[0] & " drives", 8, 8, 209, 25)
    For $d = 1 To UBound($dDrives) - 1 Step 1
        GUICtrlSetData(-1, $dDrives[$d])
    Next
    Dim $dOk = GUICtrlCreateButton("Ok", 8, 40, 97, 25, 0)
    Dim $dCancel = GUICtrlCreateButton("Cancel", 120, 40, 97, 25, 0)
    
    GUISetState(@SW_SHOW)

    $dMsg = GUIGetMsg()

    While $dMsg <> $GUI_EVENT_CLOSE And $dMsg <> $dCancel
        $dMsg = GUIGetMsg()
        If $dMsg = $dOk And StringInStr(GUICtrlRead($dChoose), "Choose") = 0 Then ExitLoop
    WEnd
    
    Return GUICtrlRead($dChoose)
EndFunc   ;==>_ChooseDrive

MsgBox(0, "", _ChooseDrive())

Share this post


Link to post
Share on other sites

Not sure exactly what you want, but you could create a GUI that will ask the user to select a Drive, and then have the script select that drive in the multimedia design program.

Here's a function i just whipped up to ask the user for a drive:

Func _ChooseCDDrive()
    #include <GUIConstants.au3>
    Dim $dDrives = DriveGetDrive("CDROM")
    Dim $dGui = GUICreate("Choose a Drive...", 232, 79, 193, 115)
    Dim $dChoose = GUICtrlCreateCombo("Choose one of " & $dDrives[0] & " drives", 8, 8, 209, 25)
    For $d = 1 To UBound($dDrives) - 1 Step 1
        GUICtrlSetData(-1, $dDrives[$d])
    Next
    Dim $dOk = GUICtrlCreateButton("Ok", 8, 40, 97, 25, 0)
    Dim $dCancel = GUICtrlCreateButton("Cancel", 120, 40, 97, 25, 0)
    
    GUISetState(@SW_SHOW)

    $dMsg = GUIGetMsg()

    While $dMsg <> $GUI_EVENT_CLOSE And $dMsg <> $dCancel
        $dMsg = GUIGetMsg()
        If $dMsg = $dOk And StringInStr(GUICtrlRead($dChoose), "Choose") = 0 Then ExitLoop
    WEnd
    
    Return GUICtrlRead($dChoose)
EndFunc   ;==>_ChooseDrive

MsgBox(0, "", _ChooseDrive())

Thanks. Sorry for the late reply - my DSL modem died, now replaced. That is a very elegant solution to the 'choose drive' aspect of my problem. I wasn't aware of the DriveGetDrive function. Still trying to get the ComboBox list contents using DLL calls.

Vatobeto.

Share this post


Link to post
Share on other sites

You'll have to try other methods with TAdvComboBox1, this is not a standard windows control

I downloaded the 6.0.22 and it's skinned to boot.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

You'll have to try other methods with TAdvComboBox1, this is not a standard windows control

I downloaded the 6.0.22 and it's skinned to boot.

Is the 6.0.22 standalone? I need it to load from a CD on machines without the accompanying dlls.

You're right - TAdvComboBox class comes from a Korean developer site: http://www.devtools.co.kr/m_mall_detail.ph...amp;ps_goid=391

V.

Share this post


Link to post
Share on other sites

Is the 6.0.22 standalone? I need it to load from a CD on machines without the accompanying dlls.

You're right - TAdvComboBox class comes from a Korean developer site: http://www.devtools.co.kr/m_mall_detail.ph...amp;ps_goid=391

V.

Obviously, if I had remembered a little about Delphi programming, I would have recognized that the TAdvComboBox control is a Delphi generated control, by the naming convention used.

V.

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