예제 #1
0
    def GetDotBoard(self, clock):
        #logging.debug("GetDotBoard")
        if exists("lost_message.png", 0.001):
            return -1
        dotLoc = []
        dotColor = []
        dotLoc.append(self.clock.getCenter().offset(221, 475))
        stepX = 96
        stepY = 97
        for i in range(1, 7):
            dotLoc.append(Location(dotLoc[i - 1].x + stepX, dotLoc[i - 1].y))
        for i in range(0, 7):
            dotLoc.append(Location(dotLoc[i].x, dotLoc[i].y + stepY))

        r = Robot()
        question_mark_count = 0
        for i in range(0, 14):
            c = r.getPixelColor(dotLoc[i].x,
                                dotLoc[i].y)  # get the color object
            color = self._check_color(c)  # 檢查該點的顏色
            if color == "?":
                color = self._check_around(r, dotLoc[i].x, dotLoc[i].y)
            if color == "?":
                question_mark_count += 1
                if question_mark_count > 3:  #魂盤有太多沒辨識出來, 則跳過這次魂盤
                    return 0

            dotColor.append(color)
            #crgb = ( c.getRed(), c.getGreen(), c.getBlue() ) # decode to RGB values
            #print dotColor[i]
        self.SetBoard(dotLoc, dotColor)
        return 1
예제 #2
0
def checkTextAndColorFromSpin():
    Region(717,828,95,90).click()
    time.sleep(1)
    textFromSpin = Region(435,754,73,24).text()
    colorRegion = find("1460730720660.png")
    colorPattern = colorRegion.getTopLeft().offset(5,5)
    robot = Robot()
    colorRobot = robot.getPixelColor(colorPattern.x, colorPattern.y)
    color = ( colorRobot.getRed())
    if color == 173:
        colorRed = 'red'
        textFromSpin = textFromSpin + colorRed
        return textFromSpin
    elif color == 31:
        colorBlack = 'black'
        textFromSpin = textFromSpin + colorBlack
        return textFromSpin
    else: 
        return textFromSpin
# Get the region of the segmentation parameter dialog window
applicationTopLeft = connectButton.getTopLeft()
applicationTopLeft = applicationTopLeft.left(205).above(295)
windowRegion = Region(applicationTopLeft.x, applicationTopLeft.y, 495, 355)
messageBoxRegion = Region(applicationTopLeft.x - 15,
                          applicationTopLeft.y - 195, 510, 550)

# Look for green status icon
try:
    statusIcon = windowRegion.find("GreenStatusIcon.png")
except FindFailed:
    print "[ERROR] Cannot find green StatusIcon!"
    captureScreenAndExit()

statusIconCenter = statusIcon.getCenter()
color = colorPickerRobot.getPixelColor(statusIconCenter.x, statusIconCenter.y)

if color.getGreen() < color.getRed() or color.getGreen() < color.getBlue():
    print "[ERROR] StatusIcon is not green (", color, ")"
    captureScreenAndExit()

# Connect to the device set that will fail
click(connectButton)
wait(2)

try:
    windowRegion.wait("ConnectButton.png", 10)
except FindFailed:
    print "[ERROR] Connection did not fail!"
    captureScreenAndExit()
try:
  saveButton = windowRegion.wait("SaveButton.png", 10)
except FindFailed:
  print "[ERROR] Save button in config file saver dialog cannot be found in original window boundaries!"
  captureScreenAndExit()

click(saveButton)
wait(5)
type("TEST_ConfigFileSaverDialogTest_Result")
type(Key.ENTER)
wait(5)

# Check if errors occurred
import java.awt.Robot as JRobot
colorPickerRobot = JRobot()

try:
  statusIcon = windowRegion.find("GreenStatusIcon.png")
except FindFailed:
  print "[ERROR] Cannot find green StatusIcon!"
  captureScreenAndExit()

statusIconCenter = statusIcon.getCenter()
color = colorPickerRobot.getPixelColor(statusIconCenter.x, statusIconCenter.y)

if color.getGreen() < color.getRed() or color.getGreen() < color.getBlue():
  print "[ERROR] StatusIcon is not green (", color, ")"
  captureScreenAndExit()
  
closeApp(appTitle) # close the window - stop the process
예제 #5
0
from java.awt import Robot
cp = find(capture())
r = Robot()
c = r.getPixelColor(cp.getX(), cp.getY())  # get the color object
crgb = (c.getRed(), c.getGreen(), c.getBlue())  # decode to RGB values
print crgb

#def get_top_line(a):
# central_top = []
# central_position = float(a)
# print central_position/14
# while central_position/14/2 != 0 and central_position > 14:
#    if (central_position//14) % 2 == 0:
#        central_position -=  15
#    else:
#        central_position -=  14
#   central_top.append(central_position)
# return central_top

#print(get_top_line(85))