Jump to content

How to assign name of the control to a variable?


Vinodh
 Share

Recommended Posts

My application is an external one so i found name of the control (combobox) using "AutoIT v3 window info" tool.

Now i want to set value of the combo box. How to assign the combobox name to a variable or how to set value to combobox?

Link to comment
Share on other sites

Look at ControlCommand() in the help doc. That should do what your asking.

Link to comment
Share on other sites

Hi

I am having a combo box on my screen name: ComboBox1 with 2 values

I want to select the second value on the combobox

I am getting msg box with current selection as "0" focus is also working.

Control command is not working as expected

MsgBox(4160, "Information", "Cur Sel: " & _GUICtrlComboBox_GetCurSel("ComboBox1"))

ControlFocus ( "Deposit Information Entry", "", "ComboBox1" )

ControlCommand("Deposit Information Entry", "", "WindowsForms10.COMBOBOX.app.0.2bf8098_r13_ad13", "SetCurrentSelection", 1)

Please help

Link to comment
Share on other sites

Don't use _GUICtrlComboBox_GetCurSel() unless the combobox was created by you using _GUICtrlComboBox_Create().

Does your "SetCurrentSelection" selection command work? if so all you should need is :

$selection = ControlCommand("Deposit Information Entry", "", "WindowsForms10.COMBOBOX.app.0.2bf8098_r13_ad13", "GetCurrentSelection", 1)
msgbox(0,'',$selection)

Also try to use the autoit tags when you post your code. You should see a square blue button with an A in it on the toolbar.

edit: woops. just changed that code

Edited by Beege
Link to comment
Share on other sites

Hi

Thanks for your reply

I think i am not explaining my need properly. I am very sorry for that. I am new to autoIt so please

Scenario:

I am having a dropdown "ComboBox1" on my screen "Sceen 1" (Every Time when screen loads ID is keeps on changing).

combo box is not created using _GUICtrlComboBox_Create().

Combobox is having two values

a) AAAA (Default)

:) BBBB

I want to select "BBBB" in ComboBox1.

I tried above code both with GetCurrentSelection and SetCurrentSelection both are returning 0 as result.

Could you please help to overcome this situation

Link to comment
Share on other sites

As the application you try to automate uses WindowsForms controls you might need to search the forum how to handle WindowsForms (one of the threads you'll find is ).

Unfortunately I've never automated such controls myself.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

Where did you get "WindowsForms10.COMBOBOX.app.0.2bf8098_r13_ad13" from? Do you know how to use the Window Info tool? Make sure you are using values from advanced mode.

Heres a example to go with a pic:

$selection = ControlCommand("(UDF) ComboBox Create", "", "[CLASS:ComboBox; INSTANCE:1]", "GetCurrentSelection")

Posted Image

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