Maffiagang Posted May 11, 2020 Posted May 11, 2020 (edited) Hey guys, I've been googeling and looking through the forum for a few hours now but to no solution to my question. How would i go about forcing ImageSearch to search in the revers of its normal searching pattern? Now it goes Top > Bottom and Left > Right. I need it to go Bottom > Top and Right > Left Thanks in advance, Maffigang Edited May 11, 2020 by Maffiagang
Aelc Posted May 11, 2020 Posted May 11, 2020 (edited) First entry in google Also you can read it in the Helpfile of Pixelsearch Edited May 11, 2020 by Aelc why do i get garbage when i buy garbage bags?
Maffiagang Posted May 11, 2020 Author Posted May 11, 2020 lol why... I was looking for imagesearch direction, that one never came up for me 0.o Thanks so much.
Maffiagang Posted May 13, 2020 Author Posted May 13, 2020 (edited) So i tried the way you suggested, I made another func for a reverse search, with the coords switched. expandcollapse popupFunc _ImageSearch_Area($_ImagePath, $P_x1 = 0, $P_y1 = 0, $P_x2 = @DesktopWidth, $P_y2 = @DesktopHeight, $_Tolerance = 0, $_CenterPos = True) Local $_Return[3] = [0, 0, 0], $_TempVar, $i $_Return[0] = -1 If (FileExists($_ImagePath) = 0) And (StringInStr($_ImagePath, "|") = 0) Then If $ImageSearch_Debug Then ConsoleWrite("! Image file not found - Can't search !" & @CRLF & "! " & $_ImagePath & @CRLF) Return SetError(-1, 0, $_Return) EndIf If $P_x1 > $P_x2 Then ; change position to default top-left and botton-right $_TempVar = $P_x1 $P_x1 = $P_x2 $P_x2 = $_TempVar EndIf If $P_y1 > $P_y2 Then $_TempVar = $P_y1 $P_y1 = $P_y2 $P_y2 = $_TempVar EndIf Local $_Find_IMG_X, $_Find_IMG = StringSplit($_ImagePath, '|', 2) For $i = 0 To (UBound($_Find_IMG) - 1) Step +1 $_Find_IMG_X = $_Find_IMG[$i] If (FileExists($_Find_IMG_X) = 0) Then If $ImageSearch_Debug Then ConsoleWrite("! Image file not found !" & @CRLF & "! " & $_Find_IMG_X & @CRLF) ContinueLoop EndIf If $_Tolerance > 0 Then $_Find_IMG_X = "*" & $_Tolerance & " " & $_Find_IMG_X If (FileExists($ImageSearchDLL_Path) = 0) Then _ImageSearch_CheckDLL() Local $result = DllCall($ImageSearchDLL_Path, "str", "ImageSearch", "int", $P_x1, "int", $P_y1, "int", $P_x2, "int", $P_y2, "str", $_Find_IMG_X) If Not IsArray($result) Then ; dll not found or other error If $ImageSearch_Debug Then ConsoleWrite("! Dll not found or Call Dll error !" & @CRLF) $_Return[0] = -1 Return SetError(1, 0, $_Return) EndIf If Int($result[0]) = 0 Then ; search not found If $ImageSearch_Debug Then ConsoleWrite("! Search not found !" & @CRLF) $_Return[0] = 0 ContinueLoop Else $_Return[0] = 1 If $ImageSearch_Debug Then ConsoleWrite("+ Dll Return: " & $result[0] & @CRLF) Local $array = StringSplit($result[0], "|") If $_CenterPos Then $_Return[1] = Round(Number($array[2]) + (Number($array[4]) / 2)) $_Return[2] = Round(Number($array[3]) + (Number($array[5]) / 2)) If $ImageSearch_Debug Then ConsoleWrite("- CP: " & $_Return[1] & " " & $_Return[2] & @CRLF) Else $_Return[1] = Number($array[2]) $_Return[2] = Number($array[3]) If $ImageSearch_Debug Then ConsoleWrite("- : " & $_Return[1] & " " & $_Return[2] & @CRLF) EndIf ExitLoop EndIf Next Return $_Return EndFunc ;==>_ImageSearch_Area Func _ImageSearch_Area_Reverse($_ImagePath, $P_x1 = @DesktopWidth, $P_y1 = @DesktopHeight, $P_x2 = 0, $P_y2 = 0, $_Tolerance = 0, $_CenterPos = True) Local $_Return[3] = [0, 0, 0], $_TempVar, $i $_Return[0] = -1 If (FileExists($_ImagePath) = 0) And (StringInStr($_ImagePath, "|") = 0) Then If $ImageSearch_Debug Then ConsoleWrite("! Image file not found - Can't search !" & @CRLF & "! " & $_ImagePath & @CRLF) Return SetError(-1, 0, $_Return) EndIf If $P_x1 > $P_x2 Then ; change position to default top-left and botton-right $_TempVar = $P_x1 $P_x1 = $P_x2 $P_x2 = $_TempVar EndIf If $P_y1 > $P_y2 Then $_TempVar = $P_y1 $P_y1 = $P_y2 $P_y2 = $_TempVar EndIf Local $_Find_IMG_X, $_Find_IMG = StringSplit($_ImagePath, '|', 2) For $i = 0 To (UBound($_Find_IMG) - 1) Step +1 $_Find_IMG_X = $_Find_IMG[$i] If (FileExists($_Find_IMG_X) = 0) Then If $ImageSearch_Debug Then ConsoleWrite("! Image file not found !" & @CRLF & "! " & $_Find_IMG_X & @CRLF) ContinueLoop EndIf If $_Tolerance > 0 Then $_Find_IMG_X = "*" & $_Tolerance & " " & $_Find_IMG_X If (FileExists($ImageSearchDLL_Path) = 0) Then _ImageSearch_CheckDLL() Local $result = DllCall($ImageSearchDLL_Path, "str", "ImageSearch", "int", $P_x1, "int", $P_y1, "int", $P_x2, "int", $P_y2, "str", $_Find_IMG_X) If Not IsArray($result) Then ; dll not found or other error If $ImageSearch_Debug Then ConsoleWrite("! Dll not found or Call Dll error !" & @CRLF) $_Return[0] = -1 Return SetError(1, 0, $_Return) EndIf If Int($result[0]) = 0 Then ; search not found If $ImageSearch_Debug Then ConsoleWrite("! Search not found !" & @CRLF) $_Return[0] = 0 ContinueLoop Else $_Return[0] = 1 If $ImageSearch_Debug Then ConsoleWrite("+ Dll Return: " & $result[0] & @CRLF) Local $array = StringSplit($result[0], "|") If $_CenterPos Then $_Return[1] = Round(Number($array[2]) + (Number($array[4]) / 2)) $_Return[2] = Round(Number($array[3]) + (Number($array[5]) / 2)) If $ImageSearch_Debug Then ConsoleWrite("- CP: " & $_Return[1] & " " & $_Return[2] & @CRLF) Else $_Return[1] = Number($array[2]) $_Return[2] = Number($array[3]) If $ImageSearch_Debug Then ConsoleWrite("- : " & $_Return[1] & " " & $_Return[2] & @CRLF) EndIf ExitLoop EndIf Next Return $_Return EndFunc ;==>_ImageSearch_Area_Reverse However, i think i need to change some other values too, i think i have to switch around these values somehow: If $P_x1 > $P_x2 Then ; change position to default top-left and botton-right $_TempVar = $P_x1 $P_x1 = $P_x2 $P_x2 = $_TempVar EndIf If $P_y1 > $P_y2 Then $_TempVar = $P_y1 $P_y1 = $P_y2 $P_y2 = $_TempVar EndIf I just have no idea where to start because i dont fully understand what is going on. Edit: I've just been thinking... That uf statement changes position to default (normal search) if i were to use ; to mark out those 2 ifs, wouldnt it in fact work? Atm not able to test atm, thats why i ask instead of try... Edited May 13, 2020 by Maffiagang
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now