如果" ptyFoo" string包含@ -character,@将不会显示在putty会话中。也是' ^%q'没有工作...有什么建议吗? 终端类型字符串是" xterm"
提前谢谢
def sendToPutty():
handle = win32gui.FindWindow(None,usrPuttyTitle)
shell = win32com.client.Dispatch("WScript.Shell")
shell.SendKeys('%')
win32gui.SetForegroundWindow(handle)
shell.SendKeys(ptyLockCMD + ptyFoo + '{ENTER}')

答案 0 :(得分:0)
我会自己回答。 它现在是pyperclip和pyautogui的混合物。
[..]
# copy the content of ptyFoo into the clipboard
pyperclip.copy(ptyFoo)
[..]
def sendToPutty():
handle = win32gui.FindWindow(None,usrPuttyTitle)
shell = win32com.client.Dispatch("WScript.Shell")
shell.SendKeys('%')
win32gui.SetForegroundWindow(handle)
# get the coordinates of the putty window
rect = win32gui.GetWindowRect(handle)
x = rect[0]
y = rect[1]
# move mouse to the window +55px on x,y
# paste the content from clipboard + enter
pyautogui.moveTo(x+55,y+55)
pyautogui.click(button='right')
pyautogui.press('enter')

适合我和我的条件。