Jump to content

Can't do Controlclick X,Y position to another Gui made by AutoIt3


tomua999
 Share

Recommended Posts

I compile this code below to "MyGui.exe"

#include <GUIConstantsEx.au3>
$hWnd = GUICreate('MyGui',600,300)
$a=GUICtrlCreateButton ( "text", 0,0,200,100 )
$b=GUICtrlCreateButton ( "text", 220,0,200,100 )
GUISetState()
 While 1
    Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                    ExitLoop

            Case $a
                    MsgBox('','','a')
            Case $b
                    MsgBox('','','b')
    EndSwitch
WEnd

And I run "MyGui.exe"

After that I write another code like this code below to controlclick to click  X,Y position in MyGui but it can't.

I know [Class:Button;Instance:1]  but I want to click X,Y position on MyGui, and I used button to check if It clicked.

Opt("MouseCoordMode", 2)
Opt("PixelCoordMode", 2)

$cs=WinGetHandle('MyGui')
ControlClick($cs,'','','left',1,319,47)

Link to comment
Share on other sites

Yes there is a few problems with your approach.

1-  As per help file : "Some controls will resist clicking unless they are the active window"

By activating the window, it will work with the current focused control if your position (x/y) is inside to the current control.

2- If you want to click on another control than the current one, you will need to give it focus first.

If you are clicking outside the focused control, it will not work.

3- You are not using the right functions to achieve whatever your goal is.

ps. Please use tags when you post code, as described in the link.

Edited by Nine
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...