#!/usr/bin/env python # -*- coding: utf-8 -*- import time import Image import LtMacroAPI import pyosd import os pid = str(os.getpid()) pidfile = open("./ltmacros/running.pid", 'w') pidfile.write(pid) pidfile.close() # Parameters n = 7 # number of icons to check (the carnet counts x2) ########################################################## #USAGE: #naive slate/grass picker #stand on slate/grass and start macro and click on the button when mousepointer changes to + #this program will keep scanning that exact location for an exact match of a 10x10 patch there #if it sees one, it will click it ########################################################## # 2008 - MAY - 09 # Added OSD # Added multiple location icon system # # # Init of OSD system FONT = "-*-helvetica-*-r-normal--20-*-*-*-*-*-*-*" p = pyosd.osd(FONT, colour="#4040ff", shadow=2) p.set_shadow_offset(1) p.set_vertical_offset(2) p.set_pos(pyosd.POS_TOP) p.set_align(pyosd.ALIGN_CENTER) str='Please click on the slate icon now..' print(str) p.display(str) # get the coords of a mouseclick ((window, relative x, relative y), (root window, absolute screen x, absolute screen y)) (target_hit, root_hit) = LtMacroAPI.getwindowclick() # Get Window attributes (attr.width, attr.height) attr = target_hit[0].get_geometry() atitdwidth=attr.width gap = ((atitdwidth - target_hit[1]) // 64)+1 initx = target_hit[1]-(64*(n-gap)) # store a 10x10 image of the pixels where the mouse was clicked (hopefully the slate button) i1 = LtMacroAPI.getimage(target_hit[0], target_hit[1], target_hit[2], 10, 10) #print "got location, saving scanned patch to temp.png (just to demo PIL stuff)" #LtMacroAPI.getPILimage(target_hit[0], target_hit[1], target_hit[2], 10, 10).save("temp.png") # see www.pythonware.com for more info on PIL # loop forever while True: xc=initx i=n while (xc