Jump to content

Command "AddString" in function ControlCommand get error


Recommended Posts

take a look at following code:

Func Example_01()

    # I copy properties of win form and control by AutoIt window info tool
    Local $win_ppt = "[TITLE:Form_ListBox;CLASS:WindowsForms10.Window.8.app.0.141b42a_r9_ad1;INSTANCE:1]"
    Local $ctl_ppt = "[CLASS:WindowsForms10.LISTBOX.app.0.141b42a_r9_ad1;NAME:ListBox1;INSTANCE:1]"

    WinActivate($win_ppt, "")

    Local $ret = ControlCommand($win_ppt, "", $ctl_ppt, "AddString", 'line ii')

    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "Error")
    EndIf

EndFunc   #==>Example_01

The result of running the code is: get error and no new line is added to ListBox

Anyone can help, thanks.

Link to post
Share on other sites
4 hours ago, dd1978 said:

Local $win_ppt = "[TITLE:Form_ListBox;CLASS:WindowsForms10.Window.8.app.0.141b42a_r9_ad1;INSTANCE:1]"

that doesn't seem right

in info Tools in the Windows tab it does not have Advanced mode as have the control tab

[TITLE:My Window; CLASS:My Class; INSTANCE:2]

... and the  # I copy properties of win form and control by AutoIt window info tool

 is better  with  ; I copy properties of win form and control by AutoIt window info tool

 

Edited by ioa747
Link to post
Share on other sites

I have tested following code:

Func Example_01()

    Local $win_ppt = "[TITLE:Form_ListBox;CLASS:WindowsForms10.Window.8.app.0.141b42a_r9_ad1;INSTANCE:1]"
    Local $hWnd = WinGetHandle($win_ppt)

    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when trying to retrieve the window handle.")
        Exit
    EndIf

    MsgBox($MB_SYSTEMMODAL, "", $hWnd)

EndFunc   ;==>Example_01

The MsgBox prints the value: 0x000306A2

and without error

I feel that this is a handle, right?

Link to post
Share on other sites

I have tested the code for control:

Func Example_02()

    Local $win_ppt = "[TITLE:Form_ListBox;CLASS:WindowsForms10.Window.8.app.0.141b42a_r9_ad1;INSTANCE:1]"
    Local $ctl_ppt = "[CLASS:WindowsForms10.LISTBOX.app.0.141b42a_r9_ad1;NAME:ListBox1;INSTANCE:1]"

    Local $hControl = ControlGetHandle($win_ppt, "", $ctl_ppt)

    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when trying to retrieve the control handle.")
        Exit
    EndIf

    MsgBox($MB_SYSTEMMODAL, "", "The handle is: " & $hControl)

EndFunc   ;==>Example_02

has run without error

MsgBox prints the value of $hControl like a handle: 0x000E0610

any suggestions, thanks

Link to post
Share on other sites

The UI to be tested against is a .net winform. I compile the UI application under VS2019 VB.Net

I have tested button click, button enable and disable, combo box show dropdown and hide dropdown. These tasks all work properly.

Now I stoped at using AddString command of ControlCommand function to add new line into ListBox.

Is there any configuration required for ListBox to get new line from my AutoIt script?

Link to post
Share on other sites
Quote
"GetCount", ""       Returns number of entries in a ListBox or ComboBox

About ControlCommand in help file.  Make sure you have latest version of AutoIt.

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...