Esempio n. 1
0
                     format="%(asctime)-15s %(levelname)-8s %(message)s")
 #need this for the sleep calls in cm.clickpoint
 variables.init()
 tradedaystart = cm.getEVETimestamp()
 process = multiprocessing.Process(target=mainwrapper.doTradeBot, args=(tradedaystart,))
 process.start()
 while True:
     try:
         if not process.is_alive():
             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")
Esempio n. 2
0
def buyorder(typeid, price, quantity):
    quickbar.openItem(typeid)
    cm.sleep(3)
    thing = pyautogui.locateOnScreen('imgs/placebuyorder.png')
    buyorderpos = cm.Point(thing.left + thing.width / 2,
                           thing.top + thing.height / 2)
    cm.clickPoint(buyorderpos)
    cm.sleep(2)
    thing = pyautogui.locateOnScreen('imgs/buyorderadvanced.png')
    if thing is not None:
        advanced = cm.Point(thing.left + thing.width / 2,
                            thing.top + thing.height / 2)
        cm.clickPoint(advanced)
        cm.sleep(1)
    thing = pyautogui.locateOnScreen('imgs/buyorderoriginpoint.png')
    bidpricefield = cm.Point(thing.left + 143, thing.top + 33)
    quantityfield = cm.Point(thing.left + 143, thing.top + 169)
    duration = cm.Point(thing.left + 143, thing.top + 190)
    threemonths = cm.Point(thing.left + 143, thing.top + 332)
    buything = pyautogui.locateOnScreen('imgs/buyandcancel.png')
    buybutton = cm.Point(buything.left + 25, buything.top + 7)
    cm.clickPoint(bidpricefield, 2)
    cm.sleep(0.3)
    cm.safetypewrite(price)
    cm.clickPoint(quantityfield, 2)
    cm.sleep(0.3)
    cm.safetypewrite(quantity)
    cm.clickPoint(duration)
    for _ in range(10):
        pyautogui.press('down')
    cm.clickPoint(duration)
    cm.clickPoint(buybutton, 1)
    cm.sleep(0.6)
    thing = pyautogui.locateOnScreen('imgs/confirmorder.png')
    confirmyes = cm.Point(thing.left + 149, thing.top + 197)
    cm.clickPoint(confirmyes)
    thing = pyautogui.locateOnScreen("imgs/warning.png", confidence=0.9)
    if thing is not None:
        cm.clickPointPNG("imgs/yesno.png", 20, 10)
Esempio n. 3
0
def loadOrders():
    itemhandlerlist = variables.itemhandlerlist

    marketlogsfolder = os.path.expanduser(
        '~\\Documents\\EVE\\logs\\Marketlogs')
    deleteMarketLogs()

    cm.exportMyOrders()

    loopidx = 0
    while True:
        if (len(os.listdir(marketlogsfolder)) > 0):
            break
        thing = pyautogui.locateOnScreen("imgs/nobuyorsell.png",
                                         confidence=0.9)
        if thing is not None:
            okbutton = cm.Point(thing.left + 169, thing.top + 194)
            cm.clickPoint(okbutton)
            return
        if loopidx % 5 == 0:
            cm.exportMyOrders()
        else:
            cm.sleep(0.5)
        loopidx += 1

    if not os.listdir(marketlogsfolder)[-1].startswith('My Orders'):
        return loadOrders()

    logfile = marketlogsfolder + "\\" + os.listdir(marketlogsfolder)[-1]
    neworders = []
    try:
        with open(logfile) as export:
            reader = csv.DictReader(export)
            for l in reader:
                neworders.append(
                    cm.Order(int(l['typeID']), int(l['orderID']),
                             str(l['bid']) == "True", float(l['price']),
                             int(float(l['volEntered'])),
                             int(float(l['volRemaining'])),
                             DateUtilParser(l['issueDate']).timestamp()))
        os.remove(logfile)
    except:
        cm.sleep(5)
        return loadOrders()

    for no in neworders:
        if not any(no.typeid == ih.typeid for ih in itemhandlerlist):
            print("initiating leftoveritemhandler for order:" +
                  api.getNameFromID(no.typeid))
            itemhandlerlist.append(cm.LeftoverItemHandler(no.typeid, [], None))
            quickbar.addItemToQuickbar(no.typeid)
    #sort each neworder back into the itemhandlers
    for itemhandler in itemhandlerlist:
        itemhandler.sellorderlist = []
        itemhandler.buyorder = None
        for no in neworders:
            if (itemhandler.typeid == no.typeid):
                if no.bid:
                    itemhandler.buyorder = no
                else:
                    itemhandler.sellorderlist.append(no)
Esempio n. 4
0
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
Esempio n. 5
0
def refreshAllOrders():
    itemhandlerlist = variables.itemhandlerlist

    marketlogsfolder = os.path.expanduser(
        '~\\Documents\\EVE\\logs\\Marketlogs')
    deleteMarketLogs()

    cm.exportMyOrders()

    loopidx = 0
    while True:
        if (len(os.listdir(marketlogsfolder)) > 0):
            break
        thing = pyautogui.locateOnScreen("imgs/nobuyorsell.png",
                                         confidence=0.9)
        if thing is not None:
            okbutton = cm.Point(thing.left + 169, thing.top + 194)
            cm.clickPoint(okbutton)
            return
        if loopidx % 5 == 0:
            cm.exportMyOrders()
        else:
            cm.sleep(0.5)
        loopidx += 1

    if not os.listdir(marketlogsfolder)[-1].startswith('My Orders'):
        return refreshAllOrders()

    logfile = marketlogsfolder + "\\" + os.listdir(marketlogsfolder)[-1]
    neworders = []
    try:
        with open(logfile) as export:
            reader = csv.DictReader(export)
            for l in reader:
                neworders.append(
                    cm.Order(int(l['typeID']), int(l['orderID']),
                             str(l['bid']) == "True", float(l['price']),
                             int(float(l['volEntered'])),
                             int(float(l['volRemaining'])),
                             DateUtilParser(l['issueDate']).timestamp()))
        os.remove(logfile)
    except:
        cm.sleep(5)
        return refreshAllOrders()

    oldorders = []
    for itemhandler in itemhandlerlist:
        ihcopy = copy.deepcopy(itemhandler)
        if ihcopy.buyorder is not None:
            oldorders.append(ihcopy.buyorder)
        if ihcopy.sellorderlist:
            oldorders += ihcopy.sellorderlist

    newfromoldorders = []
    #the newfromoldorders list will contain every order even finished ones, the itemhandler will remove those in its handle func
    for oo in oldorders:
        curorder = copy.deepcopy(oo)
        for no in neworders:
            if areOrdersTheSame(oo, no):
                curorder.volremaining = no.volremaining
                if (curorder.volremaining > curorder.volentered):
                    curorder.volremaining = curorder.volentered
                if (curorder.orderid == -1):
                    curorder.orderid = no.orderid
                curorder.issuedate = no.issuedate
                break
        curorder.finished = (
            not any(areOrdersTheSame(oo, no) for no in neworders)
            and cm.getEVETimestamp() - oo.issuedate > 20)
        newfromoldorders.append(curorder)
    #the order export can be heavily delayed sometimes, so we just add old orders that are freshly made
    for oo in oldorders:
        if (not any(areOrdersTheSame(nfo, oo) for nfo in newfromoldorders)
                and cm.getEVETimestamp() - oo.issuedate < 20):
            newfromoldorders.append(oo)
    #sort each neworder back into the itemhandlers
    for itemhandler in itemhandlerlist:
        itemhandler.sellorderlist = []
        itemhandler.buyorder = None
        for nfo in newfromoldorders:
            if (itemhandler.typeid == nfo.typeid):
                if nfo.bid:
                    itemhandler.buyorder = nfo
                else:
                    itemhandler.sellorderlist.append(nfo)