GithubHelp home page GithubHelp logo

pyautoit's Introduction

PyAutoIt

Python binding for AutoItX3.dll

Installing

If you have pip on your system, you can simply install or upgrade PyAutoIt:

pip install -U pyautoit

Alternately, you can download the source distribution from PyPI, unarchive it, and run:

python setup.py install

Example

  • open notepad
  • type some string into notepad, eg: "hello world"
  • close notepad without saving
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")

pyautoit's People

Contributors

aee11 avatar codehimn avatar jacexh avatar kylekizirian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyautoit's Issues

mouse wont move

Code:

import autoit

listx = list(range(0, 500))
listy = list(range(0, 500))

for x in listx:
    for y in listy:
        autoit.mouse_move(x, y, 9)
        

As the title already says the mouse wont move. No error

control_tree_view command "GetText" return Error when using pyautoit module, return None when using win32com module

Hi Author,

I have the issue to get the HPE Service Manager 9 x86 version control tree view text and it returns Error (pyautoit) (Python x64) or empty string (win32com) while it has no issue to get the same control tree view text in AutoIT. Besides of GetText command, "Expand" is working fine with the same command in both pyautoit and win32com.
Working: autoit.control_tree_view("HPE Service Manager", "SysTreeView321","Expand",extras1="#0")

Both AutoIT and Python are using the same DLL files.

Kindly advice on this.

Thank you

Br,
Yoong Loong

Python Code (pyautoit):
import autoit
sm9_title = "HPE Service Manager"
panel_control = "SysTreeView32"

autoit.control_tree_view(sm9_title, panel_control','GetText',extras1="#0|#0")

output:
Traceback (most recent call last):
File "C:/Python/2018/hpe/hpe.py", line 115, in
hp.open_favorite()
File "C:/Python/2018/hpe/hpe.py", line 75, in open_favorite
c = autoit.control_tree_view(sm9_title,panel_control,'GetText',extras1="#0|#0")
File "C:\Python27\lib\site-packages\pyautoit-0.4-py2.7.egg\autoit\autoit.py", line 80, in wrapper
raise AutoItError(err_msg)
AutoItError: Window/Control could not be found

Python Code (win32com):
import win32com.client

autoit = win32com.client.gencache.EnsureDispatch("AutoItX3.Control")
autoit.WinActivate("HPE Service Manager")
a = autoit.ControlTreeView("HPE Service Manager", "", "SysTreeView321", "GetText", "#0|#0", "")
print repr(a)

output:
u''

AutoIT Code:
$hwnd = WinActivate("HPE Service Manager")
$a = ControlTreeView($hwnd,'','SysTreeView321','GetText','#0')
consolewrite($a & @crlf)

output:
Connection - PROD

pyautoit does not work with pyoxidizer due to reliance on __file__

PyOxidizer is a tool to "compile" python programs into executables (https://github.com/indygreg/PyOxidizer). This tool is kind of similar to pyinstaller, however, it speeds up the startup time of the python programs it compiles by storing the python files and resources in memory during execution. Because of that modules that rely on the optional file variable do not work (see https://pyoxidizer.readthedocs.io/en/v0.6.0/packaging_pitfalls.html).

Would it be possible to follow the advice in that link and remove the reliance on the file variable to find the autoit3x.dll file?

Clicking occasionally fails

In some Direct3D games, when autoit.mouse_click("left", x, y, 1) is used, the mouse has moved to the target coordinate, but the click event does not occur
The game tested is dnf

control_command command param

I am not getting correct command value when using command param with control_command.
Error happens when I am expecting value to be 0 or not visible.

E.g.
control_visibility = autoit.control_command('win_title', 'control_id', 'IsVisible')
print control_visibility

It´s only writing the filename.ext on file manager, not the full path.

Hi!

Im trying to use PyAutoIt to select a file and hit "open", but it is not writing the full path to the file, just the fila nema and extension, and because by default the file manager doesn't start in the directory the file is in, i get an error saying the file doesn't exist.

Can someone help ?

handle = "[CLASS:#32770; TITLE:Open]" autoit.win_wait(handle, 60) autoit.control_set_text(handle, "Edit1", 'C:\\codigos\\TCBot\\LastIdeaCropped.png') autoit.control_click(handle, "Button1")

image

control click not working on LDPlayer?

i am trying out with this piece of code
autoit.control_click('LDPlayer(64)', '[CLASS:subWin; INSTANCE:1]', button='left', x=87, y=820)

when i ran it, no errors found but is not clicking at the coords. I am not sure what is happening since no error?

AutoIt Options

Please provide an example how to change AutoIt options (_Options object) without hardcoding values in imported library.

WinList?

Is there an implementation of WinList in here? I can't seem to find it...

How to automate mouse click in (x,y) coordinates using pyautoit?

Using pyautoit, I am trying to click my mouse LEFT button, 2 times, in the (x=890 and y=574) coordinates.

I have tried the below codes or options:

OPTIONS 1:

autoit.mouse_click(" 'left', 890, 574, 2")
    sleep(2)

OPTIONS 1:

autoit.mouse_click(" left, 890, 574, 2")
    sleep(2)

OPTIONS 1:

autoit.mouse_click(" $MOUSE_CLICK_LEFT, 890, 574, 2")
    sleep(2)

But no success.

How to do this, any idea?

win_wait_active

Could you please edit "win_wait_active" in win.py with 3 parameters
title, text, and time out?. The original one have only two parameters title and time out. Thanks

Cannot install

from autoit import AUTO_IT

Cannot import name AUTO_IT

v0.6.4 missing lib

Updated pyautoit to 0.6.4 and lib folder is missing from the package:

python -m pip install --upgrade pyautoit

Reverting back to 0.6.0 and the lib folder is back

python -m pip install --upgrade pyautoit==0.6.0

E KeyError: 'PROGRAMFILES'

Hi,

I understand that pyautoit = 0.4, requires python 32-bit. So, accordingly I installed python 3.6.5 (32-bit) and create virtual environment to start working with the project. Pyautoit was installed and everything worked fine.

However, my project needs to be integrated with Jenkins, so I have started using tox.

Upon using the tox, i'm facing an error only for this particular package pyauotoit. Could you please help us understand what does this error mean and what might be the suitable solution for this please?

Error messages
tox

tox.ini file
tox_ini

Vinodkumar

no way to set/get environment variables

The EnvSet and EnvGet methods are not implemented.

I tried to implement them, e.g.:

@api.check(1, "set environment variable failed")
def env_set(variable, value=None):
    """

    :param filename:
    :param work_dir:
    :param show_flag:
    :return:
    """
    if value is None:
        ret = AUTO_IT.AU3_EnvSet(LPCWSTR(variable))
    else:
        ret = AUTO_IT.AU3_EnvSet(LPCWSTR(variable), LPCWSTR(value))
    return ret

see b2611d4, but it seems like they're not included in the DLL:

AttributeError: function 'AU3_EnvSet' not found

Unsure on how to move forward with this.

ToolTip

Is ToolTip supported currently? I noticed that ControlSend was changed to Control_Send. I attempted this with Tool_Tip with no avail. Thanks.

control_click() takes exactly 2 arguments

Control click takes two arguments yet the docstring implies otherwise:

In [2]: autoit.control_click?
Type:        function
String form: <function control_click at 0x031C40B0>
File:        c:\python27\lib\site-packages\autoit\autoit.py
Definition:  autoit.control_click(*args, **kwargs)
Docstring:
:param title:
:param text:
:param control:
:param button:
:param clicks:
:param x:
:param y:
:return:

Came accross trying to right click on something.

WindowsError: [Error 193] %1 is not a valid Win32 application

Hi have a win10 64bit, same error on python 2.7.14 and 6.3.6:

d:\autoit
λ uname -a
MSYS_NT-10.0 MB-PC 2.6.0(0.304/5/3) 2016-09-09 09:46 x86_64 Msys

d:\autoit
λ pip install pyautoit
Collecting pyautoit
  Using cached PyAutoIt-0.4.zip
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\users\morten~1.sen\appdata\local\temp\pip-build-zespsl\pyautoit\setup.py", line 9, in <module>
        import autoit
      File "autoit\__init__.py", line 6, in <module>
        from .autoit import options, properties, commands
      File "autoit\autoit.py", line 28, in <module>
        AUTO_IT = ctypes.windll.LoadLibrary(dll_path)
      File "c:\dist\python27\lib\ctypes\__init__.py", line 444, in LoadLibrary
        return self._dlltype(name)
      File "c:\dist\python27\lib\ctypes\__init__.py", line 366, in __init__
        self._handle = _dlopen(self._name, mode)
    WindowsError: [Error 193] %1 is not a valid Win32 application

Any help very apperciated. This is supposed to be a standalone docker container in Azure which means it must be win10 or win2016.

Thanks, MortenB, Oslo, Norway

AutoIT control_click not working

Traceback (most recent call last):
File "rough.py", line 7, in
autoit.control_click("[Class:Notepad]", "Button2")
File "C:\Program Files (x86)\Python36-32\lib\site-packages\autoit\autoit.py", line 84, in wrapper
raise AutoItError(err_msg)
autoit.autoit.AutoItError: send click message failed

Does not detect the windows

image

Upload windows after clicking "Upload Picture" in Instagram:

image

import autoit
from time import sleep

autoit.win_wait_active("Abrir", 5)
autoit.control_focus("Abrir", 1148)
sleep(2)
autoit.control_set_text("Abrir", 1148, "Text example")

autoit.autoit.AutoItError: timeout on wait for activate window

Any idea? I am running the script while the window is open.

Edit: I ran the same (ignoring the escape controls) code in SciTE editor (autoit scripting language) and works properly:

HotKeySet("^!x", "MyExit")
Local $Text = "C:\Users\Francisco\PycharmProjects\Instagram\Ipod_Touch.jpg"

; Script Start - Add your code below here
WinWaitActive("Abrir", "", 5)


; Set input focus to the edit control of Notepad using the handle returned by WinWait.
ControlFocus("Abrir", "", 1148)

; Wait for 2 seconds.
Sleep(2000)

; Send Text
ControlSetText("Abrir", "", 1148, $Text)

ControlClick("Abrir","", 1)

Func MyExit()
    Exit
EndFunc   ;==>MyExit

control_click and control_send in Bluestacks

Has anyone had any issue with control_click and control_send in Bluestacks?

The following AU3 code works fine:

ControlFocus("BlueStacks", "", "" )
ControlClick("BlueStacks", "", "", "left", 1, 645, 626)
ControlSend("BlueStacks", "", "", "123")

But the python translation of the above code doesn't work:

import autoit

autoit.control_focus("BlueStacks", "") #this works
autoit.control_click("BlueStacks", "", x=615, y=654) #doesn't work, no error message, just doesn't click
autoit.control_send("BlueStacks", "", "123") #doesn't work, no error message, just text doesn't get sent

Also, other control functions such as control_hide and control_show work well.

What does h_ctrl mean?

When I try to operate with handle, I don't understand what the parameter h_ctrl means .

def control_click_by_handle(hwnd, h_ctrl, **kwargs):
    """

    :param handle:
    :param kwargs:
    :return:
    """
    button = kwargs.get("button", "left")
    clicks = kwargs.get("clicks", 1)
    x = kwargs.get("x", INTDEFAULT)
    y = kwargs.get("y", INTDEFAULT)

    ret = AUTO_IT.AU3_ControlClickByHandle(HWND(hwnd), HWND(h_ctrl),
                                           LPCWSTR(button), INT(clicks),
                                           INT(x), INT(y))
    return ret

Cannot Install

C:\Downloads\python\pyautoit-master\pyautoit-master>python setup.py install
Traceback (most recent call last):
File "setup.py", line 9, in
import autoit
File "C:\Downloads\python\pyautoit-master\pyautoit-master\autoit__init__.py", line 6, in
from .autoit import options, properties, commands
File "C:\Downloads\python\pyautoit-master\pyautoit-master\autoit\autoit.py", line 28, in
AUTO_IT = ctypes.windll.LoadLibrary(dll_path)
File "C:\Python27\lib\ctypes__init__.py", line 443, in LoadLibrary
return self.dlltype(name)
File "C:\Python27\lib\ctypes__init
_.py", line 365, in init
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 193] %1 is not a valid Win32 application

C:\Downloads\python\pyautoit-master\pyautoit-master>python
Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

How to go to next action if some condition fails in PyAutoit?

I am using the following pyautoit code to automate the windows app installation.

My requirement is , Script should wait for 30 seconds for a window to appear. If window appears it should raise exception. Else it should go to next action.

Following code raises exception when the window appears. But when window NOT appears its not going to next step. Its throws "AutoItError: timeout on wait for activate window". I don't want to get through this error. Simply its should go to next action.

Code :

if autoit.win_wait_active("[CLASS:TESTINH]", 30) == 0:
    raise Exception("Env is DOWN...!!!")
else:    
    autoit.send("{TAB}")
    autoit.send("{ENTER}")    

Any idea please?

Can not get full administrator rights to run the application

I found the below exception is raised while is_admin() returns 0.

  File "D:/install.py", line 32, in <module>
    autoit.run("erlang_win64_19.0.exe")
  File "C:\Python27\lib\site-packages\autoit\autoit.py", line 80, in wrapper
    raise AutoItError(err_msg)
autoit.autoit.AutoItError: run program failed

But the same issue does not occur if using the original autoit script with requireadmin as below, and i couldn't find the same api in pyautoit. So could you please take a look at this issue?

#RequireAdmin

Run("erlang_win64_19.0.exe")

win_wait_active should mirror autoit

The native version of AutoIt is as follows:
WinWaitActive("titile","text","120")

This is what pyautoit has:
@api.check(2, "timeout on wait for activate window")
def win_wait_active(title, timeout=0, **kwargs):

This makes it hard to map the example in autoit to pyautoit. Besides, **kwargs is a bit overkill in this ?

Installation problem

Win 10
Py 3.7
Virtualenv

I cannot install the package. I've tried pip from eclipse, pip from the command line, and downloading the source files and installing. I've tried into a virtual environment and into the python installation directly. All end with a

OSError: [WinError 193] %1 is not a valid Win32 application

error.

Can you give me some pointers (or is there a double secret probation password).

Thanks,
Den

Please fix installation problem and patch it into new realse.

on 64-bit MAC system pyautoit can not installed. gives error below
sudo pip install pyautoit
The directory '/Users/jineshpatel/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/jineshpatel/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pyautoit
Downloading PyAutoIt-0.4.zip (421kB)
100% |████████████████████████████████| 430kB 2.0MB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/private/tmp/pip-build-91W3Mv/pyautoit/setup.py", line 9, in
import autoit
File "autoit/init.py", line 6, in
from .autoit import options, properties, commands
File "autoit/autoit.py", line 7, in
from ctypes.wintypes import *
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/wintypes.py", line 19, in
class VARIANT_BOOL(_SimpleCData):
ValueError: type 'v' not supported

Please fix and release new version

Cannot Install

I am trying to install this on a Windows 8.1 64 bit system. I have AutoIT installed and have registered the AutoItX3 dll files for both the 32 bit and 64 bit dlls. When I try the python setup.py install or the pip installation method, I am getting the following error:

[Error 193] %1 is not a valid Win32 Application
pyautoit error

Pyautoit Pixel Search

Pixel Search is not seem to work well with python.
[AutoItError: color is not found]
When i tested it with the notepad++ it work fine.
it is same script.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.