Пример #1
0
 def getPercentFull(self):
     # scan for bgcolor
     self.window.getScreenShot()
     x,y = findColor(self.window, self.bgcolor)
     if y>-1:
         x2,y2 = findColor(self.window, self.barcolor)
         # when hovering over items in a trade it will cover the bar
         # which causes to first display background and then healthbar
         if y2==0:
             return float(y)/self.width*100
         # we found bg - so not 100 full
     return 100
Пример #2
0
    def findCenter(self):
        if self.lastLeft == -1:
            # very coarse grained search for some point of the button
            for color in self.color:
                top,left = findColor(self.win, color, 20)
                if top > -1:
                    self.color = color # also set the correct color
                    break
        else:
            # the button doesnt move so fast, that lastTop and lastLeft is a good guess
            top, left = self.lastTop, self.lastLeft

        # from the center go most left and most right and take the center again
        for l in range(left, 0, -1):
            if self.win.getPixel(top,l) != self.color:
                canContinue = False
                for jump in range(0,40,2):
                    if self.win.getPixel(top-jump,l) == self.color: # try to jump over the text if exist
                        l-=jump-1
                        canContinue = True
                        break
                mLeft = l+1
                if canContinue:
                    continue
                break
        for l in range(left, left+200, 1):
            if self.win.getPixel(top,l) != self.color:
                canContinue = False
                for jump in range(0,40,2):
                    if self.win.getPixel(top+jump,l) == self.color: # try to jump over the text if exist
                        l+=jump+1
                        canContinue = True
                        break
                mRight = l-1
                if canContinue:
                    continue
                break

        hCenter = mLeft+((mRight-mLeft)/2)
        # from top,hCenter go most up, and most down - take the center
        for t in range(top, 0, -1):
            if self.win.getPixel(t,hCenter) != self.color:
                canContinue = False
                for jump in range(0,40,2):
                    if self.win.getPixel(t-jump,hCenter) == self.color: # try to jump over the text if exist
                        t-=jump-1
                        canContinue = True
                        break
                mTop = t+1
                if canContinue:
                    continue
                break
        for t in range(top, top+200, 1):
            if self.win.getPixel(t,hCenter) != self.color:
                canContinue = False
                for jump in range(0,40,2):
                    if self.win.getPixel(t+jump,hCenter) == self.color: # try to jump over the text if exist
                        t+=jump+1
                        canContinue = True
                        break
                mBot = t-1
                if canContinue:
                    continue
                break
        vCenter = mTop+((mBot-mTop)/2)

        self.height = mBot-mTop
        self.width = mRight-mLeft
        self.lastTop = vCenter
        self.lastLeft = hCenter

        self.area = (mTop,mLeft,mBot,mRight) # could be used for debugging
        return vCenter,hCenter