Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 如何在非活动窗口上使用PixelSearch()?_Windows_Pixel_Autoit - Fatal编程技术网

Windows 如何在非活动窗口上使用PixelSearch()?

Windows 如何在非活动窗口上使用PixelSearch()?,windows,pixel,autoit,Windows,Pixel,Autoit,由于$hwnd参数,我假设应该在非活动窗口上工作,但我不能让它这样做。当另一个窗口放在要搜索的窗口前面时,它将失败 我的剧本: $hwnd = WinGetHandle("[CLASS:MSPaintApp]") $Cor = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0x39B6EF, 0, 1, $hwnd) If Not @error Then MouseMove($Cor[0], $Cor[1]) Else MsgB

由于
$hwnd
参数,我假设应该在非活动窗口上工作,但我不能让它这样做。当另一个窗口放在要搜索的窗口前面时,它将失败

我的剧本:

$hwnd = WinGetHandle("[CLASS:MSPaintApp]")
$Cor = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0x39B6EF, 0, 1, $hwnd)
If Not @error Then
    MouseMove($Cor[0], $Cor[1])
Else
    MsgBox(0, "", @error)
EndIf

如何在非活动窗口上执行此操作?

确保要搜索的窗口处于活动状态的简单修复方法(如果我正确阅读了问题)。
WinActive
检查窗口是否处于活动状态,以及是否为0(未处于活动状态)。然后,我们使用
WinActivate
激活窗口

Local $hwnd, $Cor
$hwnd = WinGetHandle("[CLASS:MSPaintApp]")
If WinActive($hwnd) = 0 Then
    WinActivate($hwnd)
EndIf
$Cor = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0x39B6EF, 0, 1, $hwnd)
If Not @error Then
    MouseMove($Cor[0], $Cor[1])
Else
    MsgBox(0, "", @error)
EndIf

我不认为你可以在屏幕上没有显示的东西上使用像素搜索。你的最终目标是什么?当窗口不活动时,您似乎要求搜索某些内容?如果这是正确的,为什么?@JonBecher,是的,甚至它没有显示在屏幕上,比如ControlSend和ControlClick。是否可能?当窗口未激活时,我需要搜索的可能重复项,以便在搜索时执行其他操作。
运行(“MSPaintApp”、“”、@SW_HIDE)
-这将允许您将其隐藏并仍然使用它。@jaqing或通过设置窗口的状态直接使用@SW_HIDE。是
GUISetState
的函数参考。