Jump to content

How to call 'AU3_WinGetTitle' by using ctyes in python?


jacexh
 Share

Recommended Posts

Hi all,

I'm trying to use ctypes to call the interfaces in AutoItX.

e.g.  Call AU3_WinGetText:

import ctypes

from ctypes.wintypes import *

AUTOIT = ctypes.windll.LoadLibrary("AutoItX3.dll")


def win_get_title(title, text="", buf_size=200):
    AUTOIT.AU3_WinGetTitle.argtypes = (LPCWSTR, LPCWSTR, LPWSTR, INT)
    AUTOIT.AU3_WinGetTitle.restypes = None
    rec_text = LPWSTR()
    AUTOIT.AU3_WinGetTitle(LPCWSTR(title), LPCWSTR(text),
                           ctypes.cast(ctypes.byref(rec_text), LPWSTR),
                           INT(buf_size))
    res = rec_text.value
    return res

print win_get_title("[CLASS:Notepad]")

 

I'm getting a ValueError when execute these codes.

res = rec_text.value

ValueError: invalid string pointer 0x680765E0

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