Jump to content

Unexpected Behavior with ControlCommand SelectString


Recommended Posts

I have done a number of AutoIt based projects. and this the first time I have experienced this. I have a combobox with a number of choices.Of particular interest are two related choices "Base Moisture" and "Base Moisture Actuator" 

A call to ControlCommand to set "Base Moisture" results in "Base Moisture Actuator" being selected. In the ComboBox, "Base Moisture Actuator" is the first item in the list "Base Moisture" is the 10th or 12th item in the list. 

$InfostoreTitle = "InfoStore"
SelectSensor("Base Moisture")
SelectSensor("Base Moisture Actuators")

Exit

Func SelectSensor( $sSensorStr)
$test = ControlCommand($InfostoreTitle, "", "[CLASS:ThunderRT6ComboBox; INSTANCE:2]", "SelectString", $sSensorStr)
msgbox(0, "test", $test)
EndFunc

Any thoughts what might be causing this behavior?

 

Link to comment
Share on other sites

This may not be the issue, but I found this bit of information in the AutoIt help file:

You should note that underlined menu items actually contain a & character to indicate the underlining. Thus, the menu item File would actually require the text "&File", and Convert would require "Con&vert"

That was from WinMenuSelectItem. Have you tried this function instead of ControlCommand?

Link to comment
Share on other sites

Have you tried issuing first a "FindString" command (requires an exact match, I hope it means up to EOL) then "SetCurrentSelection" with the occurence number returned by the previous call?

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

Have you tried issuing first a "FindString" command (requires an exact match, I hope it means up to EOL) then "SetCurrentSelection" with the occurence number returned by the previous call? 

 I have not tried that but it is worth a shot. It doesn't explain the odd behavior of ControlCommand  but if it gets me past the problem, I am all for it.

Link to comment
Share on other sites

It looks like the string comparison in "SelectString" is like StringInStr(<ComboValue>, $str) and stops early on first (partial) match. If the term "exact match" is true, that shouldn't be the case for "FindString", hopefully.

Crossing fingers...

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 believe it's something AutoIt can do anything against: only Windows has control over what it actually does when a control is sent the command "FindString". But maybe I'm completely wrong thinking this way: I easily confess no experience nor even basic knowledge on GUIs and their elements.

Yet I'm glad it worked that way.

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

You are absolutely correct. The combobox Findstring command "Returns the index of the first item in the ComboBox that starts with the specified string" .  If that is what is being used by SetCurrentSelection, we are getting what is expected.

There is an other option for the comboxbox "FindStringExact". It would be nice if SetCurrentSelection could select between the two.

 

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