2

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

shal
  • 21
  • 1
  • 2
  • What does not work? Please copy/past the error message you get – Billal Begueradj Apr 24 '16 at 05:42
  • @BillalBEGUERADJ when i am running this script on command prompt is shows error - pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147024894), None) don't know how to resolve it – shal Apr 24 '16 at 05:49
  • @shal: Please add any clarifications _directly to your question_. – mklement0 Dec 01 '16 at 23:11

1 Answers1

0

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! :)