Bonjour,
Hier, je ne savait pas trop comment utiliser 'transblack' ou 'transwhite' d'_Imagesearch()... [
http://autoitscript.fr/forum/viewtopic.php?f=3&t=6892]
Aujourd'hui j'ai compris, mais _ImageSearch() ne trouve pas l'image... Il me retourne 0...
Voici comment je m'y prends : (Je vais tout détailler, comme ça vous pourrez mieux m'aider... =D )
Tout d'abord voici mon include :
► Afficher le texte
Code : Tout sélectionner
Func _Imagesearch($file, $x1 = 0, $y1 = 0, $x2 = @DesktopWidth, $y2 = @DesktopHeight, $trans = "transblack", $variation = 60, $runs = 1, $behavior = 1)
If $behavior > 3 Or $behavior < 0 Then $behavior = 1
If $runs < 1 Or $behavior = 0 Then $runs = 1
Dim $aCoords[$runs] = [99999]; just some number to make the _ArrayMax <-> _ArrayMin comparison work on it's first run
$findImage = '*' & $trans & ' ' & '*' & $variation & ' ' & $file & ".bmp"
$dll = DllOpen("ImageSearchDLL32.dll")
While 1
$result = DllCall($dll, "str", "ImageSearch", "int", $x1, "int", $y1, "int", $x2, "int", $y2, "str", $findImage)
If $result[0] = "0" Then
_ArrayPush($aCoords, 0, 1)
Else
_ArrayPush($aCoords, 1, 1)
If $behavior = 1 Then ExitLoop
EndIf
If _ArrayMax($aCoords) == _ArrayMin($aCoords) Then ExitLoop
Sleep(40)
WEnd
DllClose($dll)
If $aCoords[0] = 1 Then
$array = StringSplit($result[0], "|")
Dim $aCoords[5] = [4, Int(Number($array[2])), Int(Number($array[3])), Int(Number($array[2])) + Int(Number($array[4]) / 2), Int(Number($array[3])) + Int(Number($array[5]) / 2)]
Return ($aCoords)
Else
Return (0)
EndIf
EndFunc
J'ai bien mis la ImagesearchDLL32.dll dans les Includes et dans le dossier de mon script (On ne sait jamais)...
Avec un autre script, je redimensionne Dofus (916x759), le déplace en 0, puis je prends un screen :
Ensuite, avec Photoshop, je rogne le screen pour n'avoir que l'image qui m’intéresse et l'enregistre en bmp 32bits (J'ai essayé aussi 16 et 24, ça ne vient pas de la) .... (Dans mon exemple, je prends les coordonnées de la map, mais j'ai essayé avec de nombreuses autres bouts d'image) :

Je place le fichier dans le dossier du script, et j’exécute ce dernier :
#include <Imagesearch.au3>
WinActivate("Over-Loading") ; Il met la fenêtre de Dofus en premier plan
Sleep(1000)
$I = _Imagesearch(@ScriptDIr & "\Test.bmp", 0, 0,) ; Je lui demande de chercher l'image...
;J'ai aussi essayé
;$I = _Imagesearch(@ScriptDIr & "\Test.bmp", 0, 0, @DesktopWidth, @DesktopHeight)
;$I = _Imagesearch(@ScriptDIr & "\Test.bmp", 0, 0, @DesktopWidth, @DesktopHeight, "transwhite")
;$I = _Imagesearch(@ScriptDIr & "\Test.bmp", 0, 0, @DesktopWidth, @DesktopHeight, "transblack")
;$I = _Imagesearch(@ScriptDIr & "\Test.bmp", 0, 0, @DesktopWidth, @DesktopHeight, "transwhite", 60, 5)
;$I = _Imagesearch(@ScriptDIr & "\Test.bmp", 0, 0, @DesktopWidth, @DesktopHeight, "transblack", 60, 5)
If $I <> 0 Then Msgbox(0, "" ,"Image trouvée...")
If $I = 0 Then Msgbox(0, "" ,"Pas d'image...")
Bref il me retourne 0, alors que l'image est bien la.... :
Merci d'avance ! =D