def stackitems(item): thing = pyautogui.locateOnScreen('imgs/inventoryitemhangar.png') inventorylist = cm.Area(thing.left + 25, thing.top + 70, 500, 250) cm.sleep(1) box = inventorylist.toAbsTuple() ocr = cm.grabandocr(box) #todo implement ocr with highestsim check for s in ocr.splitlines(): if (s.split()[-1][:5] in item.lower()): offsetpos = inventorylist mousex = offsetpos.x + int(s.split()[6]) / 4 + 5 mousey = offsetpos.y + int(s.split()[7]) / 4 + 5 cm.clickxy(mousex, mousey, clicks=1, right=True) cm.sleep(0.2) box = (mousex + 15, mousey + 2, mousex + 15 + 135, mousey + 3 + 250) ocr = cm.grabandocr(box) for s in ocr.splitlines(): if (s.split()[-1] == "stack"): mousex = mousex + 18 + int(s.split()[6]) / 4 + 5 mousey = mousey + 3 + int(s.split()[7]) / 4 + 5 cm.clickxy(mousex, mousey) return
def addItemToQuickbar(typeid): dontShow() itemname = api.getNameFromID(typeid) pyautogui.moveTo(200, 10) pyautogui.sleep(0.3) thing = pyautogui.locateOnScreen('imgs/regionalmarkettopleft.png', confidence=0.9) thing2 = pyautogui.locateOnScreen('imgs/search.png', confidence=0.9) if thing is None or thing2 is None: print("im blind") return addItemToQuickbar(typeid) search_market(itemname) cm.sleep(4) searchareacapturepos = cm.Area(thing.left, thing.top + 100, thing2.left - thing.left + 50, 400) for loopidx in range(20): ocr = cm.grabandocr(searchareacapturepos) ocrlines = ocr.splitlines() if loopidx == 10: search_market(itemname) cm.sleep(0.5) stringdict = {} curstring = "" for idx, s in enumerate(ocrlines): s = s.lower() if (len(s.split()) <= 11 or len(s.split()[-1]) < 2): if curstring: stringdict[curstring.strip()] = idx - 1 curstring = "" else: curstring += s.split()[-1] + " " if (idx == len(ocrlines) - 1): stringdict[curstring.strip()] = idx - 1 highestsim = -1 bestidx = 0 for s in stringdict: cursim = cm.similar(itemname.lower(), s) if cursim > highestsim: highestsim = cursim bestidx = stringdict[s] if (highestsim > 0.8): s = ocrlines[bestidx] print("found item in search results: " + s) offsetpos = searchareacapturepos mousex = offsetpos.x + int(s.split()[6]) / 4 + 5 mousey = offsetpos.y + int(s.split()[7]) / 4 + 5 cm.clickxy(mousex, mousey) cm.sleep(1.5) thing = pyautogui.locateOnScreen('imgs/search.png', confidence=0.9) marketnamearea = cm.Area(thing.left + 158, thing.top + 14, 375, 30) ocr = cm.grabandocr(marketnamearea) marketname = "" for line in ocr.splitlines(): if len(line.split()) > 11: marketname += line.split()[-1] + ' ' #strips marketname of whitespace and the list 4 characters, which should be: " i ©" marketname = marketname.strip()[:-4] print("read marketname while adding item: " + marketname) #marketname is the ocr result, itemname is the actual item were trying to add if (cm.similar(marketname.lower(), itemname.lower()) < 0.75): print("clicked wrong item while adding, retrying") return addItemToQuickbar(typeid) cm.clickxy(mousex, mousey, right=True) cm.sleep(0.2) cm.clickxy(mousex + 52, mousey + 29) print("old itemlist:") print(itemlist) if itemname not in itemlist: itemlist.append(itemname) itemlist.sort(key=str.lower) print("new itemlist:") print(itemlist) return if loopidx > 12: #we only get here if it didnt find an item: the item must have been in a collapsed category for s in ocr.splitlines(): if (len(s.split()) > 11 and len(s.split()[-1]) > 3): #we do NOT want to open the blueprint category if not "prints" in s and not "react" in s: offsetpos = searchareacapturepos mousex = offsetpos.x + int(s.split()[6]) / 4 + 5 mousey = offsetpos.y + int(s.split()[7]) / 4 + 5 cm.clickxy(mousex, mousey) break cm.sleep(0.5) print("looped through item adding a lot without success, aborting") sys.exit()
cl = pyautogui.locateOnScreen("imgs/connectionlost.png", confidence=0.9) if(cl is not None): process.terminate() print("we lost connection, initiating restart procedure") point = cm.Point(cl.left + 169, cl.top + 194) cm.clickPoint(point, 5) #wait 20 minutes for internet to come back or eve to restart time.sleep(1200) lg = pyautogui.locateOnScreen("imgs/launchgroup.png") pn = pyautogui.locateOnScreen("imgs/playnow.png") while (lg is None and pn is None): cm.clickPointPNG("imgs/evetaskbar.png", 5, 5) lg = pyautogui.locateOnScreen("imgs/launchgroup.png") pn = pyautogui.locateOnScreen("imgs/playnow.png") time.sleep(5) print("starting eve client") cm.clickPointPNG("imgs/launchgroup.png", 10, 10) cm.clickPointPNG("imgs/playnow.png", 10, 10) #wait for game to start time.sleep(60) print("clicking character") #5 clicks because the window may not be focused cm.clickxy(470 + 110, 420, 5) time.sleep(60) print("starting bot") process = multiprocessing.Process(target=mainwrapper.doTradeBot, args=(tradedaystart,)) process.start() time.sleep(5) except KeyboardInterrupt: sys.exit()
def sellitemininventory(typeid, price): item = api.getNameFromID(typeid) cm.clickPointPNG('imgs/inventorytopright.png', 0, 25, 2, cache=True) cm.sleep(0.2) cm.safetypewrite(item) stackitems(item) cm.sleep(0.5) thing = pyautogui.locateOnScreen('imgs/inventoryitemhangar.png') inventorylist = cm.Area(thing.left + 25, thing.top + 70, 500, 250) cm.sleep(1) box = inventorylist.toAbsTuple() ocr = cm.grabandocr(box) #todo implement ocr with highestsim check for s in ocr.splitlines(): if (s.split()[-1][:5] in item.lower()): offsetpos = inventorylist mousex = offsetpos.x + int(s.split()[6]) / 4 + 5 mousey = offsetpos.y + int(s.split()[7]) / 4 + 5 cm.clickxy(mousex, mousey, clicks=1, right=True) cm.sleep(0.2) box = (mousex + 15, mousey + 2, mousex + 15 + 135, mousey + 3 + 200) ocr = cm.grabandocr(box) for s in ocr.splitlines(): if (s.split()[-1] == "sell"): mousex = mousex + 18 + int(s.split()[6]) / 4 + 5 mousey = mousey + 3 + int(s.split()[7]) / 4 + 5 cm.clickxy(mousex, mousey) cm.sleep(5) #todo replace this with clickpointpng thing = pyautogui.locateOnScreen('imgs/sellitems.png') pricefield = cm.Point(thing.left + thing.width / 2, thing.top + 80) thing = pyautogui.locateOnScreen( 'imgs/sellitemsellcancel.png') sellbutton = cm.Point(thing.left + 25, thing.top + 12) thing = pyautogui.locateOnScreen( 'imgs/sellitemduration.png') duration = cm.Point(thing.left - 50, thing.top + 28) #set duration to 3 months cm.clickPoint(duration) for _ in range(10): pyautogui.press('down') cm.clickPoint(duration) #set price pyautogui.moveTo(pricefield.x, pricefield.y) cm.sleep(0.3) pyautogui.doubleClick(pricefield.x, pricefield.y) cm.safetypewrite(price) cm.clickPoint(sellbutton) cm.sleep(0.5) thing = pyautogui.locateOnScreen( 'imgs/sellitemconfirm.png') confirmbutton = cm.Point(thing.left + 145, thing.top + 193) cm.clickPoint(confirmbutton) thing = pyautogui.locateOnScreen("imgs/warning.png", confidence=0.9) if thing is not None: cm.clickPointPNG("imgs/yesno.png", 20, 10) return 1 return 0
def changeOrder(order, newprice): refreshOrderList() position, itemsinlist = getOrderPosition(order) itemname = api.getNameFromID(order.typeid) print("changing order of item: " + itemname + " in position: " + str(position)) if order.bid: actingPoint, listheight = variables.bidaplh else: actingPoint, listheight = variables.sellaplh pyautogui.moveTo(actingPoint.x, actingPoint.y) cm.sleep(0.2) #this scrolls so the order is visible, and adjusts the position itemsfitinlist = math.ceil(listheight / 20) if (position >= itemsfitinlist): pagescrollcount = math.floor(position / itemsfitinlist) position -= (itemsinlist % itemsfitinlist) pyautogui.scroll(int(-130 * itemsfitinlist * pagescrollcount)) pyautogui.move(0, 20 * position) pyautogui.click(button='right', clicks=1) cm.sleep(0.5) pyautogui.move(35, 10) cm.sleep(0.5) pyautogui.click() thing = pyautogui.locateOnScreen("imgs/modifyorder.png", confidence=0.9) for a in range(100): if thing is None: thing = pyautogui.locateOnScreen("imgs/modifyorder.png", confidence=0.9) cm.sleep(0.2) else: break if thing is None: refreshAllOrders() return changeOrder(order, newprice) box = cm.Area(thing.left + 100, thing.top + 21, 300, 19) ocr = cm.grabandocr(box).splitlines() ocrname = "" for line in ocr: if (len(line.split()) > 11): ocrname += line.split()[-1] + " " print("checking if we clicked the right order...") print("itemname: " + itemname.lower() + ", ocrname: " + ocrname) if cm.similar(ocrname.lower(), itemname.lower()) < 0.5: print("failed similar check") cm.clickxy(thing.left + 265, thing.top + 192) cm.sleep(0.5) refreshAllOrders() return changeOrder(order, newprice) cm.sleep(0.2) pyautogui.keyDown('ctrl') pyautogui.keyDown('c') cm.sleep(0.2) pyautogui.keyUp('c') pyautogui.keyUp('ctrl') realprice = pyperclip.paste() cm.safetypewrite(newprice) cm.sleep(0.2) pyautogui.typewrite(['enter']) cm.sleep(0.5) thing = pyautogui.locateOnScreen("imgs/warning.png", confidence=0.9) if thing is not None: cm.clickPointPNG("imgs/yesno.png", 20, 10) #reset scroll pyautogui.moveTo(actingPoint.x + 10, actingPoint.y + 10) pyautogui.scroll(100000) order.price = float(newprice) order.issuedate = cm.getEVETimestamp()