最终,我找到了使用Windows Machine通过任何方法运行测试的用户的解决方案。嗯,实现不是用Java编写的,但是您可以很容易地做到。
使用
AutoIt工具。它具有处理窗口的所有功能。这是一个免费工具。
安装AutoIt: http ://www.autoitscript.com/site/autoit/downloads/
打开编辑器并编写以下代码以隐藏任何窗口。
AutoItSetOption("WinTitleMatchMode", 2)WinSetState(“Title Of Your Window”, “”, @SW_HIDE)
要取消隐藏,可以使用下面的代码行。
AutoItSetOption("WinTitleMatchMode", 2)WinSetState(“Title Of Your Window”, “”, @SW_SHOW)
WinTitleMatchMode具有可用于匹配Windows标题的不同选项。
1 = Match the title from the start (default)`2 = Match any substring in the title3 = Exact title match4 = Advanced mode, see Window Titles & Text (Advanced)
因此,我要做的是:我创建了一个小程序的.exe文件,并按如下所示将参数作为命令行参数传递。
Runtime.getRuntime().exec("C:/Diiinnovation/HideNSeek.exe 0 "" + "Mozilla Firefox" + """);在HideNSeek.exe
-我有下面的AutoIt代码:
AutoItSetOption("WinTitleMatchMode", 1)if $CmdLine[0] > 0 Then if $CmdLine[1] == 0 Then WinSetState($CmdLine[2], "", @SW_HIDE) ElseIf $CmdLine[1] == 1 Then WinSetState($CmdLine[2], "", @SW_SHOW) Else EndIf EndIf$CmdLine[]是一个数组,它将具有所有命令行参数…
$CmdLine[0] = number of Parameter$CmdLine[1] = 1st Parameter after Exe Name ...
如果窗口标题中有空格,则必须使用双引号将其作为命令行参数传递,如上。
下面的代码行将执行AutoIt exe,如果我在第一个参数中传递 “ 0” ,则它将隐藏窗口,如果我传递 “ 1”
,则将取消隐藏与标题匹配的窗口。
Runtime.getRuntime().exec("C:/Diiinnovation/HideNSeek.exe 0 "" + "Mozilla Firefox" + """);我希望这能帮到您。谢谢!



