0

I am trying to simulate a mouse click in specific spot while still being able to control the mouse. From my understanding, I can use the library pyautoit with the command control_click to do this.

For example, I want to click at the location (1097, 832), but want to still be using the mouse when this action is occurring.

The only example I have seen using this command in python is in the code below.

import autoit

autoit.run("notepad.exe")
autoit.win_wait_active("[CLASS:Notepad]", 3)
autoit.control_send("[CLASS:Notepad]", "Edit1", "hello world{!}")
autoit.win_close("[CLASS:Notepad]")
autoit.control_click("[Class:#32770]", "Button2")

This is the function from the library

def control_click(title, control, **kwargs):
    """
    :param title:
    :param text:
    :param control:
    :param button:
    :param clicks:
    :param x:
    :param y:
    :return:
    """
    text = kwargs.get("text", "")
    button = kwargs.get("button", "left")
    clicks = kwargs.get("clicks", 1)
    x = kwargs.get("x", INTDEFAULT)
    y = kwargs.get("y", INTDEFAULT)

    ret = AUTO_IT.AU3_ControlClick(LPCWSTR(title), LPCWSTR(text),
                                   LPCWSTR(control), LPCWSTR(button),
                                   INT(clicks), INT(x), INT(y))
    return ret

2 Answers 2

1

control_click does not use the mouse cursor.

mouse_click uses the mouse cursor.

control_click arguments from AutoItX.chm help file are:

"title", "text", "controlID" [, button [, clicks [, x [, y ]]]]

of which the optional argument names align with **kwargs.

PyAutoIt arguments from the library for control_click are:

"title", "control" [, **kwargs]

where **kwargs are optional named arguments.

**kwargs accepts named arguments. i.e. text="some text in the window"

To click in a control, you could use i.e:

autoit.control_click("[CLASS:Notepad]", "Edit1", x=1097, y=832)

In the library, code you posted, the names for **kwargs:

text = kwargs.get("text", "")
button = kwargs.get("button", "left")
clicks = kwargs.get("clicks", 1)
x = kwargs.get("x", INTDEFAULT)
y = kwargs.get("y", INTDEFAULT)

It is stored as a dictionary and the .get method is used to get the value. If you pass text="some text in the window" then text equals some text in the window else will equal an empty string, represented with "" in the library, which is the default.

Sign up to request clarification or add additional context in comments.

Comments

0

Not sure how you can use mouse for two process simultaneously but if you want to use ordinates for click any specific area using python and autoit below is code for your reference.

import autoit

autoit.run("notepad.exe")
autoit.win_wait_active("[CLASS:Notepad]", 3)
autoit.control_send("[CLASS:Notepad]", "Edit1", "hello world{!}")
autoit.win_close("[CLASS:Notepad]")
autoit.mouse_click("left",272,70)

Above code will left click on Don't Save button. If you have autoit installed you can use AutoIt Window info(x86) or AutoIt Window info(x64) to get the complete details of windows objects.

let me know if above answer is helpful or not.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.