Sign in to follow this  
Followers 0
Orgins

Two.five small questions for this script

2 posts in this topic

#1 ·  Posted (edited)

I copied and pasted part of this so I don't fully under stand it.

1.: Will this only do the first file jpg and the next jpg? (only those two)

1.5: Or will it do first then next next next ect into all jpg's have been compared or a >98% match has been found?

2.:And the loop will end if none of them match right?

#include <ScreenCapture.au3>
$search = FileFindFirstFile("Magic/*.jpg");;where I keep a few jpg's (15+ atm but it will grow)
$1 = 1


_ScreenCapture_Capture("Curitem.jpg", 165, 297, 187, 315)

$Compare1 = Compare("Curitem.jpg", $search, 22, 18, 1)

If $Compare1[$1]  > 98 Then 
    _ScreenCapture_Capture("MagicItemPickedAt"& @HOUR & @MIN &  @SEC &".jpg", 165, 297, 187, 315)
    Sleep(1500)
MouseClick("left", 149, 307, 2);click/picking up that item
    Sleep(3500)
endif

$W = 1
While $W = 1
    $file = FileFindNextFile($search) 
    
$Compare2 = Compare("Curitem.jpg", $file, 22, 18, 1)

If $Compare2[$1]  > 98 Then 
    _ScreenCapture_Capture("MagicItemPickedAt"& @HOUR & @MIN &  @SEC &".jpg", 165, 297, 187, 315)
    Sleep(1500)
MouseClick("left", 149, 307, 2);;;;;;;;;;;;click/picking up that item

   $W = 0;;;;;;;;;;;;;This will end the loop if one is a 98% match right?
    Sleep(3500)
endif

$1 = $1 + 1;;;;;;;;;;;;;;;;This will make it do the next (after the next) file right?
 If @error Then ExitLoop;;;;;;;;;;;;This will end the loop if i'm out of next files right?
WEnd

FileClose($search)


;;;;;;;;;;;;;;;Used to compare current item with jpgs in folders;;;;;;; I know this part works fine;;;;;;;;;;;;;;;;I copied/pasted it and didn't edit anything;;;;;;;;;;;;;;;
Func Compare($Pic1, $Pic2, $Width, $Height, $Step = 1)
    Local $Color[$Width + 1][$Height + 1], $Color2[$Width + 1][$Height + 1], $Var = 0, $Var2 = 0
    $Compare = GUICreate("", $Width, $Height, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetState(@SW_SHOW, $Compare)
    $Pic = GUICtrlCreatePic($Pic1, "", "", $Width, $Height)
    For $y = 1 To $Height Step $Step
        For $x = 1 To $Width
            $Color[$x][$y] = PixelGetColor($x, $y)
        Next
    Next
    GUICtrlSetImage($Pic, $Pic2)
    For $y = 1 To $Height Step $Step
        For $x = 1 To $Width
            $Color2[$x][$y] = PixelGetColor($x, $y)
            If $Color[$x][$y] = $Color2[$x][$y] Then
                $Var += 1
            Else
                $Var2 += 1
            EndIf
        Next
    Next
    $Need = $Var + $Var2
    $Result = ($Var / $Need) * 100
    Sleep(800)
    GUIDelete($Compare)
    Dim $Return[4] = [$Need, Round($Result, 1), $Var, $Var2]
    Return $Return
EndFunc
Edited by Orgins

I'm a newbie.Sorry if I don't reposed to your replays very fast.

Share this post


Link to post
Share on other sites



1.: Will this only do the first file jpg and the next jpg? (only those two)

1.5: Or will it do first then next next next ect into all jpg's have been compared or a >98% match has been found?

It will do it until a 98% match is found assuming that the picture is not moved by 1 line the algorithm looks good enough

2.:And the loop will end if none of them match right?

$W = 0;;;;;;;;;;;;;This will end the loop if one is a 98% match right? ---> You are right

$1 = $1 + 1;;;;;;;;;;;;;;;;This will make it do the next (after the next) file right? ---> You are wrong, useless to put this in

If @error Then ExitLoop;;;;;;;;;;;;This will end the loop if i'm out of next files right? --> You are wrong as you assume this can be the only reason for error

Just run the code and you can see if it will ends;-)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0