Herb191 Posted April 24, 2015 Share Posted April 24, 2015 (edited) I have a window without a title in a program that is resisting automation. I can activate it, read its text with WinGetText and I can examine the controls using the Window Info tool but get no response when I use: ControlClick, ControlSetText, ControlSend, Send or _WinAPI_Keybd_Event. The below code returns 0 (window/control is not found). Any suggestions on how I can automate it without MouseClick? $Winhandle = WinGetHandle("[CLASS:WindowsForms10.Window.8.app.0.33c0d9d]", "") WinActivate($Winhandle) WinWaitActive($Winhandle) $Error = ControlSetText($Winhandle, "", "[CLASS:WindowsForms10.EDIT.app.0.33c0d9d; INSTANCE:1]", "12345") MsgBox(0, "", $Error) From Window Tool: >>>> Window <<<< Title: Class: WindowsForms10.Window.8.app.0.33c0d9d Position: 543, 102 Size: 280, 564 Style: 0x16820000 ExStyle: 0x00010101 Handle: 0x003E0960 >>>> Control <<<< Class: WindowsForms10.EDIT.app.0.33c0d9d Instance: 1 ClassnameNN: WindowsForms10.EDIT.app.0.33c0d9d1 Name: Edited April 24, 2015 by Herb191 Link to comment Share on other sites More sharing options...
caramen Posted April 24, 2015 Share Posted April 24, 2015 (edited) Do you also got an empty field in the windows process list ? or even in task manager application list? Edited April 24, 2015 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
junkew Posted April 24, 2015 Share Posted April 24, 2015 see examples thread iuiautomation and try simplespy to see if you can read and see the controls. Basic sourcecode as given by simplespy shows how to setfocus to the editbox and you can change example then to type text into the control FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
ATR Posted April 24, 2015 Share Posted April 24, 2015 Wich is the program you want automate ? Link to comment Share on other sites More sharing options...
Herb191 Posted April 24, 2015 Author Share Posted April 24, 2015 see examples thread iuiautomation and try simplespy to see if you can read and see the controls. Basic sourcecode as given by simplespy shows how to setfocus to the editbox and you can change example then to type text into the control I was able to get it to enter the data I need. Now all I need to to is invoke or click the OK control button. But for some reason I can't get it to work. #RequireAdmin #include "UIAWrappers.au3" AutoItSetOption("MustDeclareVars", 1) Local $oP1 = _UIA_getObjectByFindAll($UIA_oDesktop, "Title:=;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.33c0d9d", $treescope_children) Local $oP0 = _UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.33c0d9d", $treescope_children) _UIA_Action($oP0, "setfocus") _UIA_setVar(".mainwindow", "title:=;classname:=WindowsForms10.EDIT.app.0.33c0d9d") _UIA_setVar("OK.mainwindow", "title:=;classname:=WindowsForms10.Window.8.app.0.33c0d9d") ;set data _UIA_action(".mainwindow", "setfocus") _UIA_action(".mainwindow", "type", "12345") ;try to click or invoke _UIA_action("OK.mainwindow", "setfocus") ;_UIA_action("OK.mainwindow","invoke") _UIA_action("OK.mainwindow", "click") From simplespy: ;~ *** Standard code *** #include "UIAWrappers.au3" AutoItSetOption("MustDeclareVars", 1) Local $oP1=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Cash Register Express -- Station: 01 -- Cashier: 100101 -- 4/24/2015 08:21 AM;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.33c0d9d", $treescope_children) _UIA_Action($oP1,"setfocus") Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.33c0d9d", $treescope_children) _UIA_Action($oP0,"setfocus") _UIA_setVar("OK.mainwindow","title:=OK;classname:=WindowsForms10.Window.8.app.0.33c0d9d") _UIA_action("OK.mainwindow","setfocus") Also, how do you clear an edit box before sending text to it? I tried _UIA_action(".mainwindow", "setvalue", "") with no luck. Thanks. Link to comment Share on other sites More sharing options...
junkew Posted April 24, 2015 Share Posted April 24, 2015 rename ok.mainwindow to okButton .mainwindow has a special meaning and unfortunately has a bug so do not use it just give your elements a meaningfull name without .mainwindow _UIA_Action($oP0, "setfocus") is just a wrapper to do $oP0.setfocus() so you can either use the patterns of iUIAutomation of Microsoft $tPattern = _UIA_getPattern($oP0, $UIA_ValuePatternId) if _UIA_IsElement($tPattern) Then $tPattern.setValue("") EndIf or try the other IUIWrapper actions a."setValue using keys" b."setValue using clipboard" c."sendkeys", "enterstring", "type", "typetext" its a little hard to say how to send empty string to be entered as it differs per textbox class what works best but as you are able to type text a 1. select all with ^a 2. delete with {delete} see send command in helpfile Herb191 1 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
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