是否有方法在windows powershell中发送鼠标移动?

是否有方法在windows powershell中发送鼠标移动?,powershell,windows-10,mouseevent,Powershell,Windows 10,Mouseevent,我想做一个脚本,自动移动鼠标并发送点击到屏幕上的特定坐标。这主要是为了好玩,但如果有人有任何想法,都会觉得恶心。是的,您可以使用Windows.FormsCursor类,如下所示: #Values are from your set resolution. [Windows.Forms.Cursor]::Position = "2500, 1000" 要获得您的解决方案,您可以使用: $screen = [System.Windows.Forms.SystemInforma

我想做一个脚本,自动移动鼠标并发送点击到屏幕上的特定坐标。这主要是为了好玩,但如果有人有任何想法,都会觉得恶心。

是的,您可以使用
Windows.Forms
Cursor类,如下所示:

#Values are from your set resolution.
[Windows.Forms.Cursor]::Position = "2500, 1000"
要获得您的解决方案,您可以使用:

$screen = [System.Windows.Forms.SystemInformation]::VirtualScreen
$screen.Width
$Screen.Height
或者只是检查一下你的显示设置

您可能必须首先加载.Net类:

Add-Type -AssemblyName System.Windows.Forms
要左键单击,可以导入鼠标事件:请参见:


显然有很多方法可以通过调用windows DLL来实现。它看起来很恶心,所以我不推荐它。然而,有一些方法是相当容易做到的。。。看看AutoIT和它的豪华模块。[grin]您可以使用为此类任务(如或)而设计的脚本工具。
Add-Type -MemberDefinition '[DllImport("user32.dll")] public static extern void mouse_event(int flags, int dx, int dy, int cButtons, int info);' -Name U32 -Namespace W;
[W.U32]::mouse_event(6,0,0,0,0);