Ahh.. Ok. Yes I've done this in the past - again in VB on windows. I had to find the process ID of the window I was looking for and use a windows API function to activate that window, then the vb.net sendkeys() function to send individual keystrokes to the app. Not sure if you can apply the same thing on linux or not, but here's what I did:
Private Function FindApp() As Int32
' Loop through process table, return process id of process named 'Notepad.exe'
Dim proptr() As Process
Dim Pid As Process
proptr = Process.GetProcesses() ' Get an array filled with all process IDs
For Each Pid In proptr
Try
If Pid.MainModule.ModuleName = "Notepad.EXE" Then
Return Pid.Id ' Notepad found, return process ID
End If
Catch ex As System.ComponentModel.Win32Exception
Catch ex As InvalidOperationException
End Try
Next
End Function
Private Function ActivateApp() As Boolean
' Gives Notepad focus to receive HID keys
Dim AppID as integer = FindAPP()
If AppID <> 0 Then ' We found our application!
AppActivate(AppID)
Return True
Else : Return False ' Not running??
End If
End Function
To use:
ActivateApp()
SendKeys.SendWait("Keys to appear in notepad...")