我正在尝试修改 File > Print Setup 下的 Print Setup 选项。
我正在使用带有 Python 的 Windows 脚本宿主。我使用 Alt + F 后跟 S 打开相应的对话框:
当我手动执行这些命令时,“打印设置”框处于焦点位置,因此我可以按 F 选择“打印到文件”,然后按 {ENTER} 或O 接受更改。
但是,ALT+F 和 F 都没有选择"file"选项。
shell = win32com.client.Dispatch("WScript.Shell")
shell.AppActivate('Point of Sale')
shell.SendKeys("%fs") # I also tried "%fsf and "%fs%f" removing the other call to SendKeys"
time.sleep(0.1) # Removing this (or using a longer wait) makes no difference
shell.SendKeys("F")
请您参考如下方法:
您必须等待对话框出现才能发送“F”。
试试这个:
shell.SendKeys("%fs")
time.sleep(.25)
shell.SendKeys("f")
