Eryk Sun added the comment:
The GetWindowRect example seems fine, for the most part. The docs don't have to
show it being called. If I were to call it, I'd use GetForegroundWindow to get
a window handle. GetActiveWindow returns the active window attached to the
current thread's message queue,
Berker Peksag added the comment:
Thanks for the report! I've now updated the example to use MessageBoxw.
Eryk, do you find the second example (GetWindowRect) is useful? Can we make it
more usable? Unless I'm missing something, we need to pass the return value of
GetActiveWindow() to make it
Roundup Robot added the comment:
New changeset 11c3d6a8f5fd by Berker Peksag in branch '3.5':
Issue #21903: Update ctypes example to use MessageBoxW
https://hg.python.org/cpython/rev/11c3d6a8f5fd
New changeset 3031e4a95131 by Berker Peksag in branch '3.6':
Issue #21903: Merge from 3.5
New submission from Dan O'Donovan:
There is an example in the ctypes python3 documentation for producing a native
Windows MessageBoxA
https://docs.python.org/3.3/library/ctypes.html#ctypes.PYFUNCTYPE
Try as I might, I cannot get this example to run under python 3 (it is in the
python3
Dan O'Donovan added the comment:
Additional note, this code snippet does work in python 2. There is a note that
all snippets are tested with 'doctest' so I have added the 'tests' tag to this
ticket.
--
components: +Tests
___
Python tracker
Dan O'Donovan added the comment:
Ok, this fail is happening because we're using python3 unicode strings to call
the ANSI MessageBoxA function. A possible fix;
Encode strings before passing the MessageBoxA (ctypes.txt.diff attached)
Alternatively, calls could be made to the unicode MessageBoxW