DaveIdito
DaveIdito

Reputation: 1606

Is it possible to interact with GUI-based desktop applications using Python, and how?

I plan to write a service for my *nix systems that can interact with a select number of GUI applications like Photoshop, Libre Office, etc. on the local machine.

The purpose for the local service is essentially to listen to a remote message and accordingly perform specific operations- for instance, changing the background of a layer in Photoshop, or adding margins to a page in Libre Office (or MS Office). You can assume that the application is active in the display environment of the operating system.

Now my question is:

  1. Is this even possible? I personally find this task impossible unless I get to peek into the source code of these apps and basically augment these applications themselves. But since they are mostly proprietary apps, there are legal implications too.
  2. Assuming it is somehow possible by changing the source of these apps, won't a team have to figure out the architecture and the inner workings of all these specifi applications or are there general frameworks concepts I should look into?

Upvotes: 0

Views: 119

Answers (1)

Eugene Astafiev
Eugene Astafiev

Reputation: 49395

The UI should be updated from the main thread only. Or just consider sending Windows messages out.

The purpose for the local service is essentially to listen to a remote message and accordingly perform specific operations

Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. Read more about that in the Considerations for server-side Automation of Office article.

Upvotes: 1

Related Questions