Answer the question
In order to leave comments, you need to log in
Python. Best way to cross-platform interact with windows OS
Hello.
I am writing a small useful thing in python, but I ran into problems with working with windows.
My task is to get all titles of open windows.
I really want to not have to install anything under any OS, except for the python itself. Launched - and works.
Because It was originally planned that the script should work under windows, and I started with it. I tried different ways, settled on ctypes.
Everything was fine, but after that I decided to run my script on another computer, with Ubuntu, and this design naturally did not work.
I found another way - gtk)
Under Linux, everything is fine, but under all other operating systems (I had hope for Mac OS) again, it does not work.
Of course, there is an option to write your own method for each OS, but this is somehow not right, probably.
So I decided to ask if there are any standard cross-platform ways to get the titles of all windows?
Thanks in advance :) sorry if I'm asking nonsense, specifically I'm new to python.
Answer the question
In order to leave comments, you need to log in
Oh yes, interacting with the GUI is a good task, but it's still a pain, especially if you need to achieve something more serious than getting window titles. :)
The problem is that each OS has its own system of graphical user interaction (in windows, it seems that Windows api is responsible for this , in nix* it is X windows ) and there cannot be a universal solution in principle.
Try digging into " os HWND"- for Windows, it should be easily obtainable through either pywinauto or win32api. For nix*, I don’t remember. In any case, if this is a low-level interaction, and you don’t want to use third-party libs, then I see the following sequence: first, check for the presence of specific libs, then we try to use their methods from python, having previously figured out how wrappers are written .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question