Sandy89 Posted November 2, 2016 Share Posted November 2, 2016 I got the below output. $hWindow OK $oUIAutomation OK $oWindow OK $pCondition1 OK $pCondition2 OK $pCondition OK $oPAR OK $oInvoke ERR Perform mouse click Left = 1256 Top = 149 Right = 546 Bottom = 17 $x = 901 $y = 83 with code in post 19, it works fine. is it possible to capture this image and click on the image each time to trigger this text control? Link to comment Share on other sites More sharing options...
LarsJ Posted November 2, 2016 Share Posted November 2, 2016 Oops, Right and bottom is wrong. It's with and height. Proper calculation of x,y: Local $x = $aBoundingRectangle[0] + $aBoundingRectangle[2] / 2 Local $y = $aBoundingRectangle[1] + $aBoundingRectangle[3] / 2 Image: See bottom of post 20. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Sandy89 Posted November 2, 2016 Share Posted November 2, 2016 wow!!! worked so precisely.. thanks for the help LarsJ.. I can complete the remaining parts in the same way. Link to comment Share on other sites More sharing options...
junkew Posted November 2, 2016 Share Posted November 2, 2016 check also the uiwrapper udf as it gives you some indication how to get the screenshot part with actions like "capture","screenshot", "takescreenshot" and makes life a little easier on identifying objects and getting the interfaces of iuiautomation. If you have luck simplespy gives you directly working code example 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...
Sandy89 Posted November 3, 2016 Share Posted November 3, 2016 ok junkew, I will go through that also to make my work easier!! Link to comment Share on other sites More sharing options...
junkew Posted November 5, 2016 Share Posted November 5, 2016 Unfortunately it will not work directly with my uiawrappers. I will check later next week on how to make this wordpad structure with a Ribbon work in a better and smarter way. Tree of a ribbon is a little complexer when I study it with inspect.exe 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...
junkew Posted November 10, 2016 Share Posted November 10, 2016 ;~ *** Standard code maintainable *** #include "UIAWrappers.au3" AutoItSetOption("MustDeclareVars", 1) _UIA_setVar("oP1","Title:=.*WordPad;controltype:=UIA_WindowControlTypeId;class:=WordPadClass") ;Document - WordPad _UIA_setVar("oUIElement","Title:=Afbeelding;controltype:=UIA_SplitButtonControlTypeId;class:=") ;ControlType:=UIA_SplitButtonControlTypeId;classname:=") ;~ Actions split away from logical/technical definition above can come from configfiles _UIA_Action("oP1","highlight") _UIA_action("oUIElement","highlight") ;~_UIA_action("oUIElement","click") Earthshine 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...
Sandy89 Posted January 5, 2017 Share Posted January 5, 2017 (edited) hi, I am using cuiautomation a lot in my projects. and it is really helpful! i came back to the same topic to know more about it. is it possible to check whether a ribbon button is enabled or not using this ? Edited January 5, 2017 by Sandy89 Link to comment Share on other sites More sharing options...
junkew Posted January 5, 2017 Share Posted January 5, 2017 You can see that with simplespy 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...
Sandy89 Posted January 6, 2017 Share Posted January 6, 2017 (edited) Sorry that i didnt explain the situation properly. i have to check whether a button is enabled in webpage. i tried the below code which throw this error. In code, i mentioned this web page address, since i can't share that link. Error: "D:\AutoIT\Tasks\check.au3" (56) : ==> Variable must be of type "Object".: For $oInput In $oInputs For $oInput In $oInputs^ ERROR Code is: #include <IE.au3> #include <MsgBoxConstants.au3> Local $oIE = _IECreate ("https://www.autoitscript.com/forum/topic/170501-how-can-i-click-on-the-ribbon-menu-item/?page=2#comment-1332257") _IELoadWait($oIE) Winactivate ("Timesheet") Local $oInputs = _IETagNameGetCollection($oIE, "button") For $oInput In $oInputs If $oInput.Value = "Approve" Then $approve = $oInput.getAttributeNode ('disabled').NodeValue $approve1 = $approve.Value MsgBox (0, "", $approve1) EndIf Next From Simplespy, i got the following: Mouse position is retrieved 186-271 At least we have an element [Approve][] Having the following values for all properties: Title is: <Approve> Class := <> controltype:= <UIA_ButtonControlTypeId> ,<50000> , (0000C350) *** Parent Information *** Title is: <> Class := <> controltype:= <UIA_DataItemControlTypeId> ,<50029> , (0000C36D) *** Detailed properties of the highlighted element *** UIA_AcceleratorKeyPropertyId := UIA_AccessKeyPropertyId :=Alt+ UIA_AriaPropertiesPropertyId := UIA_AriaRolePropertyId := UIA_AutomationIdPropertyId :=ctl00_ctl00_PlaceHolderMain_PWA_PlaceHolderMain_idApproveBtn_ToolbarButton UIA_BoundingRectanglePropertyId :=161;259;73;20 UIA_ClassNamePropertyId := UIA_ClickablePointPropertyId := UIA_ControllerForPropertyId := UIA_ControlTypePropertyId :=50000 UIA_CulturePropertyId :=0 UIA_DescribedByPropertyId := UIA_DockDockPositionPropertyId :=5 UIA_ExpandCollapseExpandCollapseStatePropertyId :=3 UIA_FlowsToPropertyId := UIA_FrameworkIdPropertyId :=InternetExplorer UIA_GridColumnCountPropertyId :=0 UIA_GridItemColumnPropertyId :=0 UIA_GridItemColumnSpanPropertyId :=1 UIA_GridItemContainingGridPropertyId := UIA_GridItemRowPropertyId :=0 UIA_GridItemRowSpanPropertyId :=1 UIA_GridRowCountPropertyId :=0 UIA_HasKeyboardFocusPropertyId :=False UIA_HelpTextPropertyId :=Approve UIA_IsContentElementPropertyId :=True UIA_IsControlElementPropertyId :=True UIA_IsDataValidForFormPropertyId :=True UIA_IsDockPatternAvailablePropertyId :=False UIA_IsEnabledPropertyId :=False UIA_IsExpandCollapsePatternAvailablePropertyId :=False UIA_IsGridItemPatternAvailablePropertyId :=False UIA_IsGridPatternAvailablePropertyId :=False UIA_IsInvokePatternAvailablePropertyId :=True UIA_IsItemContainerPatternAvailablePropertyId :=False UIA_IsKeyboardFocusablePropertyId :=False UIA_IsLegacyIAccessiblePatternAvailablePropertyId :=True UIA_IsMultipleViewPatternAvailablePropertyId :=False UIA_IsOffscreenPropertyId :=False UIA_IsPasswordPropertyId :=False UIA_IsRangeValuePatternAvailablePropertyId :=False UIA_IsRequiredForFormPropertyId :=False UIA_IsScrollItemPatternAvailablePropertyId :=True UIA_IsScrollPatternAvailablePropertyId :=False UIA_IsSelectionItemPatternAvailablePropertyId :=False UIA_IsSelectionPatternAvailablePropertyId :=False UIA_IsSynchronizedInputPatternAvailablePropertyId :=False UIA_IsTableItemPatternAvailablePropertyId :=False UIA_IsTablePatternAvailablePropertyId :=False UIA_IsTextPatternAvailablePropertyId :=False UIA_IsTogglePatternAvailablePropertyId :=False UIA_IsTransformPatternAvailablePropertyId :=False UIA_IsValuePatternAvailablePropertyId :=False UIA_IsVirtualizedItemPatternAvailablePropertyId :=False UIA_IsWindowPatternAvailablePropertyId :=False UIA_ItemStatusPropertyId := UIA_ItemTypePropertyId := UIA_LabeledByPropertyId := UIA_LegacyIAccessibleChildIdPropertyId :=0 UIA_LegacyIAccessibleDefaultActionPropertyId :=Press UIA_LegacyIAccessibleDescriptionPropertyId :=Approve UIA_LegacyIAccessibleHelpPropertyId :=Approve UIA_LegacyIAccessibleKeyboardShortcutPropertyId :=Alt+ UIA_LegacyIAccessibleNamePropertyId :=Approve UIA_LegacyIAccessibleRolePropertyId :=43 UIA_LegacyIAccessibleSelectionPropertyId := UIA_LegacyIAccessibleStatePropertyId :=1 UIA_LegacyIAccessibleValuePropertyId := UIA_LocalizedControlTypePropertyId :=button UIA_MultipleViewCurrentViewPropertyId :=0 UIA_MultipleViewSupportedViewsPropertyId := UIA_NamePropertyId :=Approve UIA_NativeWindowHandlePropertyId :=0 UIA_OrientationPropertyId :=0 UIA_ProcessIdPropertyId :=14200 UIA_ProviderDescriptionPropertyId :=[pid:14200,hwnd:0x0 Main(parent link):Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)] UIA_RangeValueIsReadOnlyPropertyId :=True UIA_RangeValueLargeChangePropertyId :=0 UIA_RangeValueMaximumPropertyId :=0 UIA_RangeValueMinimumPropertyId :=0 UIA_RangeValueSmallChangePropertyId :=0 UIA_RangeValueValuePropertyId :=0 UIA_RuntimeIdPropertyId :=42;5313858;2;64 UIA_ScrollHorizontallyScrollablePropertyId :=False UIA_ScrollHorizontalScrollPercentPropertyId :=0 UIA_ScrollHorizontalViewSizePropertyId :=100 UIA_ScrollVerticallyScrollablePropertyId :=False UIA_ScrollVerticalScrollPercentPropertyId :=0 UIA_ScrollVerticalViewSizePropertyId :=100 UIA_SelectionCanSelectMultiplePropertyId :=False UIA_SelectionIsSelectionRequiredPropertyId :=False UIA_SelectionselectionPropertyId := UIA_SelectionItemIsSelectedPropertyId :=False UIA_SelectionItemSelectionContainerPropertyId := UIA_TableColumnHeadersPropertyId := UIA_TableItemColumnHeaderItemsPropertyId := UIA_TableRowHeadersPropertyId := UIA_TableRowOrColumnMajorPropertyId :=2 UIA_TableItemRowHeaderItemsPropertyId := UIA_ToggleToggleStatePropertyId :=2 UIA_TransformCanMovePropertyId :=False UIA_TransformCanResizePropertyId :=False UIA_TransformCanRotatePropertyId :=False UIA_ValueIsReadOnlyPropertyId :=True UIA_ValueValuePropertyId := UIA_WindowCanMaximizePropertyId :=False UIA_WindowCanMinimizePropertyId :=False UIA_WindowIsModalPropertyId :=False UIA_WindowIsTopmostPropertyId :=False UIA_WindowWindowInteractionStatePropertyId :=0 UIA_WindowWindowVisualStatePropertyId :=0 Edited January 6, 2017 by Sandy89 Adding info got from simplespy.au3 Link to comment Share on other sites More sharing options...
Sandy89 Posted January 6, 2017 Share Posted January 6, 2017 (edited) how to get value of $UIA_IsEnabledPropertyId from wrapper.au3 into my code? some information ( Title is: <Approve> Class := <> controltype:= <UIA_ButtonControlTypeId> ,<50000> and UIA_AutomationIdPropertyId ) are constant. it would be a simple line of code, but i couldnt figure out it. please help! i tried following code also, but got the error "No property value due to non existing object". am i missing some settings or something? Local $oIE = _IECreate ("https://www.autoitscript.com/forum/topic/170501-how-can-i-click-on-the-ribbon-menu-item/?page=2#comment-1332257") _IELoadWait($oIE) WinWaitActive ("Timesheet Approvals") Winactivate ("Timesheet Approvals") Sleep(6000) Local $oInput = _IEGetObjById ( $oIE, "ctl00_ctl00_PlaceHolderMain_PWA_PlaceHolderMain_idApproveBtn_ToolbarButton") Local $retVal=_UIA_getPropertyValue($oInput, $UIA_IsEnabledPropertyId) Msgbox (0, "", $retVal) Edited January 6, 2017 by Sandy89 remved original link Link to comment Share on other sites More sharing options...
junkew Posted January 6, 2017 Share Posted January 6, 2017 ribbon button and web button are 2 completely different things and as such checking if enabled is also different. If you mix IE.AU3 and CUIAutomation you cannot mix it by getting object with one technology and ask properties with the other. Identify/find element and property validating you should do for 1 object with 1 technology. 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...
Sandy89 Posted January 6, 2017 Share Posted January 6, 2017 (edited) First one is : i have a button in web page whose status has to be retrieved using simplespy. and i want to perform actions based on that. please refer my code in #31. i used cuiautomation for selecting some controls in web page as well. thats why i mixed up techs. sorry for that. Also, i am getting this error often for web pages other than autoitscript.com. ""C:\Program Files (x86)\AutoIt3\Include\IE.au3" (3690) : ==> The requested action with this object has failed.: Local $oTemp = $o_object.document Local $oTemp = $o_object^ ERROR" Do i need to change something? Edited January 6, 2017 by Sandy89 Link to comment Share on other sites More sharing options...
junkew Posted January 6, 2017 Share Posted January 6, 2017 Local $oInput = _IEGetObjById ( $oIE, "ctl00_ctl00_PlaceHolderMain_PWA_PlaceHolderMain_idApproveBtn_ToolbarButton") Local $retVal=_UIA_getPropertyValue($oInput, $UIA_IsEnabledPropertyId) code above is from #31 but thats just mixing the 2 $oInput is from IE.UDF and is not compatible with CUIAutomation stuff. ""C:\Program Files (x86)\AutoIt3\Include\IE.au3" (3690) : ==> The requested action with this object has failed.: Local $oTemp = $o_object.document Local $oTemp = $o_object^ ERROR" above is unclear as you not show how you create $o_object as that normally should refer to an IE object. Could be that you retrieve to quickly the document try first a sleep of few seconds to see if issue dissapears. If it dissapears you can try to wait for .statusready and .busy properties to be in proper state for nicer syncing. 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...
Sandy89 Posted January 9, 2017 Share Posted January 9, 2017 the web page which we need to open can be the required object, right? in this case, this webpage. and then using the code that I mentioned above. Local $oIE = _IECreate ("https://www.autoitscript.com/forum/topic/170501-how-can-i-click-on-the-ribbon-menu-item/?page=2#comment-1332257") As you told: above is unclear as you not show how you create $o_object as that normally should refer to an IE object. Could be that you retrieve to quickly the document try first a sleep of few seconds to see if issue dissapears. If it dissapears you can try to wait for .statusready and .busy properties to be in proper state for nicer syncing I just want to check the status using simplespy and take that result to my current code to proceed. Link to comment Share on other sites More sharing options...
Sandy89 Posted January 9, 2017 Share Posted January 9, 2017 Local $oIE = _IECreate ("http://.........") _IELoadWait($oIE) Sleep(12000) If IsObj($oIE) Then MsgBox($MB_SYSTEMMODAL, "", "The variable is an object") Else MsgBox($MB_SYSTEMMODAL, "", "The variable is not an object") EndIf While 1 If $oIE.readyState = "complete" Or $oIE.readyState = 4 Then ExitLoop Sleep(10) WEnd Local $oInput = _IEGetObjById ( $oIE, "ctl00_ctl00_PlaceHolderMain_PWA_PlaceHolderMain_idApproveBtn_ToolbarButton") Local $retVal=_UIA_getPropertyValue($oInput, $UIA_IsEnabledPropertyId) Msgbox (0, "", $retVal) I tried with more delay also and I checked whether $oIE is an object. when i replaced my IE.au3 in include folder, i am not getting the previous error, instead i am getting the error : "D:\AutoIT\Tasks\check.au3" (56) : ==> The requested action with this object has failed.: If $oIE.readyState = "complete" Or $oIE.readyState = 4 Then ExitLoop If $oIE^ ERROR" now.. it might be a small mistake from my side. Could you pls share the correct IE.au3 file as well? Link to comment Share on other sites More sharing options...
Sandy89 Posted January 9, 2017 Share Posted January 9, 2017 (edited) Hi, Anyone, please help! i am getting these warnings as well. So i am doubting more on the setting or updation of IE.au3 UDF only. Edited January 10, 2017 by Sandy89 warnings attached Link to comment Share on other sites More sharing options...
Sandy89 Posted January 25, 2017 Share Posted January 25, 2017 the below statement has done the required check and it is working. Local $check = _UIA_getPropertyValue($oPAR, $UIA_IsEnabledPropertyId) Link to comment Share on other sites More sharing options...
Autom8 Posted December 6, 2017 Share Posted December 6, 2017 Hi junkew Can we use this framework to test Office applications such as Word? More specifically, I would like to automate clicking on the File backstage menu and ribbon items. Link to comment Share on other sites More sharing options...
junkew Posted December 6, 2017 Share Posted December 6, 2017 Yes you can but word com interface is far more efficient objcreate word.application. i think there is a word.au3 udf around. 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