[英]Powershell [System.Windows.Forms.SendKey], ALT don't work properly
我有 powershell 腳本可以自動執行我正在執行的一些任務。 我們正在使用 Citrix,為了訪問 Citrix 中的應用程序,我使用的是 Selenium。Citrix 中的主要問題是,在 Selenium 單擊它后,我只能使用 SendKeys 在應用程序中實現自動化,因為我實際上看到了一個“遠程”用戶界面。
我的代碼:
Add-Type -AssemblyName System.Windows.Forms
Start-Sleep -Seconds 5
[System.Windows.Forms.SendKeys]::SendWait(" ") ## Space to focus on item
Start-Sleep -Seconds 1
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}") ## Enter to get into Printer Settings UI
Start-Sleep -Seconds 2
[System.Windows.Forms.SendKeys]::SendWait("%") ## ALT to focus on the menu
Start-Sleep -Seconds 1
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}") ## Enter to open the menu
我正在使用 Add-Type 加載 System.Windows.Forms,並使用 [System.Windows.Forms.SendKeys]::SendWait() 到 SendKeys。
我正在使用“Space”(“”)聚焦並使用“{Enter}”進入設置用戶界面,這是有效的..但在新設置用戶界面 window 中,我似乎無法使用 SendKeys 按“ALT”導航到菜單並打開它。
這個問題的奇怪之處在於:
謝謝!
我嘗試使用 VBA AppActivate,但沒有成功。
在 Citrix 中使用 [System.Windows.Forms.SendKeys] class 時出現問題,因為 Citrix 終端服務器無法使用 SendKeys 處理特殊選項卡。 解決方法是下載AutoIT,取出.dll個文件(3個文件)。 然后將其加載到您的 C# 代碼或 Powershell 並使用它。 AutoIT sendkeys 似乎可以與 citrix 終端服務器很好地交互,並且您的自動化可以很好地與 sendkeys 一起工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.