简体   繁体   English

Powershell | 将鼠标移动到坐标并单击鼠标左键

[英]Powershell | Move mouse to coordinates and left-click

I am setting up an automated deployment of a very old software.我正在设置一个非常古老的软件的自动部署。 It's so old that there is no silent install option.它太旧了,没有静默安装选项。 I've checked the installer with ProcessExplorer and confirmed there were no silent switches in Strings.我已经使用 ProcessExplorer 检查了安装程序,并确认 Strings 中没有静默开关。 To get around this, I am installing the components manually.为了解决这个问题,我手动安装组件。

My goal is to have my deployment software call a PowerShell script which calls the installer, then moves the mouse to the next button, and goes through the motions as an end-user would.我的目标是让我的部署软件调用 PowerShell 脚本,该脚本调用安装程序,然后将鼠标移动到下一个按钮,并像最终用户一样完成这些动作。 I already have the deployment software performing the preparation steps, and calling the program installer.我已经让部署软件执行准备步骤,并调用程序安装程序。 It will need some wait functions to account for different processing times among different computers.它将需要一些等待函数来解决不同计算机之间的不同处理时间。 And it would need to be able to handle the script being called on computers with different sized screens.并且它需要能够处理在具有不同尺寸屏幕的计算机上调用的脚本。

Is this possible?这可能吗?

As already commented - using a mouse won't be that easy with the requirement to make it work on different computers (screen size...).正如已经评论的那样 - 使用鼠标不会那么容易,因为需要让它在不同的计算机(屏幕尺寸......)上工作。 If PowerShell is required, you might try to use send keys:如果需要 PowerShell,您可以尝试使用发送密钥:

Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.SendKeys]::SendWait("%n{TAB}{ENTER}")

Source: Send Keys in Powershell alt+n {TAB} {ENTER}来源: 发送密钥 Powershell alt+n {TAB} {ENTER}

I know software deployment tools (baramundi for example) might have built-in scripting capabilities to automate something like that, but you can built your own application that helps you with your installation.我知道软件部署工具(例如 baramundi)可能具有内置脚本功能来自动执行类似的操作,但您可以构建自己的应用程序来帮助您完成安装。 With Autoit you can create almost bulletproof installer if your installer is compatible.如果您的安装程序兼容,您可以使用 Autoit 创建几乎无懈可击的安装程序。 Just get Autoit, try if you can use the finder tool within "AutoIt Window Info" (try both x86 and x64).获取 Autoit,尝试是否可以使用“AutoIt Window 信息”中的查找器工具(尝试 x86 和 x64)。 If it can directly "find" your buttons, you need you can wait for that window, and that button and then press it with controlClick function: https://www.autoitscript.com/autoit3/docs/functions/ControlClick.htm如果它可以直接“找到”你的按钮,你需要你可以等待那个window,然后那个按钮用controlClick function按下它: https://www.autoitscript.com/autoit3/docs/functions/ControlClick.htm

Third way - the best solution especially for old software - depending on the installation routine you might build your own installer.第三种方式 - 特别是对于旧软件的最佳解决方案 - 根据您可能构建自己的安装程序的安装例程。 In some cases, copying the necessary folder, files, and registry entries might be enough.在某些情况下,复制必要的文件夹、文件和注册表项可能就足够了。 For other cases you might monitor your installation process with Procmon and do the other things that happen during normal installation.对于其他情况,您可以使用 Procmon 监视安装过程并执行正常安装期间发生的其他事情。 https://learn.microsoft.com/en-us/sysinternals/downloads/procmon Also using Procmon in a try and error deployment might be enough for you. https://learn.microsoft.com/en-us/sysinternals/downloads/procmon在试错部署中使用 Procmon 对您来说可能就足够了。 Just copy the installation from a working client try to start the application, read the error message, and solve that with the help of actions you see that happened/failed in procmom.只需从工作客户端复制安装尝试启动应用程序,阅读错误消息,并借助您在 procmom 中看到发生/失败的操作来解决该问题。

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

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