Adyan Posted August 28, 2018 Posted August 28, 2018 (edited) I need to write an AutoIt script which launches a windows application where I need to select a menu item to perform certain functions. I am using AutoIt windows info to identify all the controls. I am able to login to the application but I am not able to click on the menu item of the windows. Please see the screenshot below. AutoIt Info is not able to recognize the menu item individually and maximum I get the control id of the whole menu strip. I have tried the following: 1. Use WinActivate and then MouseClick. It runs fine till the machine is not locked. On a locked machine the script becomes unreliable. 2. Use WinMenuSelectItem to click the menu item but the menu item could not be clicked. 3. Used Windows Inspect to identify control name and tried clicking Control with that name but it did not work. Please suggest what approach can I use to click the control reliably. Edited August 28, 2018 by Adyan
caramen Posted August 28, 2018 Posted August 28, 2018 (edited) Hello, The way to start with is this function : ControlClick Regards. Edited August 28, 2018 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 Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
Adyan Posted August 29, 2018 Author Posted August 29, 2018 @caramen, I tried using ControlClick and I am able to click on the Menu item as below: ControlFocus("[REGEXPTITLE:CHAMP(.*?); CLASS:WindowsForms10.Window.8.app.0.ea7f4a]", "", "[CLASS:WindowsForms10.Window.8.app.0.ea7f4a; INSTANCE:1]") ControlClick("[REGEXPTITLE:CHAMP(.*?); CLASS:WindowsForms10.Window.8.app.0.ea7f4a]", "", "[CLASS:WindowsForms10.Window.8.app.0.ea7f4a; INSTANCE:1]", "Left", 1, 250, 11) But I am stuck on how to click on the submenu (Comms Input Queue...) item. 1. There is no control info available. 2. I cannot use MouseClick because it does not work when my screen is locked. Also my screen won't be active when script runs. 3. WinMenuSelectItem also does not help here. 4. Also I tried sending keystrokes but this also works on an active screen. ControlSend("[REGEXPTITLE:CHAMP(.*?); CLASS:WindowsForms10.Window.8.app.0.ea7f4a]", "", "[CLASS:WindowsForms10.Window.8.app.0.ea7f4a; INSTANCE:1]", "{ALT}{V}{I}", 0) Please see the screenshot below.
caramen Posted August 29, 2018 Posted August 29, 2018 Try use the SimpleSpy tool. It provide sometime more info about the current Control. You can find it here. If you dont success with SimpleSpy you can try an other InfoTool there is some if you search in the forum. 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 Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
jdelaney Posted August 30, 2018 Posted August 30, 2018 (edited) You might get lucky, and the 'Toolbar' tab of the Autoit Window Info tool will be populated when you focus on the control. If it does, then you can use _guictrltoolbar* functions. Edited August 30, 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.
Adyan Posted August 31, 2018 Author Posted August 31, 2018 Toolbar tab is not showing any info. I tried using SimpleSpy tool but no info is displayed for the submenu item. I then used windows inspect tool and I can see some info of the control. But I am not sure how can I still use it to click the submenu item (Comms Input Queue) highlighted above. I have tried the following but it does not click the sub menu item. ControlClick("[REGEXPTITLE:CHAMP(.*?); CLASS:WindowsForms10.Window.8.app.0.ea7f4a]", "", "[Name:View; INSTANCE:1]") ControlClick("[REGEXPTITLE:CHAMP(.*?); CLASS:WindowsForms10.Window.8.app.0.ea7f4a]", "", "[CLASS:WindowsForms10.Window.8.app.0.ea7f4a; Name:Comms Input Queue...]") I tried going through the link below but I am not sure which info I can assimilate to achieve the above objective to click on the submenu. Is there a way to iterate through the menu items and click it. Any info would be of great help.
jdelaney Posted August 31, 2018 Posted August 31, 2018 I meant for the bar itself. the sub toolbar looks like a context window, so you would need to get it's info from the window tab. 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.
Adyan Posted August 31, 2018 Author Posted August 31, 2018 The window tab only gives the class name but I cannot click the control using that info. Also ToolBar does not display any info for main menu and sub menu as well.
Deye Posted September 1, 2018 Posted September 1, 2018 (edited) Hi Adyan, Try Out WinMenuSelectItem: and see if it works with whatever that secret window is Local $hWnd = WinGetHandle("[CLASS:SciTEWindow]") WinMenuSelectItem($hWnd, "", "&Help", "&Help") $hWnd = WinWaitActive("AutoIt Help", "", 3) ControlSetText($hWnd, "", 3003, "WinMenuSelectItem") ControlClick($hWnd, "", 3006, "left", 3) Deye Edited September 1, 2018 by Deye
Adyan Posted September 2, 2018 Author Posted September 2, 2018 @Deye, As I mentioned above, WinMenuSelectItem does not work in this case. I have tried many ways such as: Local $hWnd = WinGetHandle("[REGEXPTITLE:CHAMP(.*?); CLASS:WindowsForms10.Window.8.app.0.ea7f4a]") WinMenuSelectItem($hWnd, "", "&View", "Comms &Input Queue...") But nothing happens. Also I read that WinMenuSelectItem() will only work on standard menus.
Adyan Posted September 4, 2018 Author Posted September 4, 2018 Any other pointers on what approach I can use to be able to click on the control without using WinActivate and MouseClick.
Earthshine Posted September 4, 2018 Posted September 4, 2018 (edited) there is no assimilate with junkew's UDF. You use it or you don't, It's not for the faint at heart though. Simplespy actually generates usable code, Edited September 4, 2018 by Earthshine My resources are limited. You must ask the right questions
junkew Posted September 5, 2018 Posted September 5, 2018 As inspect and simplespy recognize your control you can do the job with IUIAutomation UDF Study the first 10 examples in the udf and you will understand how IUIAutomation works in general Decide if you want to use my wrapper with _UIA_Action("your control identification", "click") Simplespy will give you the base code to do that If you are not doing 3 you will have to understand the following algorithm with IUIAutomation Get main child window from desktop Understand your GUi hierarchy Use the findall function or condition filter of IUIAutomation to get your element Based on the x,y,w,h properties UIA will give you you can move the mouse and click FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
Adyan Posted September 5, 2018 Author Posted September 5, 2018 Thanks @junkew I will follow the steps in detail to solve the issue.
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