DazGizmo Posted June 20, 2018 Posted June 20, 2018 Really battling with this one as I cannot get the info of the state of the Checkbox... using and testing many references for "IsChecked" to no avail... Anything I am doing wrong or you can suggest please? Tries: 1. ControlFocus($hWnd, "Material Editor", "[HANDLE:0x00000000000814B4]") ;Fresnel True Send("{+}") 2. ControlCommand($hWnd, "Material Editor", "[CLASSNN:WindowsForms10.BUTTON.app.0.32b818c_r12_ad118]", "IsChecked", "") 3. ControlCommand($hWnd, "Material Editor", "[NAME:FresnelCheckBox]", "IsChecked", "") These work but do the same thing: ControlCommand($hWnd, "Material Editor", "[NAME:FresnelCheckBox]", "Check", "") ;will uncheck if already checked ControlCommand($hWnd, "Material Editor", "[NAME:FresnelCheckBox]", "UnCheck", "") ;will check if already unchecked
Malkey Posted June 20, 2018 Posted June 20, 2018 Try this example. It successfully returned the state of a checkbox in the AutoIt help file. I have modified this script for your needs. #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local $sWinTitle = "Material Editor" ; Tested on "AutoIt Help (v3.3.14.5)" window. WinActivate($sWinTitle, "") WinWaitActive($sWinTitle, "") ;If _IsChecked($sWinTitle, 'Button4') Then ; Again tested on 'Button4' - Under Search tab of AutoIt Help Window. If _IsChecked($sWinTitle, "WindowsForms10.BUTTON.app.0.32b818c_r12_ad118") Then MsgBox(0, "", "The checkbox is checked.") Else MsgBox(0, "", "The checkbox is not checked.") EndIf EndFunc ;==>Example ; Modified from GUICtrlCreateCheckbox function example in AutoIt Help file. Func _IsChecked($sWinTitle, $sControlClassnameNN) ;Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED Return ControlCommand($sWinTitle, "", $sControlClassnameNN, "IsChecked", "") EndFunc ;==>_IsChecked
DazGizmo Posted June 20, 2018 Author Posted June 20, 2018 On 6/20/2018 at 10:50 PM, Malkey said: Try this example. It successfully returned the state of a checkbox in the AutoIt help file. I have modified this script for your needs. #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local $sWinTitle = "Material Editor" ; Tested on "AutoIt Help (v3.3.14.5)" window. WinActivate($sWinTitle, "") WinWaitActive($sWinTitle, "") ;If _IsChecked($sWinTitle, 'Button4') Then ; Again tested on 'Button4' - Under Search tab of AutoIt Help Window. If _IsChecked($sWinTitle, "WindowsForms10.BUTTON.app.0.32b818c_r12_ad118") Then MsgBox(0, "", "The checkbox is checked.") Else MsgBox(0, "", "The checkbox is not checked.") EndIf EndFunc ;==>Example ; Modified from GUICtrlCreateCheckbox function example in AutoIt Help file. Func _IsChecked($sWinTitle, $sControlClassnameNN) ;Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED Return ControlCommand($sWinTitle, "", $sControlClassnameNN, "IsChecked", "") EndFunc ;==>_IsChecked Expand Many Thanks Malkey for your efforts but it is not returning the correct state as it says Not Checked when It is Checked.... Could it be anything to do with the program being 64bit?
jdelaney Posted June 21, 2018 Posted June 21, 2018 (edited) I believe that windowform controls use a type of guid at runtime for the ID and class...you should probably use the name. https://www.autoitscript.com/autoit3/docs/intro/controls.htm [NAME:FresnelCheckBox] Use ControlGetHandle to first get the handle of the control...output that so that you can check that you even have the correct 'button' before even sending it (the handle) to the _IsChecked function. Try this: Func Example() Local $sWinTitle = "Material Editor" $hWin = WinGetHandle($sWinTitle) If Not IsHWnd($hWind) Then MsgBox(1,1,"window does not exist") Return False EndIf WinActivate($hWin) $hControl = ControlGetHandle($hWin,"","[NAME:FresnelCheckBox]") If Not IsHWnd($hControl) Then MsgBox(1,1,"couldn't identify control") Return False EndIf MsgBox(1,1,"Control found with handle=[" & $hControl & "]") If _IsChecked($hWin,$hControl) Then MsgBox(0, "", "The checkbox is checked.") Else MsgBox(0, "", "The checkbox is not checked.") EndIf EndFunc ;==>Example Func _IsChecked($hWindow,$hControl) Return ControlCommand($hWindow,"",$hControl,"IsChecked","") EndFunc ;==>_IsChecked In regards to your 64bit question: no, that does not matter. Edited June 21, 2018 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
DazGizmo Posted June 21, 2018 Author Posted June 21, 2018 On 6/21/2018 at 12:32 AM, jdelaney said: I believe that windowform controls use a type of guid at runtime for the ID and class...you should probably use the name. https://www.autoitscript.com/autoit3/docs/intro/controls.htm [NAME:FresnelCheckBox] Use ControlGetHandle to first get the handle of the control...output that so that you can check that you even have the correct 'button' before even sending it (the handle) to the _IsChecked function. Try this: Func Example() Local $sWinTitle = "Material Editor" $hWin = WinGetHandle($sWinTitle) If Not IsHWnd($hWind) Then MsgBox(1,1,"window does not exist") Return False EndIf WinActivate($hWin) $hControl = ControlGetHandle($hWin,"","[NAME:FresnelCheckBox]") If Not IsHWnd($hControl) Then MsgBox(1,1,"couldn't identify control") Return False EndIf MsgBox(1,1,"Control found with handle=[" & $hControl & "]") If _IsChecked($hWin,$hControl) Then MsgBox(0, "", "The checkbox is checked.") Else MsgBox(0, "", "The checkbox is not checked.") EndIf EndFunc ;==>Example Func _IsChecked($hWindow,$hControl) Return ControlCommand($hWindow,"",$hControl,"IsChecked","") EndFunc ;==>_IsChecked In regards to your 64bit question: no, that does not matter. Expand Thanks for your input but when I run it nothing happens, no msgbox's show up at all... I did change $hWin to $hWind and the Func _IsChecked ($hWindow to $hWind.....
jdelaney Posted June 21, 2018 Posted June 21, 2018 You can't exercise the function without calling it IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
DazGizmo Posted June 21, 2018 Author Posted June 21, 2018 On 6/21/2018 at 7:10 PM, jdelaney said: You can't exercise the function without calling it Expand Okay... sorry forgot that... It's still not reading it correctly... saying it's not checked when it is...
jdelaney Posted June 21, 2018 Posted June 21, 2018 (edited) Did the handle returned match then handle of the control in the spy tool? If they match, then work still needs to be done on _ischecked Edited June 21, 2018 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
DazGizmo Posted June 21, 2018 Author Posted June 21, 2018 On 6/21/2018 at 7:45 PM, jdelaney said: Did the handle returned match then handle of the control in the spy tool? If they match, then work still needs to be done on _ischecked Expand I think they are the same.... not showing as many zero's though:
Danyfirex Posted June 22, 2018 Posted June 22, 2018 I think BM_GETCHECK does not work with Net checkbox. You will need to hanble it with pixel color check. you could do this get a checkbox capture and check color or use pixelgetcolor. Saludos Danysys.com AutoIt... Reveal hidden contents UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
junkew Posted June 22, 2018 Posted June 22, 2018 Check FAQ31 and check with simplespy what you get back. With IUIAutomation you should be able to get state of your checkbox FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
DazGizmo Posted June 22, 2018 Author Posted June 22, 2018 On 6/22/2018 at 3:18 PM, junkew said: Check FAQ31 and check with simplespy what you get back. With IUIAutomation you should be able to get state of your checkbox Expand Yes, I have looked at your SimplySpy...... How would I go about coding the state and using it some pointers would be great... this is what I get running control+W: expandcollapse popuphttps://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/?do=findComment&comment=1156373 At least we have an element title: [Fresnel:] class: [WindowsForms10.BUTTON.app.0.32b818c_r12_ad1] Having the following values for all properties: Title is: <Fresnel:> Class := <WindowsForms10.BUTTON.app.0.32b818c_r12_ad1> controltype:= <UIA_CheckBoxControlTypeId> ,<50002> , (0000C352) 517;544;195;20 *** Parent Information top down *** 11: Title is: <Edit Default Material Selections> Class := <WindowsForms10.Window.8.app.0.32b818c_r12_ad1> controltype:= <UIA_WindowControlTypeId> ,<50032> , (0000C370) 191;147;1538;906 "Title:=Edit Default Material Selections;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1"" 10: Title is: <Material Editor> Class := <WindowsForms10.Window.8.app.0.32b818c_r12_ad1> controltype:= <UIA_WindowControlTypeId> ,<50032> , (0000C370) 482;185;955;830 "Title:=Material Editor;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1"" 9: Title is: <> Class := <WindowsForms10.Window.8.app.0.32b818c_r12_ad1> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 505;230;908;725 "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1"" 8: Title is: <> Class := <WindowsForms10.Window.8.app.0.32b818c_r12_ad1> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 505;230;602;725 "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1"" 7: Title is: <> Class := <WindowsForms10.Window.8.app.0.32b818c_r12_ad1> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 505;230;602;725 "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1"" 6: Title is: <> Class := <WindowsForms10.Window.8.app.0.32b818c_r12_ad1> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 505;230;602;725 "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1"" 5: Title is: <> Class := <WindowsForms10.SysTabControl32.app.0.32b818c_r12_ad1> controltype:= <UIA_TabControlTypeId> ,<50018> , (0000C362) 505;273;602;682 "Title:=;controltype:=UIA_TabControlTypeId;class:=WindowsForms10.SysTabControl32.app.0.32b818c_r12_ad1"" 4: Title is: <Advanced> Class := <WindowsForms10.Window.8.app.0.32b818c_r12_ad1> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 509;297;594;654 "Title:=Advanced;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1"" 3: Title is: <Colour:> Class := <WindowsForms10.Window.8.app.0.32b818c_r12_ad1> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 509;297;594;654 "Title:=Colour:;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1"" 2: Title is: <> Class := <WindowsForms10.Window.8.app.0.32b818c_r12_ad1> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 509;401;594;475 "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1"" 1: Title is: <Specular Settings> Class := <WindowsForms10.Window.8.app.0.32b818c_r12_ad1> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 513;404;203;163 "Title:=Specular Settings;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1"" 0: Title is: <No texture selected.> Class := <WindowsForms10.Window.8.app.0.32b818c_r12_ad1> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 517;421;195;143 "Title:=No texture selected.;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1"" ;~ *** Standard code maintainable *** #include "UIAWrappers.au3" AutoItSetOption("MustDeclareVars", 1) _UIA_setVar("oP1","Title:=Edit Default Material Selections;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1") ;Edit Default Material Selections _UIA_setVar("oP2","Title:=Material Editor;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1") ;Material Editor _UIA_setVar("oP3","Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1") ; _UIA_setVar("oP4","Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1") ; _UIA_setVar("oP5","Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1") ; _UIA_setVar("oP6","Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1") ; _UIA_setVar("oP7","Title:=;controltype:=UIA_TabControlTypeId;class:=WindowsForms10.SysTabControl32.app.0.32b818c_r12_ad1") ; _UIA_setVar("oP8","Title:=Advanced;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1") ;Advanced _UIA_setVar("oP9","Title:=Colour:;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1") ;Colour: _UIA_setVar("oP10","Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1") ; _UIA_setVar("oP11","Title:=Specular Settings;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1") ;Specular Settings _UIA_setVar("oP12","Title:=No texture selected.;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1") ;No texture selected. _UIA_setVar("Fresnel:.mainwindow","title:=Fresnel:;classname:=WindowsForms10.BUTTON.app.0.32b818c_r12_ad1") ;~ Actions split away from logical/technical definition above can come from configfiles ;~_UIA_Action("oP1","highlight") _UIA_Action("oP1","setfocus") ;~_UIA_Action("oP2","highlight") _UIA_Action("oP2","setfocus") ;~_UIA_Action("oP3","highlight") _UIA_Action("oP3","setfocus") ;~_UIA_Action("oP4","highlight") _UIA_Action("oP4","setfocus") ;~_UIA_Action("oP5","highlight") _UIA_Action("oP5","setfocus") ;~_UIA_Action("oP6","highlight") _UIA_Action("oP6","setfocus") ;~_UIA_Action("oP7","highlight") _UIA_Action("oP7","setfocus") ;~_UIA_Action("oP8","highlight") _UIA_Action("oP8","setfocus") ;~_UIA_Action("oP9","highlight") _UIA_Action("oP9","setfocus") ;~_UIA_Action("oP10","highlight") _UIA_Action("oP10","setfocus") ;~_UIA_Action("oP11","highlight") _UIA_Action("oP11","setfocus") ;~_UIA_Action("oP12","highlight") _UIA_Action("oP12","setfocus") _UIA_action("Fresnel:.mainwindow","setfocus") ;~ *** Standard code Flexible*** #include "UIAWrappers.au3" AutoItSetOption("MustDeclareVars", 1) Local $oP11=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Edit Default Material Selections;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1", $treescope_children) _UIA_Action($oP11,"setfocus") Local $oP10=_UIA_getObjectByFindAll($oP11, "Title:=Material Editor;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1", $treescope_children) _UIA_Action($oP10,"setfocus") Local $oP9=_UIA_getObjectByFindAll($oP10, "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1", $treescope_children) _UIA_Action($oP9,"setfocus") Local $oP8=_UIA_getObjectByFindAll($oP9, "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1", $treescope_children) _UIA_Action($oP8,"setfocus") Local $oP7=_UIA_getObjectByFindAll($oP8, "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1", $treescope_children) _UIA_Action($oP7,"setfocus") Local $oP6=_UIA_getObjectByFindAll($oP7, "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1", $treescope_children) _UIA_Action($oP6,"setfocus") Local $oP5=_UIA_getObjectByFindAll($oP6, "Title:=;controltype:=UIA_TabControlTypeId;class:=WindowsForms10.SysTabControl32.app.0.32b818c_r12_ad1", $treescope_children) _UIA_Action($oP5,"setfocus") Local $oP4=_UIA_getObjectByFindAll($oP5, "Title:=Advanced;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1", $treescope_children) _UIA_Action($oP4,"setfocus") Local $oP3=_UIA_getObjectByFindAll($oP4, "Title:=Colour:;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1", $treescope_children) _UIA_Action($oP3,"setfocus") Local $oP2=_UIA_getObjectByFindAll($oP3, "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1", $treescope_children) _UIA_Action($oP2,"setfocus") Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=Specular Settings;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1", $treescope_children) _UIA_Action($oP1,"setfocus") Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=No texture selected.;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.32b818c_r12_ad1", $treescope_children) _UIA_Action($oP0,"setfocus") _UIA_setVar("Fresnel:.mainwindow","title:=Fresnel:;classname:=WindowsForms10.BUTTON.app.0.32b818c_r12_ad1") _UIA_action("Fresnel:.mainwindow","setfocus") *** Detailed properties of the highlighted element *** UIA_title:= <Fresnel:> UIA_text:= <Fresnel:> UIA_regexptitle:= <Fresnel:> UIA_class:= <WindowsForms10.BUTTON.app.0.32b818c_r12_ad1> UIA_regexpclass:= <WindowsForms10.BUTTON.app.0.32b818c_r12_ad1> UIA_iaccessiblechildId:= <0> UIA_id:= <FresnelCheckBox> UIA_handle:= <71774> UIA_RuntimeId:= <42;71774> UIA_BoundingRectangle:= <517;544;195;20> UIA_ProcessId:= <10116> UIA_ControlType:= <50002> UIA_LocalizedControlType:= <check box> UIA_Name:= <Fresnel:> UIA_HasKeyboardFocus:= <False> UIA_IsKeyboardFocusable:= <True> UIA_IsEnabled:= <True> UIA_AutomationId:= <FresnelCheckBox> UIA_ClassName:= <WindowsForms10.BUTTON.app.0.32b818c_r12_ad1> UIA_Culture:= <0> UIA_IsControlElement:= <True> UIA_IsContentElement:= <True> UIA_IsPassword:= <False> UIA_NativeWindowHandle:= <71774> UIA_IsOffscreen:= <False> UIA_Orientation:= <0> UIA_FrameworkId:= <WinForm> UIA_IsRequiredForForm:= <False> UIA_IsDockPatternAvailable:= <False> UIA_IsExpandCollapsePatternAvailable:= <False> UIA_IsGridItemPatternAvailable:= <False> UIA_IsGridPatternAvailable:= <False> UIA_IsInvokePatternAvailable:= <True> UIA_IsMultipleViewPatternAvailable:= <False> UIA_IsRangeValuePatternAvailable:= <False> UIA_IsScrollPatternAvailable:= <False> UIA_IsScrollItemPatternAvailable:= <False> UIA_IsSelectionItemPatternAvailable:= <False> UIA_IsSelectionPatternAvailable:= <False> UIA_IsTablePatternAvailable:= <False> UIA_IsTableItemPatternAvailable:= <False> UIA_IsTextPatternAvailable:= <False> UIA_IsTogglePatternAvailable:= <True> UIA_IsTransformPatternAvailable:= <False> UIA_IsValuePatternAvailable:= <False> UIA_IsWindowPatternAvailable:= <False> UIA_ValueIsReadOnly:= <True> UIA_RangeValueValue:= <0> UIA_RangeValueIsReadOnly:= <True> UIA_RangeValueMinimum:= <0> UIA_RangeValueMaximum:= <0> UIA_RangeValueLargeChange:= <0> UIA_RangeValueSmallChange:= <0> UIA_ScrollHorizontalScrollPercent:= <0> UIA_ScrollHorizontalViewSize:= <100> UIA_ScrollVerticalScrollPercent:= <0> UIA_ScrollVerticalViewSize:= <100> UIA_ScrollHorizontallyScrollable:= <False> UIA_ScrollVerticallyScrollable:= <False> UIA_SelectionCanSelectMultiple:= <False> UIA_SelectionIsSelectionRequired:= <False> UIA_GridRowCount:= <0> UIA_GridColumnCount:= <0> UIA_GridItemRow:= <0> UIA_GridItemColumn:= <0> UIA_GridItemRowSpan:= <1> UIA_GridItemColumnSpan:= <1> UIA_DockDockPosition:= <5> UIA_ExpandCollapseExpandCollapseState:= <3> UIA_MultipleViewCurrentView:= <0> UIA_WindowCanMaximize:= <False> UIA_WindowCanMinimize:= <False> UIA_WindowWindowVisualState:= <0> UIA_WindowWindowInteractionState:= <0> UIA_WindowIsModal:= <False> UIA_WindowIsTopmost:= <False> UIA_SelectionItemIsSelected:= <False> UIA_TableRowOrColumnMajor:= <2> UIA_ToggleToggleState:= <1> UIA_TransformCanMove:= <False> UIA_TransformCanResize:= <False> UIA_TransformCanRotate:= <False> UIA_IsLegacyIAccessiblePatternAvailable:= <True> UIA_LegacyIAccessibleChildId:= <0> UIA_LegacyIAccessibleName:= <Fresnel:> UIA_LegacyIAccessibleRole:= <44> UIA_LegacyIAccessibleState:= <1048592> UIA_LegacyIAccessibleDefaultAction:= <Uncheck> UIA_IsDataValidForForm:= <False> UIA_ProviderDescription:= <[pid:9884,hwnd:0x1185E Main:Nested [pid:10116,hwnd:0x1185E Main(parent link):Microsoft: MSAA Proxy (unmanaged:UIAutomationCore.dll)]; Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]> UIA_IsItemContainerPatternAvailable:= <False> UIA_IsVirtualizedItemPatternAvailable:= <False> UIA_IsSynchronizedInputPatternAvailable:= <False>
DazGizmo Posted June 22, 2018 Author Posted June 22, 2018 On 6/22/2018 at 2:06 PM, Danyfirex said: I think BM_GETCHECK does not work with Net checkbox. You will need to hanble it with pixel color check. you could do this get a checkbox capture and check color or use pixelgetcolor. Saludos Expand Thanks for your input Saludos.... I have read in a few places about grabbing the pixel colour but would rather find a better method if possible...
AdamUL Posted June 22, 2018 Posted June 22, 2018 Check the @error value returned by _IsChecked to make sure the ControlCommand function is not throwing an error. Replace the _IsChecked call with the following. Local $iIsChecked = _IsChecked($hWin, $hControl) Local $iIsCheckedError = @error If $iIsChecked And Not $iIsCheckedError Then MsgBox(0, "", "The checkbox is checked.") ElseIf Not $iIsChecked And Not $iIsCheckedError Then MsgBox(0, "", "The checkbox is not checked.") Else MsgBox(16, "ERROR!", 'Error with ControlCommand "IsChecked"') EndIf Also, when I have had to automate some hard to automate controls to I've use a loop with IsChecked and and UnCheck. Example below. Global $sDialogTitle = "[CLASS:WindowsForms10.Window.8.app.0.32b818c_r12_ad1; TEXT:Material Editor]" Global $sDialogText = "" Global $sControlInfo = "[CLASS:WindowsForms10.BUTTON.app.0.32b818c_r12_ad1; TEXT:Fresnel:]" While ControlCommand($sDialogTitle, $sDialogText, $sControlInfo, "IsChecked", "") ControlCommand($sDialogTitle, $sDialogText, $sControlInfo, "UnCheck", "") WEnd Adam
junkew Posted June 22, 2018 Posted June 22, 2018 You have to put full spy output in your post. But its based on this logic https://docs.microsoft.com/en-us/dotnet/framework/ui-automation/get-the-toggle-state-of-a-check-box-using-ui-automation FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
jdelaney Posted June 22, 2018 Posted June 22, 2018 You can also try the function _guictrlbutton_getchecked IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
shuaua Posted September 24, 2019 Posted September 24, 2019 (edited) The _ChkBoxCommand function below may be helpful. You must first get the relative X and Y coordinates within the control. To do so, you can use this tool:https://github.com/J2TEAM/AutoIt-UDF-Collection/blob/master/UDF/Auto Infor (mini).au3 For more details, see remarks. expandcollapse popup; CHECKBOX COMMAND ================================================================================================= ; Name............: _ChkBoxCommand ; Description ....: Executes a command in a non-standard Windows checkbox, using PixelGetColor and a set of ; auxiliary functions. ; Parameters .....: $title - the title/hWnd/class of the window to access. ; $text - the text of the window to access. ; $controlID - the control to interact with. ; $command - the command to send to the checkbox, "IsChecked", "Check", "UnCheck". ; $xGetPixel - the x position to get pixel within the control. ; $yGetPixel - the y position to get pixel within the control. ; $colorUnchecked: the color of checkbox when is uncheked. ; Remarks ........: The X and Y positions are relative within the control. You must get them beforehand. To do so, ; you can use this tool: ; https://github.com/J2TEAM/AutoIt-UDF-Collection/blob/master/UDF/Auto%20Infor%20(mini).au3 ; Just run the tool above, put the mouse pointer over a pixel when the chekbox is checked and ; write down the ControClick coordinates. This pixel will be compared to $colorUnchecked. ; Since the relative position of a checkbox within the control will probably always be the same in ; the same third party program, no matter the window, you can set a default value to X and Y. ; Author .........: shuaua ; ================================================================================================================== Func _ChkBoxCommand($title, $text, $controlID, $command, $xGetPixel = 8, $yGetPixel = 8, $colorUnchecked = 0xFFFFFF) Switch $command Case "IsChecked" Return _IsCheckedPixel($title, $text, $controlID, $xGetPixel, $yGetPixel, $colorUnchecked) Case "UnCheck" If _IsCheckedPixel($title, $text, $controlID, $xGetPixel, $yGetPixel, $colorUnchecked) Then _ ControlClick($title, $text, $controlID, "primary", 1, $xGetPixel, $yGetPixel) If _IsCheckedPixel($title, $text, $controlID, $xGetPixel, $yGetPixel, $colorUnchecked) Then _ BitAND(ControlFocus($title, $text, $controlID), Send("{SPACE}")) If _IsCheckedPixel($title, $text, $controlID, $xGetPixel, $yGetPixel, $colorUnchecked) Then _ Return 0 Case "Check" If Not _IsCheckedPixel($title, $text, $controlID, $xGetPixel, $yGetPixel, $colorUnchecked) Then _ ControlClick($title, $text, $controlID, "primary", 1, $xGetPixel, $yGetPixel) If Not _IsCheckedPixel($title, $text, $controlID, $xGetPixel, $yGetPixel, $colorUnchecked) Then _ BitAND(ControlFocus($title, $text, $controlID), Send("{SPACE}")) If Not _IsCheckedPixel($title, $text, $controlID, $xGetPixel, $yGetPixel, $colorUnchecked) Then _ Return 0 Case Else Return SetError(1) EndSwitch Return 1 EndFunc ; VERIFIES IF A CHECKBOX IS CHECKED (USING PIXELGETCOLOR) ========================================================== ; Name............: _IsCheckedPixel ; Description ....: Verifies if a checkbox is checked, using PixelGetColor. ; Parameters .....: $title - the title/hWnd/class of the window to access. ; $text - the text of the window to access. ; $controlID - the control to interact with. ; $xGetPixel - the x position to get pixel within the control. ; $yGetPixel - the y position to get pixel within the control. ; $colorUnchecked: the color of checkbox when is uncheked. ; Remarks ........: The X and Y positions are relative within the control. You must get them beforehand. To do so, ; you can use this tool: ; https://github.com/J2TEAM/AutoIt-UDF-Collection/blob/master/UDF/Auto%20Infor%20(mini).au3 ; Just run the tool above, put the mouse pointer over a pixel when the chekbox is checked and ; write down the ControClick coordinates. This pixel will be compared to $colorUnchecked. ; Since the relative position of a checkbox within the control will probably always be the same in ; the same third party program, no matter the window, you can set a default value to X and Y. ; Author .........: shuaua ; ================================================================================================================== Func _IsCheckedPixel($title, $text, $controlID, $xGetPixel = 8, $yGetPixel = 8, $colorUnchecked = 0xFFFFFF) Local $ctrlPos = WinGetPos(ControlGetHandle($title, $text, $controlID)) If Not IsArray($ctrlPos) Then Return SetError(1) Local $pxColor = PixelGetColor($ctrlPos[0]+$xGetPixel, $ctrlPos[1]+$yGetPixel) If $pxColor == $colorUnchecked Then Return False Return True EndFunc Edited July 27, 2020 by shuaua
seadoggie01 Posted September 24, 2019 Posted September 24, 2019 On 6/21/2018 at 12:32 AM, jdelaney said: In regards to your 64bit question: no, that does not matter. Expand (Not that I don't believe you) How do you know, is there a way to tell? I've had issues with controls in a 32-bit program before, and I'd love to know if I was missing something All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Reveal hidden contents My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types
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