<p>我试图修改<code>File > Print Setup.</code>下的打印设置选项</p>
<p>我正在使用Windows脚本主机与Python。我用<code>Alt + F</code>后跟<code>S</code>打开相应的对话框:</p>
<p><img src="https://i.stack.imgur.com/01RSI.png" alt="Print Setup"/></p>
<p>当我手动执行这些命令时,打印设置框处于焦点位置,因此我可以按<code>F</code>选择“打印到文件”,然后<code>{ENTER}</code>或{<cd6>}接受更改。在</p>
<p>但是,<code>ALT+F</code>和<code>F</code>都没有选择文件选项。在</p>
<pre><code>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")
</code></pre>