Jump to content

Select string from listbox - (Moved)


Recommended Posts

Hello barely novice user for Autoit here. I'm trying to select an item (called "Dictated in Dragon") in a listbox from a 3rd party app and eventually within the same window click on a button to close this window, however, all my attempts have failed to do so. This is the code I have currently that stops at selecting the item first.

 

$hWindow = WinGetHandle("Insert Audio Normal - Double Click or Press Enter to Select.")
$hControl = ControlGetHandle($hWindow, "", "[CLASS:WindowsForms10.LISTBOX.app.0.33c0d9d; INSTANCE:1]")
ControlCommand($hWindow, "", $hControl, "SelectString", "Dictated in Dragon")

 

And below is Summary of the AutoIt Window Info of the window I'm trying to select the item from:

 

Quote

>>>> Window <<<<
Title:    Insert Audio Normal - Double Click or Press Enter to Select.
Class:    WindowsForms10.Window.8.app.0.33c0d9d
Position:    288, 277
Size:    689, 438
Style:    0x16C80000
ExStyle:    0x00010180
Handle:    0x001618D6

>>>> Control <<<<
Class:    WindowsForms10.LISTBOX.app.0.33c0d9d
Instance:    1
ClassnameNN:    WindowsForms10.LISTBOX.app.0.33c0d9d1
Name:    TemplateList
Advanced (Class):    [NAME:TemplateList]
ID:    2363260
Text:    
Position:    16, 64
Size:    650, 290
ControlClick Coords:    86, 17
Style:    0x560100C1
ExStyle:    0x00000200
Handle:    0x00240F7C

>>>> Mouse <<<<
Position:    393, 384
Cursor ID:    0
Color:    0xFFFFFF

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
User Audio Normals and Templates
Insert Selected
Rename Selected
Remove Selected
C:\ProgramData\FusionDictate\Templates\User Test
User Audio Templates Path:


>>>> Hidden Text <<<<
 

Any help on this would be greatly appreciated!

Link to post
Share on other sites
  • Moderators
Posted (edited)

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to post
Share on other sites

@FrancescoDiMuro Thanks for the suggestion, I did an "If @error Then MsgBox() exit..." behind both the WinGetHandle and ControlGetHandle and I'm failing on the "ControlGetHandle".  I've tried replacing the "controlID" portion with

"[CLASS: WindowsForms10.LISTBOX.app.0.33c0d9d; INSTANCE: 1]"

"[ID: 2363260]"

" [NAME:TemplateList]"

But it continues to fail on the control handle, I have the update code below:

 

$hWindow = WinGetHandle("[CLASS:WindowsForms10.Window.8.app.0.33c0d9d]")
        If @error Then
            MsgBox($MB_SYSTEMMODAL, "", "An error occurred when trying to retrieve the WINDOW handle of Fusion.")
            Exit
        EndIf
        consoleWrite('handle window: ' & $hWindow & @CRLF)
        $hControl = ControlGetHandle($hWindow, "", "[ID: 2363260]")
        If @error Then
            MsgBox($MB_SYSTEMMODAL, "", "An error occurred when trying to retrieve the CONTROL handle of Fusion.")
            Exit
        EndIf
        consoleWrite('handle control: ' & $hControl & @CRLF)
        ControlCommand($hWindow, "", $hControl, "SelectString", "Dictated in Dragon")

 

Any thoughts?

Link to post
Share on other sites

@Yodavish
Check the usage of ControlGetHandle with ID parameter; there's a space after ID, and you could just use the ID instead of using [ID:].

From the Help file:

Quote

e.g. Click on control ID 254 in "My Window"

ControlClick("My Window", "", "[ID:254]")

or

ControlClick("My Window", "", 254)

^_^

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to post
Share on other sites
Posted (edited)

Hi @Yodavish,

Does this work?

Global $g_hWnd = WinGetHandle('Insert Audio Normal - Double Click or Press Enter to Select.')
Global $g_iIndex = ControlCommand($g_hWnd, '', '[CLASS:WindowsForms10.LISTBOX.app.0.33c0d9d; INSTANCE:1]', 'FindString', 'Dictated in Dragon')
ControlCommand($g_hWnd, '', '[CLASS:WindowsForms10.LISTBOX.app.0.33c0d9d; INSTANCE:1]', 'SetCurrentSelection', $g_iIndex)

 

Edited by Luke94
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...