Jump to content

ControlClick with Sub (Child?) Windows


Recommended Posts

Hello all. Just started using AutoIt yesterday for an automation project and I have a few questions.

The object of this project is basically just to click/send keystrokes to this program while minimized and keep a GUI in focus. I have the keystrokes down, but am having some trouble with the ControlClick function. I think it has something to do with the fact that I'm dealing with sub-windows (or children?).

Here is my code:

Opt("WinTitleMatchMode", 2)
Opt("MouseCoordMode", 1)
Opt("WinSearchChildren", 1)

GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
        ExitLoop
        
    Case $Button1
        Run("c:\program files\somat\infield\infield.exe", "", @SW_MINIMIZE)
        Sleep(7500)
        ControlSend("So", "", "", "!t")
        ControlSend("So", "", "", "{ENTER}")
        Sleep(1000)
        ControlSend("So", "", "","^O")
        Sleep(1000)
        ControlSend("So", "", "","{ENTER}")
        Sleep(3000)
        ControlClick("Te", "", "[CLASS:msvb_lib_toolbar; INSTANCE:1", "left", 1, 161, 43)

There is more but it doesn't matter...

And here is some detail of the program I'm trying to ControlClick on - I think the problem is arising here...

Posted Image

Posted Image

Posted Image

There are three different sub windows and I'm not sure which one to choose to click one of those buttons on the toolbar (in the Test... window). On top of that, it is a sub-window of the "SoMat..." window.

Here are the screenshots. I appreciate any advice. Oh and it's probably worth noting I ran through the ControlClick in another program (notepad) to make sure I could do it first... still no luck here.

Edited by asd14v
Link to comment
Share on other sites

Hello all. Just started using AutoIt yesterday for an automation project and I have a few questions.

The object of this project is basically just to click/send keystrokes to this program while minimized and keep a GUI in focus. I have the keystrokes down, but am having some trouble with the ControlClick function. I think it has something to do with the fact that I'm dealing with sub-windows (or children?).

Here is my code:

Opt("WinTitleMatchMode", 2)
     Opt("MouseCoordMode", 1)
     Opt("WinSearchChildren", 1)
     
     GUISetState()
     
     While 1
         $nMsg = GUIGetMsg()
         Switch $nMsg
         Case $GUI_EVENT_CLOSE
             ExitLoop
             
         Case $Button1
             Run("c:\program files\somat\infield\infield.exe", "", @SW_MINIMIZE)
             Sleep(7500)
             ControlSend("So", "", "", "!t")
             ControlSend("So", "", "", "{ENTER}")
             Sleep(1000)
             ControlSend("So", "", "","^O")
             Sleep(1000)
             ControlSend("So", "", "","{ENTER}")
             Sleep(3000)
             ControlClick("Te", "", "[CLASS:msvb_lib_toolbar; INSTANCE:1", "left", 1, 161, 43)

There is more but it doesn't matter...

And here is some detail of the program I'm trying to ControlClick on - I think the problem is arising here...

There are three different sub windows and I'm not sure which one to choose to click one of those buttons on the toolbar (in the Test... window). On top of that, it is a sub-window of the "SoMat..." window.

Here are the screenshots. I appreciate any advice. Oh and it's probably worth noting I ran through the ControlClick in another program (notepad) to make sure I could do it first... still no luck here.

Instead of :-

ControlClick("Te", "", "[CLASS:msvb_lib_toolbar; INSTANCE:1", "left", 1, 161, 43)

which is missing a closing square bracket, try:-

ControlClick("SoMat ", "", "msvb_lib_toolbar1", "left", 1, 161, 43)

From the image of the "Window Info" tool, the Basic Window info - Title is "SoMat InField ...", and the ControlClick() function accepts the ClassnameNN as a controlID parameter, as entered above. Although your controlID parameter is acceptable with a closing bracket. I believe the problem is with the wrong window title parameter.

This may help. There can always be other problem issues.

I am also assuming when you took the screen-shot, the cursor was over the control you needed to control click, and the Window Info window is relevant.

Welcome to the forums.

Link to comment
Share on other sites

Oh awesome I got it to work. It's weird I thought I had tried all of the combinatios of the window names (SoMat, Test...) with all of the combinations of classes/instances. But I just started with a clean slate and the msvb_lib_toolbar1 that you suggested worked!! I can't even tell you how relieved I am. I greatly appreciate your effort - it saved the day!

edit: I nominated to use handles to get to the window after learning about them via help. It's weird though, that shouldn't have made a difference. Strange. Can't complain though.

Edited by asd14v
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

  • Recently Browsing   0 members

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