'python script to open tera term application and sending keys
I am trying to use Python script to run Tera Term application to open console for Serial port communication and i am sending some commands/keys like {Enter} key on tera term . but my script dosen't work. Heres the script -
import os
import win32com.client
shell = win32com.client.Dispatch("WScript.Shell")
shell.Run("C:\\Program Files (x86)\\teraterm\\ttermpro.exe")
shell.AppActivate("COM1:57600baud - Tera Term VT")
shell.SendKeys("{Enter}")
i am using python2.7 on my windowxp Pc. please help me with this i am new to python . please help me out
Solution 1:[1]
I am not sure if you found an answer or whether you are even working on automating teraterm now, but I did end up finding a way to automate teraterm to some extent.
import os
from pywinauto import application
############ Change path to Teraterm root folder #################################
out=os.getcwd()
print("Current working directory is:", out)
path = os.chdir('C:/Program Files (x86)/teraterm')
out=os.getcwd()
print("Current working directory is:", out)
############ Start Teraterm ###########################
app = application.Application()
app.start("ttermpro.exe")
a=app.windows()[0]
################### Autostart Macro to allow user to select DSC dump script #######################
app.VTWin32.draw_outline()
app.VTWin32.menu_select("Control -> Macro")
This would help autostart teraterm once you run the script of course. The last two lines of the code would autostart macro to load any .ttl script for the user to use.
I still have not come across any way to fill in the connection details automatically though.
Hope this helps! :)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | sandeepan_sen |