Jump to content
Sign in to follow this  

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

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

Share this post

Link to post
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
Sign in to follow this  

  • Create New...