Quote:
Originally Posted by Strix333
Ja benutze SciTe.
Habe AutoIt nochmal neu installiert (64x). Jetzt funktioniert es. Naja fast. Es findet die Bilder jetzt, verfehlt diese aber immer um ca eine Icon Größe. Habe einfach einen Teil des Chrome-Icons auf dem Desktop genommen. Mit MouseMove geht er dann aber fast auf das nächste Icon darunter... Wie kann das sein? (Habe es auch mit anderen Icons ausprobiert)
|
That is because scan order, you need a representative image to search for and limit in the area you want it to be found
Here is an example:
Code:
#include "ImageSearch2015.au3"
_ImageSearchStartup()
Global $x= 0,$y = 0
$centerImage = 1; 0 top left corner - 1 center of image
$data = _ImageSearch("test.png",$centerImage,$x,$y,10)
MouseMove($x,$y)
;use to search for images in specific rectangle -> Faster than search entire desktop
; _ImageSearchArea($imgpath,$searchCenter,$xo,$yo,$width,$height,$x,$y,$tolerance)
_ImageSearchShutdown()
Image to search, then we split the image in one of 50x50
[Only registered and activated users can see links. Click Here To Register...]
Lets say we have this
[Only registered and activated users can see links. Click Here To Register...]
Then search order will be like this:
[Only registered and activated users can see links. Click Here To Register...]
As soon as image 1 is not visible, it will find image 2, then if image 1 and 2 aren't visible will find image 3 and so on...
The best you can do to test for same images in the desktop is area search, to test if it is there or not.
[EDIT]
This code should search for all same images in a region, it takes some time for all desktop (8/10 sec)
so if u use a smaller region would be faster
Code:
#include "ImageSearch2015.au3"
#include <Array.au3>
_ImageSearchStartup()
Func SearchAllImagesInARegion($path,$xo,$yo,$width,$height,$imgSize=50)
Local $fx = 0,$fy = 0
$ds = $imgSize * 2
Local $pos[0][2]
For $y = $yo To $width Step $imgSize
For $x = $xo To $height Step $imgSize
$find = _ImageSearchArea($path,1,$x,$y,$x+$ds,$y+$ds,$fx,$fy,10)
If $find <> False Then
ReDim $pos[UBound($pos)+1][2]
$pos[UBound($pos)-1][0] = $fx
$pos[UBound($pos)-1][1] = $fy
EndIf
Next
Next
Return $pos
EndFunc
$images = SearchAllImagesInARegion("test.png",0,0,@DesktopWidth,@DesktopHeight)
MsgBox(0,"Found",ubound($images) &" images")
For $i = 0 To UBound($images)-1
MouseMove($images[$i][0],$images[$i][1])
Sleep(500)
Next
_ImageSearchShutdown()