G
G
giggigi2012-10-19 16:31:47
linux
giggigi, 2012-10-19 16:31:47

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

2 answer(s)
K
ks_ks, 2012-10-20
@ks_ks

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 .

B
BubaVV, 2012-10-20
@BubaVV

Apparently, you will have to detect the OS and / or window manager and use the functions specific to each case

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question