Jump to content

Recommended Posts

Posted (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.

AutoItCannotClickOnMenu.thumb.jpg.047b1060db88140bcf12d5b92416d67b.jpg

 

Edited by Adyan
Posted (edited)

Hello, 

The way to start with is this function :

ControlClick

 

 

Regards.

Edited 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 - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Posted

@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.

AutoItCannotClickOnSubMenu.thumb.jpg.d507d556228cdeff30aa5824b1371d23.jpg

 

Posted

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 - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Posted (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 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.
Posted

Toolbar tab is not showing any info.

NoDetailInToolbar.thumb.jpg.0d31055d7240164ed0d729db1ef727c5.jpg

 

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...]")

 

3_InspectTool.jpg.4eceb00aa45316724c916ff705dfba4d.jpg

 

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.

 

Posted

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.

4_ClassNameOnly.jpg.2ef48f32ae2b03a0653ee52a93b5b11c.jpg

Posted (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 by Deye
Posted

@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.

Posted

Any other pointers on what approach I can use to be able to click on the control without using WinActivate and MouseClick.

Posted (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 by Earthshine

My resources are limited. You must ask the right questions

 

Posted
  1. As inspect and simplespy recognize your control you can do the job with IUIAutomation UDF
  2. Study the first 10 examples in the udf and you will understand how IUIAutomation works in general
  3. 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
  4. If you are not doing 3 you will have to understand the following algorithm with IUIAutomation
    1. Get main child window from desktop
    2. Understand your GUi hierarchy
    3. Use the findall function or condition filter of IUIAutomation to get your element
    4. Based on the x,y,w,h properties UIA will give you you can move the mouse and click

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...