Jump to content

Selecting a exact string from dropdown


Recommended Posts

Following is the list of items in a dropdown

1. 'TAB Processor (TAB QWERTYGP Compound) - Qwert00'

2. 'TDD Processor (TDD QWERTYGP Compound) - Qwert00'

3. 'TPA Processor (TPA QWERTYGP Compound) - Qwert00'

I am using the following code to select a particular string from dropdown.

ControlCommand("Test Form", "", $hcombo, "ShowDropDown")

ControlSend("Test Form", "", $hcombo, "select", 'TPA Processor (TPA QWERTYGP Compound) - Qwert00')

But instead of selecting 'TPA Processor (TPA QWERTYGP Compound) - Qwert00' string it selects 'TAB Processor (TAB QWERTYGP Compound) - Qwert00'

PLease help how I can force it to select a particular string instead of it matching the first character.

Link to comment
Share on other sites

Try using this:

ControlCommand("Test Form", "", $hcombo, "ShowDropDown")
ControlCommand("Test Form", "", $hcombo, "SelectString", 'TPA Processor (TPA QWERTYGP Compound) - Qwert00')

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Try using this:

ControlCommand("Test Form", "", $hcombo, "ShowDropDown")
ControlCommand("Test Form", "", $hcombo, "SelectString", 'TPA Processor (TPA QWERTYGP Compound) - Qwert00')

Tried this way as well but it wont even select any thing. Any thing I am missing here. Following is the full code I am trying

#Include <GuiComboBox.au3>

#include <Constants.au3>

local $hcombo = "[NAME:ctlMsgQueueCombo]"

;Start test executable

Run("Z:\test\Groups\bin\Debug\Test.exe")

Global $hWHandle = WinWaitActive("Test Form", "", 2)

sleep(8000)

controlFocus("", "", "[NAME:ctlQueSelector]")

controlsend("", "", "[NAME:ctlQueSelector]", '2')

ControlCommand("Test Form", "", $hcombo, "ShowDropDown")

ControlCommand("Test Form", "", $hcombo, "SelectString", 'TPA Processor (TPA QWERTYGP Compound) - Qwert00')

IS there any thing to do with string = "TPA Processor (TPA QWERTYGP Compound) - Qwert00" as it is containing (spaces, (,), -, numbers).

Edited by gigabyte
Link to comment
Share on other sites

It shouldn't matter. Try using just the "TPA" part.

Do you have any error return?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

It shouldn't matter. Try using just the "TPA" part.

Do you have any error return?

but its a long list and many start with TPA e.g

Following is the list of items in a dropdown

1. 'TAB Processor (TAB QWERTYGP Compound) - Qwert00'

2. 'TDD Processor (TDD QWERTYGP Compound) - Qwert00'

3. 'TPA Processor (TPA QWERTYGP Compound) - Qwert00'

4. 'TPA Processor (TPA QWERTYAD Compound) - Qwert01'

5. 'TPA Processor (TPA QWERTYGD Compound) - Qwert02'

6. 'TAB Processor (TAB QWERTYAD Compound) - Qwert01'

in this case it will always selects the first TPA one...Why it is not matching the whole string. as these values varies according to company. and I need to select a particular one.

"SelectString" is not working. it selects using the "Select".

No error return

Edited by gigabyte
Link to comment
Share on other sites

Someone else will have to take this over me, I'm clueless and not familiar enough with related issues to guide you efficiently.

Sorry for that.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Someone else will have to take this over me, I'm clueless and not familiar enough with related issues to guide you efficiently.

Sorry for that.

:huh2: ...Desperalty waiting for someone to guide me over this...As this has been now 2 days and I even tried with _GUICtrlComboBox_FindString, _GUICtrlComboBox_SelectString, _GUICtrlComboBox_SetCurSel but nothing seems to work...
Link to comment
Share on other sites

Does and/or bring any help?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

I don't have a problem using ControlCommand function with 'FindString' command. Here is an example.

#include <GUIConstantsEx.au3>

$text = 'TAB Processor (TAB QWERTYGP Compound) - Qwert00'
$text &=  '|' & 'TDD Processor (TDD QWERTYGP Compound) - Qwert00'
$text &=  '|' & 'TPA Processor (TPA QWERTYGP Compound) - Qwert00'
$text &=  '|' & 'TPA Processor (TPA QWERTYAD Compound) - Qwert01'
$text &=  '|' & 'TPA Processor (TPA QWERTYGD Compound) - Qwert02'
$text &=  '|' & 'TAB Processor (TAB QWERTYAD Compound) - Qwert01'

Example()

Func Example()
    Local $msg
    GUICreate("My GUI combo")  ; will create a dialog box that when displayed is centered

    GUICtrlCreateCombo("", 10, 10,300) ; create first item
    GUICtrlSetData(-1,$text)

    $btnFind = GUICtrlCreateButton("Find String",10,50)

    GUISetState()

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
            If $msg = $btnFind Then
                $index = ControlCommand("My GUI combo","Find String","ComboBox1","FindString",'TPA Processor (TPA QWERTYAD Compound) - Qwert01')
                ControlCommand("My GUI combo","Find String","ComboBox1","SetCurrentSelection",$index)
            EndIf
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>Example
Link to comment
Share on other sites

I don't have a problem using ControlCommand function with 'FindString' command. Here is an example.

#include <GUIConstantsEx.au3>

$text = 'TAB Processor (TAB QWERTYGP Compound) - Qwert00'
$text &=  '|' & 'TDD Processor (TDD QWERTYGP Compound) - Qwert00'
$text &=  '|' & 'TPA Processor (TPA QWERTYGP Compound) - Qwert00'
$text &=  '|' & 'TPA Processor (TPA QWERTYAD Compound) - Qwert01'
$text &=  '|' & 'TPA Processor (TPA QWERTYGD Compound) - Qwert02'
$text &=  '|' & 'TAB Processor (TAB QWERTYAD Compound) - Qwert01'

Example()

Func Example()
    Local $msg
    GUICreate("My GUI combo")  ; will create a dialog box that when displayed is centered

    GUICtrlCreateCombo("", 10, 10,300) ; create first item
    GUICtrlSetData(-1,$text)

    $btnFind = GUICtrlCreateButton("Find String",10,50)

    GUISetState()

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
            If $msg = $btnFind Then
                $index = ControlCommand("My GUI combo","Find String","ComboBox1","FindString",'TPA Processor (TPA QWERTYAD Compound) - Qwert01')
                ControlCommand("My GUI combo","Find String","ComboBox1","SetCurrentSelection",$index)
            EndIf
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>Example

I am confused, Please clear my understanding. Why do we have to create a GUIcombobox and populate it with values. What I want is to select value from an existing open form. Is it possible with this. because in the example you are creating a new combo and then populating it with values. and then using the guicombo to find a string. please guide.
Link to comment
Share on other sites

I am confused, Please clear my understanding. Why do we have to create a GUIcombobox and populate it with values. What I want is to select value from an existing open form. Is it possible with this. because in the example you are creating a new combo and then populating it with values. and then using the guicombo to find a string. please guide.

I don't have same form windows as you have. I need something to test with... This shouldn't be any differenct than yours. I'm just testing FindString is working or not. And, it seems working fine to me.

Link to comment
Share on other sites

I don't have same form windows as you have. I need something to test with... This shouldn't be any differenct than yours. I'm just testing FindString is working or not. And, it seems working fine to me.

Looks like a bug in autoit, as it is unable to handle a specific string instead just matches first characters and if they match just selects it, if its a external gui form.

Edited by gigabyte
Link to comment
Share on other sites

Looks like a bug in autoit, as it is unable to handle a specific string instead just matches first characters and if they match just selects it, if its a external gui form.

You are jumping to the conclusion too quickly. So, here is test code with external GUI.

Send("#r")
Sleep(1000)
$index = ControlCommand("Run", "Type", "ComboBox1", "FindString", 'C:\Windows\SysWOW64\cmd.exe')
ControlCommand("Run", "Type", "ComboBox1", "SetCurrentSelection", $index)

My search string 'C:\Windows\SysWOW64\cmd.exe' was way down in the list.

Edited by Joon
Link to comment
Share on other sites

You are jumping to the conclusion too quickly. So, here is test code with external GUI.

Send("#r")
Sleep(1000)
$index = ControlCommand("Run", "Type", "ComboBox1", "FindString", 'C:\Windows\SysWOW64\cmd.exe')
ControlCommand("Run", "Type", "ComboBox1", "SetCurrentSelection", $index)

My search string 'C:\Windows\SysWOW64\cmd.exe' was way down in the list.

Can you please tell, you are trying this code on which ver of windows. I am using Windows 7.

PLz also guide in your code ControlCommand("Run", "Type", "ComboBox1", "SetCurrentSelection", $index) what is this "Type" refering to.

Edited by gigabyte
Link to comment
Share on other sites

Windows 7 Enterprise x64

Just found out in the following code

ControlCommand($title,"Find String",$hcombo,"SetCurrentSelection",$index)

"SetCurrentSelection" would not come up while typing instead just Select is available. Am I missing some library or any missing tool.

Link to comment
Share on other sites

I don't have same form windows as you have. I need something to test with... This shouldn't be any differenct than yours. I'm just testing FindString is working or not. And, it seems working fine to me.

Yes I tested your piece of code and yes it works fine when you create your own form and populate it with values. Problem is coming when you have an existing windows application form with already populated values in it. and then you try to find a string, it wont work. Not possible for me to send that form, Can you please test this with any of your existing application, If possible. Would be highly grateful. :huh2:;)

the following code works but always selects 5th item in list from a list of 10 items

$index = ControlCommand($title,"",$hcombo,"FindString",'TPA Processor (TPA QWERTYAD Compound) - Qwert01')

ControlSend($title, "", $hcombo, "select", $index)

Edited by gigabyte
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...