Jump to content

A control is not detected in a menu


ur
 Share

Recommended Posts

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.

image.png.b7b25a3a0bb81772ca7cfc5c50aa4f3d.png

 

How to click this using AutoIT.?

 

Please suggest.

Link to comment
Share on other sites

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

 

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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
 Share

×
×
  • Create New...