Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Process windows

2 réponses
Avatar
NicolasP
Bonjour,

J'aimerais, à partir d'un programme python, lancer un executable windows, récupérer le handle sur sa fenetre principale et envoyer des messages pour simuler l'appui sur des touches.
Je pense que c'est possible avec pywin32. Je sais lancer un process. Je sais envoyer des messages à une fenetre (à l'aide de son handle). Mais comment récupérer le handle sur la fenetre principale ?

Nicolas

2 réponses

Avatar
Laurent Pointal
Bonjour,

J'aimerais, à partir d'un programme python, lancer un executable
windows, récupérer le handle sur sa fenetre principale et envoyer des
messages pour simuler l'appui sur des touches.
Je pense que c'est possible avec pywin32. Je sais lancer un process. Je
sais envoyer des messages à une fenetre (à l'aide de son handle). Mais
comment récupérer le handle sur la fenetre principale ?
Nicolas


Peut-être via WMI (en attribut de l'objet correspondant au process) ???

http://tgolden.sc.sabren.com/python/wmi.html
http://tgolden.sc.sabren.com/python/wmi_cookbook.html
http://timgolden.me.uk/python/win32_how_do_i.html

http://smsguys.blogspot.com/2006/08/wmi-introduction.html
http://smsguys.blogspot.com/2006/09/wmi-scripting.html


Sinon, en recherchant python + process + window + handle sur google, on
tombe sur:

http://mail.python.org/pipermail/python-list/2003-March/153917.html
-----------------------------------------------------------
Mark Hammond
Tue, 18 Mar 2003 10:39:10 GMT

* Previous message: Window handle (hwnd) from process or thread info
* Next message: 2 UK Jobs
* Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

Constant wrote:
The Win32 CreateProcess(), including the win32process.CreateProcess(),
function return the following info about the process that it just created:

HANDLE hProcess
HANDLE hThread
DWORD dwProcessId
DWORD dwThreadId

Is it possible to get the window handle (HWND) of the window, that was
created by this process, from these pieces of information?


Use win32api.EnumWindows() to enumerate all top-level windows, then call
win32process.GetWindowThreadProcessId() to see if the process ID for the
hwnd is the window you just created.

Obviously, the process may take some time to create the window, may
create many windows, or may not create one at all.

Mark.
-----------------------------------------------------------

Avatar
NicolasP

Use win32api.EnumWindows() to enumerate all top-level windows, then call
win32process.GetWindowThreadProcessId() to see if the process ID for the
hwnd is the window you just created.

Obviously, the process may take some time to create the window, may
create many windows, or may not create one at all.



Super.

Merci.

Nicolas