POE (Path of Exile) automatic drink potion macro (software)


Warning

This posting is for educational purposes only. Never abuse, 

 

To do! Life on the room. 

The other postings, did you take the potion on the POE game using the hardware mechs? In this post, I’ll try only using Python. 

1. New Code 

Did you make a file called Post drinkPortion.py the other time? Use the code below instead of that code. In fact, it’s almost changed. After you Import the keyEvent library, it is not fillers to call the Ke.press function instead of ser.keyboardInput within the generateKeyEvent function. The keyEvent library is described after this code. In fact, it’s a library of example code that’s been uploaded to GitHub. 

To Keyboard the Arduino to serial communication, the serialFunc.py file giving the Mouse key command is not required here. So I treated it as a try. !

import mouse as mo
import keyboard as keys
import time
import configparser
import os
import keyEvent as ke
try:    
    import serialFunc as sf
    ser = sf.ExternalHID('COM16')
except Exception as e:
    print(e)
    print("Hardware Macro Disabled")
def generateKeyEvent(val, key_s, delay):
    if val == True:
        for outVal in key_s:
            # hardware macro
            #ser.keyboardInput(outVal)
            # software macro
            ke.press(outVal)
            time.sleep(delay)
def drinkPortionWithInput(listDevKeyOutVal, delay=0.001):
    listKeyState = [0] * len(listDevKeyOutVal)
    while True:
        for idx, dictDevVal in enumerate(listDevKeyOutVal):
            keyormo = list(dictDevVal.keys())[0]
            generateKeys = dictDevVal[keyormo].split(',')
            # [0] = k is keyboard [1] = pushed key
            if keyormo.split('_')[0].strip() == 'k':
                value = keys.is_pressed(keyormo.split('_')[1].strip())
                if listKeyState[idx] != value:
                    generateKeyEvent(value, generateKeys, delay)
                    listKeyState[idx] = value
            # [0] = m is mouse [1] = pushed mouse btn
            elif keyormo.split('_')[0].strip() == 'm':
                possList = [mo.LEFT, mo.RIGHT, mo.MIDDLE]
                try:
                    possList.index(keyormo.split('_')[1].strip())
                except Exception as e:
                    continue
                value = mo.is_pressed(keyormo.split('_')[1].strip())
                if listKeyState[idx] != value:
                    generateKeyEvent(value, generateKeys, delay)
                    listKeyState[idx] = value
if __name__=="__main__":
    configFile = os.path.dirname(os.path.realpath(__file__)) + '\\' + 'config.cfg'
    config = configparser.ConfigParser()
    config.read(configFile)
    itemList = []
    for option in config.options('portion_key'):
        itemList.append({option:config['portion_key'][option]})
    drinkDelay = float(config['portion_drink_delay']['delay'])
    print("macro start drink delay  %s " % str(drinkDelay))
    while True:
        time.sleep(0.001)
        drinkPortionWithInput(itemList, drinkDelay)

 

 

Then create a file named keyEvent.py in the folder where the drinkPortion.py file is located, and then repeat the code in the URL below. 

Https://gist.github.com/chriskiehl/2906125

At the top of the code, write down the text below. 

import win32API
import time
import win32con

To use this library, you need to lay out a library called Pywin32. The command below. 

pip install pywin32

 

If you have finished the task, run the Pycharm as an administrator and try to turn the code back on and go to POE and press the right-click and “F2” button. Then the potion will be eaten!



Subscribe to the Blog!!

You may also like...

Leave a Reply

Your email address will not be published.