【问题标题】:How to use cx_freeze with pyautoit?如何将 cx_freeze 与 pyautoit 一起使用?
【发布时间】:2015-06-13 10:11:31
【问题描述】:

我想从我的使用“pyautoit”模块的 Windows 应用程序创建一个 cx_freeze 可执行文件。

pip install -U pyautoit

这是我的示例代码:

ma​​in.py

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")

setup.py

import sys
from cx_Freeze import setup, Executable

build_exe_options = {
    "packages": ["autoit"],
    "excludes": []
}

base = None
if sys.platform == "win32":
    base = "Win32GUI"

setup(
    name = "AutoItSample",
    version = "0.1",
    description = "Automate Notepad Editor",
    options = {"build_exe": build_exe_options},
    executables = [Executable("main.py", base=base)],
)

我在我的项目文件夹中使用此命令创建了构建。

python setup.py build

此模块使用模块文件夹中包含的 .dll 文件。

autoit
    lib
        AutoItX3.dll
    autoit.py
    ...

但是 cx_freeze 不包括 library.zip 存档中的这个 .dll。
我尝试在 library.zip 存档中手动包含 lib 文件夹。
但是我遇到了同样的错误。

http://pix.toile-libre.org/upload/original/1428496271.png

我应该怎么做才能让它工作?

【问题讨论】:

    标签: python windows autoit cx-freeze


    【解决方案1】:

    尝试在 setup.py 文件中使用 zip_includes 选项:

    import sys
    from cx_Freeze import setup, Executable
    
    build_exe_options = {
        "packages": ["autoit"],
        "excludes": [],
        "zip_includes": ['AutoITX3.dll']
    }
    
    base = None
    if sys.platform == "win32":
        base = "Win32GUI"
    
    setup(
        name = "AutoItSample",
        version = "0.1",
        description = "Automate Notepad Editor",
        options = {"build_exe": build_exe_options},
        executables = [Executable("main.py", base=base)],
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-30
      • 2017-04-08
      • 2019-09-15
      相关资源
      最近更新 更多