rbhkamal Posted March 7, 2007 Posted March 7, 2007 (edited) If a combo box has Item1="<>" and Item2="<" and I use ControlCommand(.,.,.,"SelectString" , "<") to select Item2, ControlCommand selects Item1 instead ..... How can I go around that?Here is my code:$SELECT_STRING = "<" $hwnd = GUICreate( "testing" , 200 , 150 ) $combo = GUICtrlCreateCombo( "" , 20 , 20 , 100 , 200 ) GUICtrlSetData( -1 , "none|=|<>|<|>|regex" , "none" ) GUISetState() $first = True While( GUIGetMsg() <> -3 ) If $first Then ControlCommand( $hwnd , "" , $combo , "SelectString" , $SELECT_STRING ) If @error Then ConsoleWrite( "-- ControlCommand() failed >Error: " & @error & @CRLF ) Else ConsoleWrite( "ControlCommand() successful" & @CRLF ) EndIf $first = False EndIf WEndNote: I can't change the GUI....Thanks,RK Edited March 7, 2007 by rbhkamal "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix
tAKTelapis Posted March 7, 2007 Posted March 7, 2007 the SelectString option is obviously using some kind of regular expression..in your case, the first instance of < that it is finding, is the <>, and so it is assuming that is the correct answer..it isn't finding a literal string, it is finding any occurence of THAT stringto see what i mean, try this:GUICtrlSetData( -1 , "none|=|<|<>|>|regex" , "none" )i have moved the < to be before the <> , the ControlCommand will select this as it is the first occurrence in the combo box
rbhkamal Posted March 7, 2007 Author Posted March 7, 2007 the SelectString option is obviously using some kind of regular expression..in your case, the first instance of < that it is finding, is the <>, and so it is assuming that is the correct answer..it isn't finding a literal string, it is finding any occurence of THAT stringto see what i mean, try this:GUICtrlSetData( -1 , "none|=|<|<>|>|regex" , "none" )i have moved the < to be before the <> , the ControlCommand will select this as it is the first occurrence in the combo boxThanks, but do you know how to go around this without changing the GUI?Regards,RK "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix
rbhkamal Posted March 7, 2007 Author Posted March 7, 2007 Found it! $SELECT_STRING = "<" $hwnd = GUICreate( "testing" , 200 , 150 ) $combo = GUICtrlCreateCombo( "" , 20 , 20 , 100 , 200 ) GUICtrlSetData( -1 , "none|=|<>|<|>|regex" , "none" ) $comboHwnd = ControlGetHandle( $hwnd , "" , $combo ) GUISetState() $first = True While( GUIGetMsg() <> -3 ) If $first Then ;$ret = ControlCommand( $hwnd , "" , $combo , "SETCURSEL" , $SELECT_STRING ) $index = DllCall("user32.dll", "int", "SendMessage", "hwnd", $comboHwnd, "int", 0x158 , "int", 0 , "str", $SELECT_STRING ) $ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $comboHwnd, "int", 0x14E , "int", $index[0] , "int", 0 ) If @error Then ConsoleWrite( "-- ControlCommand() failed >Error: " & @error & @CRLF ) Else ConsoleWrite( "ControlCommand() successful , return: "&$ret[0] & @CRLF ) EndIf $first = False EndIf WEnd Regards, RK "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix
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