Esempio n. 1
0
def _demo():
    saveNames = [
        'allMonitors', 'primaryMonitor', 'secondaryMonitor', 'boundingTestOne',
        'boundingTestTwo'
    ]
    params = [
        None,
        getMonitorCoordinates(0),
        getMonitorCoordinates(1), (0, 0, 100, 50), (400, 300, 200, 200)
    ]
Esempio n. 2
0
def get_play_area(monitor):
	'''
	Snaps an image of the chosen monitor (zero indexed). 
	Loops through the RGB pixels looking for the value 
	(244,222,176), which corresponds to the top left 
	most pixel of the game.

	It returns the coordinates of the playarea. 
	'''
	
	TOP_LEFT_PIXELS = (204,204,204)
	GREY_BORDER = (204,204,204)
	SCREEN_WIDTH = 719
	SCREEN_HEIGH = 479

	monitor_coords = getMonitorCoordinates(0) #set to whatever monitor you have the game screen on
	im = grab(monitor_coords)
	imageWidth, imHeight = im.size
	imageArray = im.getdata()

	for index, pixel in enumerate(imageArray):
		if pixel == TOP_LEFT_PIXELS:
			# getdata returns a flat array, so the below figures out
			# the 2d coords based on the index position.
			top = (index / imageWidth)
			left = (index % imageWidth)
			if (im.getpixel((left + 1, top + 1)) == GREY_BORDER and
				im.getpixel((left + 2, top + 2)) == GREY_BORDER):
				top += 5
				left += 5
				
				return (left, top, left + SCREEN_WIDTH, top + SCREEN_HEIGH) 

	raise Exception("Play area not in view." 
			"Make sure the game is visible on screen!")	
Esempio n. 3
0
def get_play_area(monitor):
    '''
	Snaps an image of the chosen monitor (zero indexed). 
	Loops through the RGB pixels looking for the value 
	(244,222,176), which corresponds to the top left 
	most pixel of the game.

	It returns the coordinates of the playarea. 
	'''

    TOP_LEFT_PIXELS = (204, 204, 204)
    GREY_BORDER = (204, 204, 204)
    SCREEN_WIDTH = 719
    SCREEN_HEIGH = 479

    monitor_coords = getMonitorCoordinates(
        0)  #set to whatever monitor you have the game screen on
    im = grab(monitor_coords)
    imageWidth, imHeight = im.size
    imageArray = im.getdata()

    for index, pixel in enumerate(imageArray):
        if pixel == TOP_LEFT_PIXELS:
            # getdata returns a flat array, so the below figures out
            # the 2d coords based on the index position.
            top = (index / imageWidth)
            left = (index % imageWidth)
            if (im.getpixel((left + 1, top + 1)) == GREY_BORDER
                    and im.getpixel((left + 2, top + 2)) == GREY_BORDER):
                top += 5
                left += 5

                return (left, top, left + SCREEN_WIDTH, top + SCREEN_HEIGH)

    raise Exception("Play area not in view."
                    "Make sure the game is visible on screen!")
Esempio n. 4
0
def _demo():
    saveNames = ["allMonitors", "primaryMonitor", "secondaryMonitor", "boundingTestOne", "boundingTestTwo"]
    params = [None, getMonitorCoordinates(0), getMonitorCoordinates(1), (0, 0, 100, 50), (400, 300, 200, 200)]