gpt4 book ai didi

powershell - 电源外壳 : how to send middle mouse click?

转载 作者:行者123 更新时间:2023-12-01 07:42:19 27 4
gpt4 key购买 nike

如何使用 powershell 脚本发送鼠标中键?
我想要这样的东西:

Add-Type -AssemblyName System.Windows.Forms
[Windows.Forms.SendKeys]::SendWait('{MButton}')

最佳答案

function Click-MouseButton
{
param(
[string]$Button,
[switch]$help)
$HelpInfo = @'

Function : Click-MouseButton
By : John Bartels
Date : 12/16/2012
Purpose : Clicks the Specified Mouse Button
Usage : Click-MouseButton [-Help][-Button x]
where
-Help displays this help
-Button specify the Button You Wish to Click {left, middle, right}

'@

if ($help -or (!$Button))
{
write-host $HelpInfo
return
}
else
{
$signature=@'
[DllImport("user32.dll",CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
'@

$SendMouseClick = Add-Type -memberDefinition $signature -name "Win32MouseEventNew" -namespace Win32Functions -passThru
if($Button -eq "left")
{
$SendMouseClick::mouse_event(0x00000002, 0, 0, 0, 0);
$SendMouseClick::mouse_event(0x00000004, 0, 0, 0, 0);
}
if($Button -eq "right")
{
$SendMouseClick::mouse_event(0x00000008, 0, 0, 0, 0);
$SendMouseClick::mouse_event(0x00000010, 0, 0, 0, 0);
}
if($Button -eq "middle")
{
$SendMouseClick::mouse_event(0x00000020, 0, 0, 0, 0);
$SendMouseClick::mouse_event(0x00000040, 0, 0, 0, 0);
}

}


}

您可以将此函数添加到您的个人资料或其他脚本中,然后您可以使用以下命令调用它:

单击鼠标按钮“中间”

关于powershell - 电源外壳 : how to send middle mouse click?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12125959/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com