繁体   English   中英

使用powerhsell更改远程计算机的鼠标位置?

[英]Change mouse location of remote computer using powerhsell?

我正在编写一个脚本来更改远程计算机鼠标的位置。 一台或多台计算机将位于同一LAN上,并且每个GPO都启用了远程PS会话/命令。

我让它在我的计算机上工作但是当我尝试远程运行它时它不会移动鼠标。

    Invoke-Command -computername remote computer -ScriptBlock
{
while($true)
{
$rand = Get-Random -Maximum 5 -Minimum -5
   $a = [windows.forms.cursor]::Position.y + $rand
   $b = [windows.forms.cursor]::Position.x + $rand

   [Windows.Forms.Cursor]::Position = "$b, $a"

  Start-sleep -s .5

   $rand = Get-Random -Maximum 5 -Minimum -5
   $a = [windows.forms.cursor]::Position.y - $rand
   $b = [windows.forms.cursor]::Position.x - $rand

  [Windows.Forms.Cursor]::Position = "$b, $a"

   Start-sleep -s .5
}
}

我有一种感觉它可能与system.windows.forms汇编有关,但我不确定是否有解决方案。

在远程会话中,这是不可能的,因为您的会话没有GUI /句柄来操作。

在主机上运行的本地计算机上,您有一个GUI和句柄,因此调用System.Windows.Forms / Cursor。

如果您真的想这样做,可以将其包装到脚本中并使用允许您与桌面交互的工具执行它。

看看PSExec - 使用“-i”参数进行交互。

https://technet.microsoft.com/en-us/sysinternals/bb897553.aspx

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM