Hello,
Does someone know how to call a CLI application in Windows with an input field?
As show, I tried calling it with a full string, an array, a byte-encoded input, to no avail.
Thank you.
Does someone know how to call a CLI application in Windows with an input field?
As show, I tried calling it with a full string, an array, a byte-encoded input, to no avail.
Thank you.
import os
import wx
import subprocess
from subprocess import PIPE
#b'Password: Error reading password!\n'
CMD = "app.exe input.txt"
#b'\'"app.exe input.txt"\' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n'
CMD = ["app.exe input.txt"]
#b'Password: Error reading password!\n'
CMD = ["app.exe", "input.txt"]
class MyPanel(wx.Panel):
def __init__(self, parent):
super().__init__(parent)
self.my_text = wx.TextCtrl(self, style=wx.TE_MULTILINE)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.my_text, 1, wx.ALL|wx.EXPAND)
self.SetSizer(sizer)
#prompt for password
dlg = wx.TextEntryDialog(parent, 'Enter password','Password')
if dlg.ShowModal() == wx.ID_OK:
password = dlg.GetValue()
password = password.encode(encoding="utf-8")
print('You entered: %s\n' % password)
dlg.Destroy()
p = subprocess.Popen(CMD, stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=True)
output, error = p.communicate(input=password)
print(error)
print(output)
return
