Jump to content

Window resisting automation

Recommended Posts

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]", "")

$Error = ControlSetText($Winhandle, "", "[CLASS:WindowsForms10.EDIT.app.0.33c0d9d; INSTANCE:1]", "12345")

MsgBox(0, "", $Error)

From Window Tool:

>>>> Window <<<<
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
Edited by Herb191
Link to comment
Share on other sites

Do you also got an empty field in the windows process list ?

or even in task manager application list?

Edited 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


 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki

ADO - Wiki


Link to comment
Share on other sites

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.

#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", "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)    
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.33c0d9d", $treescope_children)  

Also, how do you clear an edit box before sending text to it? I tried _UIA_action(".mainwindow", "setvalue", "") with no luck.


Link to comment
Share on other sites

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

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

Link to comment
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...