Jump to content

Major issues interacting with ComboBox


Go to solution Solved by Danp2,

Recommended Posts

Hello all,

I am aware that most of you may have seen similar questions being asked a lot. I've spent some days know to go through many of the propesed answers but so far none of those answers were able to help me to resolve the issue, i.e. interacting with a standard ComboBox of a third party software.

I am doing this on Windows 11 (22H2) using AutoIt v3.3.16.1.

What I am trying to do is to select a language from a ComboBox when running an InstallShield setup launcher (setup.exe). The only thing I managed so far is to read out the currently selected value that is being displayed:
 

Local Const $sWndTitle = "InstallShield Wizard"
Local Const $sCtrlClass = "[CLASS:ComboBox; INSTANCE:1]"

WinActivate($sWndTitle)
Local $hWnd = WinWaitActive($sWndTitle, "", 5)
Local $sCurrentLang = ControlGetText($hWnd, "", $sCtrlClass)
ConsoleWrite("$sCurrentLang: " & $sCurrentLang & @CRLF) ; OK


Considering this dialog

image.png.ed5aa529d1e87cec24bbe057efc57d6b.png

this gives me "$sCurrentLang: Deutsch" on the console. So far, so good.

Now the issue is that I can't figure out how to select a different value from that ComboBox. I've tried all kinds of things ranging from all sorts of Control Name variations to different methods I found here in this forum, on StackOverflow, the web, like:

ControlSetText($hWnd, "", "[CLASS:ComboBox; INSTANCE:1]", "Englisch", 1)

ControlSend($hWnd, "", "[CLASS:ComboBox; INSTANCE:1]", "E")
ControlSend($hWnd, "", "[CLASS:ComboBox; INSTANCE:1]", "Englisch")

ControlCommand($hWnd, "" , "[CLASS:ComboBox; INSTANCE:1]" , "SelectString" , "Englisch")

ControlSend($hWnd, "", $hCtrl, "Englisch")

_GUICtrlComboBox_SetCurSel(306, 1)  ;ID from AutoIt Info Tool
_GUICtrlComboBox_SetCurSel("ComboBox1", 1)

;...

The AutoIt Info Tool gives the following information about the ComboBox:

>>>> Window <<<<
Title:  ABC - InstallShield Wizard
Class:  #32770
Position:   1088, 617
Size:   384, 157
Style:  0x94C808C4
ExStyle:    0x00010101
Handle: 0x00000000000D0910

>>>> Control <<<<
Class:  ComboBox
Instance:   1
ClassnameNN:    ComboBox1
Name:   
Advanced (Class):   [CLASS:ComboBox; INSTANCE:1]
ID: 306
Text:   
Position:   51, 65
Size:   317, 21
ControlClick Coords:    120, 19
Style:  0x50010343
ExStyle:    0x00000004
Handle: 0x00000000003F10EC

I also tried other CombBox related functions, for example:

ControlCommand("InstallShield", "", "ComboBox1","ShowDropDown", "")

but nothing worked, except ControlGetText().

I would be very thankful if anybody could give me a hint on how to interact with this ComboBox. If anything is unclear or missing please do not hesitate to ask.

Best regards,
Tacomas

 

Edit: This might be a Windows 11 issue, since I just found that I also can't click a button on this dialog. Either this or I completely misunderstood how to use AutoIt to interact with UI controls.

WinActivate($sWndTitle)
If ControlClick($sWndTitle, "", "[CLASS:Button; INSTANCE:2]") = 0 Then ConsoleError("ERROR: ControlClick() failed!" & @CRLF) ;no click, no error

 

Edited by Tacomas
edit
Link to comment
Share on other sites

Have you tried to do a silent install with Install Shield? This way you do not need to automate the installation GUI.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Sorry for not having mentioned it, but a silent installation is not an option because it's the installation process that I need to write a test for. Some of the test cases include the control of proper translation etc. so the script has to go through every single step of the installation process.

Link to comment
Share on other sites

As you can read out the currently selected value I suggest to use the same approach to set the value. Plus add some error checking.

Local Const $sWndTitle = "InstallShield Wizard"
Local Const $sCtrlClass = "[CLASS:ComboBox; INSTANCE:1]"
Local Const $sSetLang = "English"

If WinActivate($sWndTitle) = 0 Then Exit MsgBox(0, "Error", "WinActivate - Could not activate the window!")
Local $hWnd = WinWaitActive($sWndTitle, "", 5)
If $hWnd = 0 Then Exit MsgBox(0, "Error", "WinWaitActivate - error when waiting for the window to become active!")
ControlCommand($hWnd, "", $sCtrlClass, "SelectString", $sSetLang)
If @error Then Exit MsgBox(0, "Error", "ControlCommand - error when selecting a language from the ComboBox!")

BTW: What is the exact value in your ComboBox? "English" or "Englisch"?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

BTW: What is the exact value in your ComboBox? "English" or "Englisch"?

Currently both writings exist in the installer, but you are right, I should take care to use it consistently in my script.

Plus add some error checking.

I left it out of my posts to keep the focus on the function calls. Actually I do nearly the exact same error checking in my current script as you have proposed: 😉 

ConsoleWrite("ControlFocus(""" & $sWndTitle & """, """", """ & $sCtrlClass & """" & @TAB & "--> ")
If ControlFocus($sWndTitle, "", $sCtrlClass) = 0 Then 
    ConsoleWrite("Success" & @CRLF)
Else
    ConsoleWriteError("Failed: " & @error & @CRLF)
EndIf

It seems as if the problems with the setup dialog interaction might be caused by Windows UAC. I will do some more testing and post the results.

Link to comment
Share on other sites

On 8/29/2023 at 9:56 AM, Tacomas said:

I still wonder why all functions return with no error

Well, in the code you posted, there is not a single line checking for @error or function result.  AutoIt will not crash your script because there is an error in it (unless absolutely necessary).  So you need to check yourself if AutoIt informs you of an error.  Make senses, don't you think ? 

Link to comment
Share on other sites

  • 2 weeks later...
On 9/1/2023 at 12:21 AM, Nine said:

Well, in the code you posted, there is not a single line checking for @error or function result.  AutoIt will not crash your script because there is an error in it (unless absolutely necessary).  So you need to check yourself if AutoIt informs you of an error.  Make senses, don't you think ? 

Thanks Nine. Of course I use "If @error" in my script after each API call that sets it. Yet in this case none of the calls return with an error. Hence the confusion. :)

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

×
×
  • Create New...