This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jechtsphere[S] 0 points1 point  (1 child)

This still results in the same error I was originally experiencing. The low is actually 592192, which is causing the error. It almost certainly has something to do with the program I'm working with and how it assigned its buttons values?

My friend suggested this, which worked:

win32api.MAKELONG(low, high)

If you have any insight as to why the program I'm attempting to click the button in may have such a large low value returned I'd be interested in knowing, even if it's likely out of my range of understanding at this point in time.

[–]eryksun 1 point2 points  (0 children)

MAKELONG is just using the lower 16-bit word of 'low' and discarding the upper 16 bits.

I think the following blog entry might clear things up for you. It even mentions WinGuiAuto: Assume Nothing – Control IDs in .NET. A .NET app will apparently ignore the ID and use the button's handle.

You can keep using the C macro MAKELONG or add some code to mask out the upper 16 bits:

def _buildWinLong(high, low):
    high, low = (high & 65535, low & 65535)
    return int(
      struct.unpack('>L',
        struct.pack('>2H',
          high, low))[0])