From zyork.contribution at gmail.com Mon Oct 10 15:34:43 2022 From: zyork.contribution at gmail.com (Zach York) Date: Mon, 10 Oct 2022 12:34:43 -0700 Subject: [python-win32] Unpredictable behavior of pywin32 on new computer Message-ID: Hello, I have recently upgraded my computer and after upgrading and installing pywin32, I have found the behavior to be extremely unpredictable and in a lot of cases, just wrong. Environment: Python 3.10 (upgraded from python 3.9 on the previous computer) pywin32 304 Windows 10: 19044.2006 My scripts are mostly trying to do some background clicking using PostMessage/SendMessage and window resizing/positioning using MoveWindow. I used to be able to use SendMessage reliably before this computer upgrade, but now it seems like I need a combination of PostMessage + SendMessage to see a click at all). For MoveWindow, the results are entirely unpredictable (window isn't moved at all, window resized and moved to the wrong location, etc). I assume this has to somehow be with my setup and not pywin32, but I am lost on what might be causing this weird behavior. Any insight would be greatly appreciated! Thanks, Zach -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Mon Oct 10 19:41:50 2022 From: timr at probo.com (Tim Roberts) Date: Mon, 10 Oct 2022 16:41:50 -0700 Subject: [python-win32] Unpredictable behavior of pywin32 on new computer In-Reply-To: References: Message-ID: Zach York wrote: > > I have recently upgraded my computer and after upgrading and > installing pywin32, I have found the behavior to be extremely > unpredictable and in a lot of cases, just wrong. > ... > My scripts are mostly trying to do some background clicking using > PostMessage/SendMessage ?and window resizing/positioning using > MoveWindow. I used to be able to use SendMessage reliably before this > computer upgrade, but now it seems like I need a combination of > PostMessage?+ SendMessage to see a click at all). For MoveWindow, the > results are entirely unpredictable (window isn't moved at all, window > resized and moved to the wrong location, etc). > > I assume this has to somehow be with my setup and not pywin32, but I > am lost on what might be causing this weird behavior. Any insight > would be greatly appreciated! If you upgraded your display as well, the problem is probably the display scaling.? Unless you mark your application has being "high DPI aware", Windows will lie to you about pixel locations.? If your display is 3840x2160, but you have scaling set to 200%, your "non-aware" application will be told that the display is 1920x1080, and the pixel coordinates you are sending to other applications will be wrong.? Go read about "high DPI aware" applications.? It's a mess. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3428 bytes Desc: S/MIME Cryptographic Signature URL: From monetclause at cs.com Tue Oct 11 13:10:40 2022 From: monetclause at cs.com (monetclause at cs.com) Date: Tue, 11 Oct 2022 17:10:40 +0000 (UTC) Subject: [python-win32] python-win32 Digest, Vol 232, Issue 1 In-Reply-To: References: Message-ID: <442971881.213068.1665508240061@mail.yahoo.com> I've had my challenges with 3.10 and stayed on 3.9, with good results. Sent from Android On Tue, Oct 11, 2022 at 11:00, python-win32-request at python.org wrote: Send python-win32 mailing list submissions to ??? python-win32 at python.org To subscribe or unsubscribe via the World Wide Web, visit ??? https://mail.python.org/mailman/listinfo/python-win32 or, via email, send a message with subject or body 'help' to ??? python-win32-request at python.org You can reach the person managing the list at ??? python-win32-owner at python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of python-win32 digest..." Today's Topics: ? 1. Unpredictable behavior of pywin32 on new computer (Zach York) ? 2. Re: Unpredictable behavior of pywin32 on new computer ? ? ? (Tim Roberts) ---------------------------------------------------------------------- Message: 1 Date: Mon, 10 Oct 2022 12:34:43 -0700 From: Zach York To: python-win32 at python.org Subject: [python-win32] Unpredictable behavior of pywin32 on new ??? computer Message-ID: ??? Content-Type: text/plain; charset="utf-8" Hello, I have recently upgraded my computer and after upgrading and installing pywin32, I have found the behavior to be extremely unpredictable and in a lot of cases, just wrong. Environment: Python 3.10 (upgraded from python 3.9 on the previous computer) pywin32 304 Windows 10: 19044.2006 My scripts are mostly trying to do some background clicking using PostMessage/SendMessage? and window resizing/positioning using MoveWindow. I used to be able to use SendMessage reliably before this computer upgrade, but now it seems like I need a combination of PostMessage + SendMessage to see a click at all). For MoveWindow, the results are entirely unpredictable (window isn't moved at all, window resized and moved to the wrong location, etc). I assume this has to somehow be with my setup and not pywin32, but I am lost on what might be causing this weird behavior. Any insight would be greatly appreciated! Thanks, Zach -------------- next part -------------- An HTML attachment was scrubbed... URL: ------------------------------ Message: 2 Date: Mon, 10 Oct 2022 16:41:50 -0700 From: Tim Roberts To: python-win32 at python.org Subject: Re: [python-win32] Unpredictable behavior of pywin32 on new ??? computer Message-ID: Content-Type: text/plain; charset="utf-8"; Format="flowed" Zach York wrote: > > I have recently upgraded my computer and after upgrading and > installing pywin32, I have found the behavior to be extremely > unpredictable and in a lot of cases, just wrong. > ... > My scripts are mostly trying to do some background clicking using > PostMessage/SendMessage ?and window resizing/positioning using > MoveWindow. I used to be able to use SendMessage reliably before this > computer upgrade, but now it seems like I need a combination of > PostMessage?+ SendMessage to see a click at all). For MoveWindow, the > results are entirely unpredictable (window isn't moved at all, window > resized and moved to the wrong location, etc). > > I assume this has to somehow be with my setup and not pywin32, but I > am lost on what might be causing this weird behavior. Any insight > would be greatly appreciated! If you upgraded your display as well, the problem is probably the display scaling.? Unless you mark your application has being "high DPI aware", Windows will lie to you about pixel locations.? If your display is 3840x2160, but you have scaling set to 200%, your "non-aware" application will be told that the display is 1920x1080, and the pixel coordinates you are sending to other applications will be wrong.? Go read about "high DPI aware" applications.? It's a mess. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3428 bytes Desc: S/MIME Cryptographic Signature URL: ------------------------------ Subject: Digest Footer _______________________________________________ python-win32 mailing list python-win32 at python.org https://mail.python.org/mailman/listinfo/python-win32 ------------------------------ End of python-win32 Digest, Vol 232, Issue 1 ******************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: From zyork.contribution at gmail.com Tue Oct 11 15:23:11 2022 From: zyork.contribution at gmail.com (Zach York) Date: Tue, 11 Oct 2022 12:23:11 -0700 Subject: [python-win32] Unpredictable behavior of pywin32 on new computer In-Reply-To: References: Message-ID: Interesting, thanks for the quick response. So would a quick way to test this out be to change the scaling to 100% from whatever it's set at? On Mon, Oct 10, 2022 at 4:47 PM Tim Roberts wrote: > Zach York wrote: > > > > I have recently upgraded my computer and after upgrading and > > installing pywin32, I have found the behavior to be extremely > > unpredictable and in a lot of cases, just wrong. > > ... > > My scripts are mostly trying to do some background clicking using > > PostMessage/SendMessage and window resizing/positioning using > > MoveWindow. I used to be able to use SendMessage reliably before this > > computer upgrade, but now it seems like I need a combination of > > PostMessage + SendMessage to see a click at all). For MoveWindow, the > > results are entirely unpredictable (window isn't moved at all, window > > resized and moved to the wrong location, etc). > > > > I assume this has to somehow be with my setup and not pywin32, but I > > am lost on what might be causing this weird behavior. Any insight > > would be greatly appreciated! > > If you upgraded your display as well, the problem is probably the > display scaling. Unless you mark your application has being "high DPI > aware", Windows will lie to you about pixel locations. If your display > is 3840x2160, but you have scaling set to 200%, your "non-aware" > application will be told that the display is 1920x1080, and the pixel > coordinates you are sending to other applications will be wrong. Go > read about "high DPI aware" applications. It's a mess. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Oct 12 00:53:35 2022 From: timr at probo.com (Tim Roberts) Date: Tue, 11 Oct 2022 21:53:35 -0700 Subject: [python-win32] Unpredictable behavior of pywin32 on new computer In-Reply-To: References: Message-ID: On 10/11/22 12:23, Zach York wrote: > Interesting, thanks for the quick response. So would a quick way to > test this out be to change the scaling to 100% from whatever it's set at? That would be an interesting step.? Another thing to try is to call the APIs to make your app "high-DPI aware".? You can do that for one process using this code: ``` from ctypes import windll user32 = windll.user32 user32.SetProcessDPIAware() ``` Or you can use a registry hack: https://stackoverflow.com/questions/43401709/marking-your-python-program-as-high-dpi-aware-seamlessly-windows -- Tim Roberts,timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- An HTML attachment was scrubbed... URL: