美好的一天。当Popen调用ssms.exe时,我尝试在SQL Server Mgmt Studio中模拟Enter键失败。我需要编码什么?我显然是一个Python新手。 ***目标是按Enter键以便SSMS将“连接”#34;一旦它发布。如果需要,请查看截图非常感谢。
#! python3
from subprocess import Popen
import pyautogui
import time
import os
import signal
## 1. To open SSMS:
proc = Popen("C:\\Program Files (x86)\\Microsoft SQL Server\\130\\Tools\\Binn\\ManagementStudio\\Ssms.exe", shell=True)
print("After Popen")
proc.wait()
print("After wait")
focus = False
print("After focus")
while (focus == False):
print("In While loop")
focus = pyautogui.PAUSE = 1
pyautogui.FAILSAFE = True
pyautogui.press('enter')
if (focus == True):
break