Yodavish Posted July 8, 2021 Posted July 8, 2021 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!
Moderators JLogan3o13 Posted July 8, 2021 Moderators Posted July 8, 2021 (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 July 8, 2021 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!
FrancescoDiMuro Posted July 9, 2021 Posted July 9, 2021 (edited) @Yodavish Make sure all the functions return a valid handle, otherwise you have a bunch of instructions which you don't know if they're stuck somewhere or just can't select that item in the ListBox Edited July 9, 2021 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Yodavish Posted July 9, 2021 Author Posted July 9, 2021 @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?
FrancescoDiMuro Posted July 9, 2021 Posted July 9, 2021 @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: Forum Rules Forum Etiquette
Yodavish Posted July 9, 2021 Author Posted July 9, 2021 @FrancescoDiMuroI tired that as well removing the space, the listbox changes ID as well. Since there is code before it that opens the window that contains the listbox, I suppose the "ID" wouldn't be very consistent.
Yodavish Posted July 9, 2021 Author Posted July 9, 2021 @FrancescoDiMuro Ran out of ideas, so I tried to force by sending it keystrokes Send("{TAB}") Send("{TAB}") Send("{TAB}") Send("{TAB}") Send("{d}") Send("{Enter}") This does the trick.
FrancescoDiMuro Posted July 9, 2021 Posted July 9, 2021 @Yodavish If you are still interested in automating this application without Send() function, you should download UIASpy and try to use UIAutomation. In that case, you'll probably have more information and more ways to automate your application Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Yodavish Posted July 9, 2021 Author Posted July 9, 2021 @FrancescoDiMuro I'm not familiar with that, but I'll look into it.
Luke94 Posted July 9, 2021 Posted July 9, 2021 (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 July 9, 2021 by Luke94
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