cappy2112 Posted January 24, 2006 Share Posted January 24, 2006 (moved from General support forum- accidental post) I"m having a problem with SetCurrentSelection. I can see on the screen that my combo box has the string I am searching for, and I am displaying that value in a msgbox, so why isn't the select working with SetCurrentSelection? ;$bankNumber is equal to 1 when this code is called, and the first entry in the combo box is a 1 (at index 0) $WinRet = ControlFocus($BankUploadWindowTitle, "", $ControlID) msgbox(0x20,"Set bank number", "String($BankNumber)=" & String($BankNumber) ) $Ref = ControlCommand($BankUploadWindowTitle, "", $ControlID, "FindString", String($BankNumber)) if (($Ref <> - 1) and (Not @error)) Then $WinRet = ControlCommand($BankUploadWindowTitle, "", $ControlID, "SetCurrentSelection", $Ref) Msgbox(0x20,"SetBankNumber4", "$Ref from FindString=" & String($Ref)) EndIf Link to comment Share on other sites More sharing options...
tonedeaf Posted January 25, 2006 Share Posted January 25, 2006 (edited) As an alternative to ControlCommand() function, you can use DllCall() to select an item in a ComboBox DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_combobox, "int", $CB_SETCURSEL, "int", $i_index, "int", 0) Where $h_combobox handle can be get using ControlGetHandle() $i_index is the index of the item you want to select $CB_SETCURSEL = 0x14E Example: Open Date/Time properties from Control Panel. This script will select the item from the month combo box based on i_index value. Global Const $CB_SETCURSEL = 0x14E $h_combobox = ControlGetHandle("Date and Time Properties", "", 713) $i_index = 2 ; March DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_combobox, "int", $CB_SETCURSEL, "int", $i_index, "int", 0) Edited January 25, 2006 by tonedeaf Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now