ur Posted September 27, 2018 Posted September 27, 2018 An application is there which is created using vc++,mostly mfc. DOn't know the details completely. WHen I try to automate the control clicks for testing the UI. THe below control is not detected. As you can see, during UI operations I can click the elements one by one. But all the elements is selected as a whole set, when I use the Windowinfo tool. How to click this using AutoIT.? Please suggest.
FrancescoDiMuro Posted September 27, 2018 Posted September 27, 2018 @ur Using a combination of Win* functions, ControlGetHandle() and _GUICtrlToolbar_ClickIndex(), you get what you want #include <GuiToolbar.au3> Global $strWinTitle = "new 1 - Notepad++", _ $hdlWinHandle, _ $strNotepadTB = "[CLASS:ToolbarWindow32; INSTANCE:1]", _ $hdlNotepadTB WinWaitActive($strWinTitle) $hdlWinHandle = WinGetHandle($strWinTitle, "") $hdlNotepadTB = ControlGetHandle($hdlWinHandle, "", $strNotepadTB) _GUICtrlToolbar_ClickIndex($hdlNotepadTB, 1) ; It starts from 0, so it will click on "Open..." ur 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
ur Posted September 27, 2018 Author Posted September 27, 2018 Thank you @FrancescoDiMuro I tried the below code at present, by keeping the relative coordinates. $time_out = 100 Func _WinWaitActivate($title,$text,$timeout=$time_out) ;Logging("Waiting for "&$title&":"&$text) $dHandle = WinWait($title,$text,$timeout) if not ($dHandle = 0) then If Not WinActive($title,$text) Then WinActivate($title,$text) WinWaitActive($title,$text,$timeout) Else Logging("Timeout occured while waiting for the window...") Exit EndIf EndFunc ;_WinWaitActivate only,but with returning of GUI window ID Func _WinWaitActivate1($title,$text,$timeout=$time_out);Will Return the window Handler ;Logging("Waiting for "&$title&":"&$text) $dHandle = WinWait($title,$text,$timeout) if not ($dHandle = 0) then If Not WinActive($title,$text) Then WinActivate($title,$text) return WinWaitActive($title,$text,$timeout) Else Logging("Timeout occured while waiting for the window...") Exit EndIf EndFunc $hwd = _WinWaitActivate1("erwin DM","Model Explorer") Send("!tam") $hwd = _WinWaitActivate1("Add-In Manager","Menu Item Details") ControlClick("Add-In Manager","Menu Item Details", "[CLASS:ToolbarWindow32; INSTANCE:1]","left",1,10,14) The coordinates 10,14 are gathered using windowinfo tool. I will test on different resolutions to check whether it is working on all scenarios.
FrancescoDiMuro Posted September 27, 2018 Posted September 27, 2018 @ur Instead of using ControlClick, it is better to use handles and controls to automate stuffs; just because, if you change resolution, or you move your window, you can't use that code. The example I gave you uses only handles and controls from a sample Notepad++ window ( and it does the trick! ) Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
ur Posted September 27, 2018 Author Posted September 27, 2018 Thanks @FrancescoDiMuro I have changed my code as you suggested. It is working. $hwd = _WinWaitActivate1("Add-In Manager","Menu Item Details") $hdlAddNewItem = ControlGetHandle($hwd, "", "[CLASS:ToolbarWindow32; INSTANCE:1]") _GUICtrlToolbar_ClickIndex($hdlAddNewItem, 0)
FrancescoDiMuro Posted September 27, 2018 Posted September 27, 2018 Happy to have helped Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
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