GitHubShen / robotframework-autoitlibrary

Automatically exported from code.google.com/p/robotframework-autoitlibrary
Apache License 2.0
0 stars 0 forks source link

Support for Combobox in .Net #5

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
It's not possible to use the existing functions to update a combobox of a
.Net application. Not to retrieve the current value, or set a value.

See also on the Autoit forum:
http://www.autoitscript.com/forum/index.php?showtopic=66803&st=0&p=496147&hl=Net
%20getcurrentselection&fromsearch=1&#entry496147

Solution on the forum (AutoIt syntax):
Func ComboBox_SelectString( $winTitle, $winText, $control, $option )
    Local $hWnd = ControlGetHandle( $winTitle, $winText, $control )
    Local $index = _GUICtrlComboBox_FindString( $hWnd, $option )

    If $index = -1 then
        ConsoleWrite( $option & " not found"    & @CRLF)
        SetError( 1 )
        Return False
    EndIf

    If $index = 0 then
      ; If the item is the first in the list, use hotkeys to navigate to it
        ControlSend( $winTitle, $winText, $hWnd, "^{PGUP}" )
    Else
      ; Select the item right before the target index, then send down
        _GUICtrlComboBox_SetCurSel($hWnd, $index - 1)
        ControlSend( $winTitle, $winText, $hWnd, "{DOWN}" )
    EndIf

    Return True
EndFunc

Problem here is that the _GUICtrlComboBox_x methods are not available
through the AutoItLibrary.
Can it be made available somehow ?

Original issue reported on code.google.com by kris...@gmail.com on 9 Dec 2009 at 10:21

GoogleCodeExporter commented 8 years ago
The _GUICtrlComboBox_x methods are not available in AutoItLibrary because it is
simply a Python wrapper of the AutoItX COM object, and these methods are not
available in the COM object.  If you look at the AutoItX.chm help file you'll 
see
that there is a generic command for sending sub-commands to specific controls:

ControlCommand "title", "text", "controlID", "command", "option"

One of the commands you can send to a control this way is

"FindString", 'string': Returns occurrence ref of the exact string in a ListBox 
or
ComboBox

Perhaps you can experiment with this to see if it solves your problem.  If you 
can
figure out a way to do this using the methods in the AutoItX COM object then we 
could
wrap that solution in a new keyword method at the Python layer.

Since I don't know .NET, or have any .NET applications to test this on, I'm 
afraid I
can't provide any further assistance.

Original comment by c.martin...@gmail.com on 5 Mar 2010 at 2:23

GoogleCodeExporter commented 8 years ago
Marking "WontFix" since I can't see a way to do this via the AutoItX3.dll COM 
object.
 Please open a new issue if you find a solution to this.

Original comment by c.martin...@gmail.com on 23 Apr 2010 at 7:45

GoogleCodeExporter commented 8 years ago

Original comment by c.martin...@gmail.com on 23 Apr 2010 at 7:58