junkew Posted May 30, 2012 Posted May 30, 2012 About a year ago I made a UI automation library but still wondering if it cannot be more easily done without usage AutoITObjectAny input on background why below will not work with AutoIT ObjCreate and UIAutomationcore.dll library (W7 32 and 64 bits)Basically I am trying to create1. CUIAutomation object2. As there is normally no registrykey with this UIAutomationCore.DLL the only workaround is to use CLSID (as within C++ we call CoCreateInstanceReferenceshttp://msdn.microsoft.com/en-us/library/windows/desktop/ff384838(v=vs.85).aspxUI Automation API is not having a com object in registry registered and as such also in VBA createobject will not work (needs a progid) as opposed to NEW statementCode sample I tried so far (latest version of AutoIt)expandcollapse popupHotKeySet("{ESC}", "Terminate") ;********** THIS WORKS ******************* ;~ $oExcel = ObjCreate("Excel.Application") ; Create an Excel Object ;~ $oExcel.Visible = 1 ; Let Excel show itself ;~ $oExcel2 = ObjCreate("{00024500-0000-0000-C000-000000000046}") ; Create an Excel Object ;~ $oExcel2.Visible = 1 ; Let Excel show itself ;***************************************** ;********** THIS WORKS NOT *************** $sCLSID_CUIAutomation="{FF48DBA4-60EF-4201-AA87-54103EEF594E}" ; $oCUIAutomation=ObjCreate("{30CBE57D-D9D0-452A-AB13-7AC5AC4825EE}") ; $oCUIAutomation=ObjCreate("{ff48dba4-60ef-4201-aa87-54103eef594e}") ; $oCUIAutomation=ObjCreate("{944DE083-8FB8-45CF-BCB7-C477ACB2F897}") ; $oCUIAutomation=ObjCreate("{FF48DBA4-60EF-4201-AA87-54103EEF594E}") ;~ $oCUIAutomation=ObjCreate("FF48DBA4-60EF-4201-AA87-54103EEF594E") $oCUIAutomation=ObjCreate($sCLSID_CUIAutomation) ;~ Trial when registry keys are added ;~ $oCUIAutomation=ObjCreate("CUIAutomation.Application") ;***************************************** ;~ if isobj($oCUIAutomation) Then ;~ msgbox "Hello cuiautomation" consolewrite($oCUIAutomation.GetRootElement.CurrentClassName) ;~ endIf while True sleep(100) WEnd Func Terminate() Exit 0 EndFunc ;==>Terminate ;***************************************** ;~ Windows Registry Editor Version 5.00 ;~ [HKEY_CLASSES_ROOT\CUIAutomation.Application] ;~ @="Microsoft UI Automation Application" ;~ [HKEY_CLASSES_ROOT\CUIAutomation.Application\CLSID] ;~ @="{FF48DBA4-60EF-4201-AA87-54103EEF594E}" ;~ [HKEY_CLASSES_ROOT\CUIAutomation.Application\CurVer] ;~ @="CUIAutomation.Application.7" ;***************************************** ;~ VBA samples ;~ Works without registry modifications ;~ Sub test() ;~ Dim c As New CUIAutomation ;~ Debug.Print c.GetRootElement.CurrentClassName ;~ End Sub ;~ ;~ Works when registry is modified ;~ Sub test() ;~ Dim c As CUIAutomation ;~ Set c = CreateObject("CUIAutomation.Application") ;~ Debug.Print c.GetRootElement.CurrentClassName ;~ End Sub FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
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