sending commands from python to UI(32byte)

Viewed 24

Hey guys I need help with building python script, I am working on windows with python 3.9 64 bytes. I need to send some commands to a UI on my PC for example "status?".In that UI there is a space where you can pass commands manually but I want to do it via python where I can type all the commands at once and send them directly to that UI and get Output.

2 Answers

For GUI automation, there are specially designed modules or libraries in Python. There are many out there, each with their pros and cons, good and bad sides.

I would recommend you to research PyAutoGUI or autogui and see which one fits your needs the best, the second one being more simpler to use.

E.g. this code would open Notepad and write to it automatically using autogui module.

from autogui import *
open("notepad")
click("File")
click("Text Editor")
write("This is AutoGui ","Text Editor")
append(" writing, appending, and sending keys is easy!","Text Editor")
sendkey("{ENTER}")
read("Text Editor")
close()

There's only two ways (I can think of) to accomplish this:

1.) Using the said UI's API (if it has one) to control it; and 2.) using Python to control the operating system's GUI controls (keyboard, mouse, program window controls). pywin32 is a good Python library for accessing Window's OS API. You'll likely have to do it tediously and sequentially, like move mouse over text area, click, type, etc.

Related