模拟按下windows键的powershell代码是什么?

ryoqjall  于 2023-06-23  发布在  Shell
关注(0)|答案(3)|浏览(266)

我试图使一个.ps1程序自动刷新边缘的网站-我也希望它的位置窗口。我需要它来模拟按下Win+RIGHT,但我找不到windows键的代码。

$wshell.SendKeys('{??????}')
hsvhsicv

hsvhsicv1#

就我个人而言,如果我是你,我会使用Autoit powershell模块来完成这项任务。如果您下载了zip文件,您需要将zip文件中的目录“install\AutoitX”解压缩到计算机上的某个位置。当然,在此之前一定要先解除对zip文件的阻止。然后,导入autoit powershell模块,您可以使用以下代码发送emulate按下您提到的键:

Initialize-AU3
Send-AU3Key -Key "#{RIGHT}" -Mode 0
csga3l58

csga3l582#

用于Windows密钥的SendKeys的密钥绑定如下:

# Activating the Windows Key
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.SendKeys]::SendWait('^{ESC}')
gkl3eglg

gkl3eglg3#

AutoIt响应按预期工作,因为SendKeys能够按Windows键,但不能按windowskey +另一个键。
下载AutoIt zip并将AutoItX文件夹保存到永久位置:
https://www.autoitscript.com/site/autoit/downloads/
按windowskey + e的示例代码:

Import-Module "C:\Path\AutoItX\AutoItX.psd1"

Initialize-AU3

Send-AU3Key -Key "{LWINDOWN}e{LWINUP}" -Mode 0

(我会把这个作为对现有AutoIt答案的评论,但我还没有50的声誉,对不起)

相关问题