Jump to content

Pixelsearch Returning Apparent False Positives


Recommended Posts

I'm writing a script that manually copies and pastes data out of a funky UI implementation that won't let you select all values at once. I'm using CTRL-F in the browser to highlight the last copied value. Then I do some pixelsearches to see when I've arrowed down far enough to select the next chunk of data, so I can copy and paste it to my spreadsheet.

It works perfect. Until it doesn't. I can get through three full proper executions of the While loop before Pixelsearch apparently decides that a white pixel is in fact a bright orange pixel.

I added a bunch of logging so I can see what values are present at all times in the execution of the code. Please have mercy on my soul, I'm not a coder by trade. I think the relevant part of the code starts on the While $NotFound line:

While 1

   ;Hit CTRL-C
   GoodCopy()

   ;Alt Tab
   GoodAltTab()

   ;Hit CTRL-SHIFT-V
   GoodPasteText()

   ;Hit CTRL-Down
   GoodJumpDown()

   ;Copy
   GoodCopy()

   ;Hit Down
   GoodDown()

   ;Alt Tab
   GoodAltTab()

   ;Hit CTRL-F
   GoodF()

   $HereItIs = "At CTRL Find"
   GoodLog($HereItIs)

   ;Paste
   GoodPaste()

   ;Hit Enter
   GoodEnter()

   ;Left click in field

   Sleep($Time)

   GoodLeftClick($TopRightX, $TopRightY)

   Sleep($Time)

   GoodLeftClick($BottomRightX, $BottomRightY)

   Sleep($Time)

   ;Arrow key down until orange is in top area - may not need to hit down at all if orange is already in area
   $NotFound = 1

   While $NotFound
      GoodLog("Started Not Found")

      $OrangeLoc = 0
      $OrangeLoc = PixelSearch(579,303,580,257,0xFF9632,1,1)
      If @error Then

         GoodLog("Error on PixelSearch.")
         GoodDown()

      Else

         GoodLog("PixelSearch Success. X: " & $OrangeLoc[0] & " Y: " & $OrangeLoc[1])
         $NotFound = 0

      EndIf

   WEnd


   $OrangeLoc2 = 0
   $OrangeLoc2 = PixelSearch(579,360,580,257,0xFF9632,1,1)
   If @error Then

   Else

      $BOX = $OrangeLoc2[0]
      $BOY = $OrangeLoc2[1] + 20
      GoodLog("Selection started. X: " & $OrangeLoc2[0] & " Y: " & $OrangeLoc2[1])

      Sleep($Time)
      MouseMove($BOX, $BOY)
      Sleep($Time)
      MyDrag()

   EndIf

WEnd

That While $NotFound loop works perfect, and gives me expected Pixelsearch results for the first three iterations. Then for no reason at all that I can see, Pixelsearch returns values for the fourth iteration. Even though the color is decidedly not present in the very small area described. It should be returning an error. But it's not.

I've recorded the operation of the script half a dozen times, and played it back in slow motion. There simply is no color. All those $Time variables are current set to 500 ms, so things happen very slowly, so I can scrutinize them. This problem is highly repeatable with different data sets.

Any ideas on why Pixelsearch would behave like this?

Link to comment
Share on other sites

47 minutes ago, ZandarKoad said:

I ended up figuring out a way to modify the page's client side CSS so that I could select hundreds of rows at a time.

Another victory for the use-something-anything-other-than-pixelsearch team!

Surely there are some small details that you do not take into account when interacting with the images on the screen. Otherwise there will be a logic error in the code ...

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...