Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import win32clipboard
- from time import sleep
- from pywinauto.application import Application
- from pywinauto.keyboard import send_keys
- from pywinauto.mouse import move
- from pywinauto.findwindows import WindowNotFoundError
- from pywinauto.findwindows import ElementNotFoundError
- from win32api import GetKeyState
- from win32con import VK_NUMLOCK
- from pywinauto.timings import Timings
- from pywinauto.timings import TimeoutError
- from ctypes import windll
- Timings.fast()
- ###
- def item_data():
- try:
- win32clipboard.OpenClipboard()
- data = win32clipboard.GetClipboardData()
- win32clipboard.CloseClipboard()
- except TypeError:
- return dict()
- # print (data)
- if windll.user32.OpenClipboard(None):
- windll.user32.EmptyClipboard()
- windll.user32.CloseClipboard()
- properties = {}
- itemdata = data.split('\n')
- if len(itemdata) > 1:
- properties['name'] = itemdata[1]
- for line in itemdata:
- key_value = line.split(': ')
- if len(key_value) == 2:
- key,value = key_value
- properties[key] = value
- return properties
- def get_key(dic,key):
- if key in dic:
- return dic[key]
- else:
- return ''
- def select_tab(key):
- global last_selected_tab
- if last_selected_tab != key:
- app.window(title=appname).click_input(button='left', coords=(tab[key], tab_y))
- sleep(0.1)
- app.window(title=appname).click_input(button='left', coords=(tab[key], tab_y))
- sleep(0.1)
- last_selected_tab = key
- ###
- last_selected_tab = ''
- cell_size = 50
- grid = 10,5
- # grid = 9,5
- # grid = 1,1
- base = 1335, 598
- tab_y = 159
- tab = {}
- tab['orb'] = 60 * 1
- tab['ess'] = 60 * 2
- tab['frg'] = 60 * 3
- tab['map'] = 60 * 4
- tab['div'] = 60 * 5
- tab['gcp'] = 60 * 6
- tab['chm'] = 60 * 7
- tab['unq'] = 60 * 8
- tab['tmp'] = 60 * 9
- rgb = ["R-G-B","R-B-G","B-R-G","B-G-R","G-R-B","G-B-R"]
- appname = "Path of Exile"
- app = Application().connect(title=appname)
- print (appname)
- ###
- while(True):
- if GetKeyState(VK_NUMLOCK):
- for x in range(0,grid[0]):
- if not GetKeyState(VK_NUMLOCK): break
- for y in range(0,grid[1]):
- if not GetKeyState(VK_NUMLOCK): break
- try:
- move(coords=(base[0]+cell_size*x, base[1]+cell_size*y))
- send_keys('^c')
- sleep(0.5)
- data = item_data()
- if get_key(data,'Rarity').startswith('Currency') and 'Essence of' in get_key(data,'name'):
- select_tab('ess')
- elif get_key(data,'Rarity').startswith('Currency'):
- select_tab('orb')
- elif get_key(data,'Rarity').startswith('Divination Card'):
- select_tab('div')
- elif len(get_key(data,'Map Tier')):
- select_tab('map')
- elif get_key(data,'Rarity').startswith('Unique'):
- select_tab('unq')
- elif any(substring in get_key(data,'Sockets') for substring in rgb):
- select_tab('chm')
- elif get_key(data,'Rarity').startswith('Gem') and len(get_key(data,'Quality')):
- select_tab('gcp')
- elif len(data):
- select_tab('tmp')
- else:
- continue
- sleep(0.5)
- app.window(title=appname).click_input(button='left', coords=(base[0]+cell_size*x, base[1]+cell_size*y),pressed='control')
- sleep(0.3)
- app.window(title=appname).click_input(button='left', coords=(base[0]+cell_size*x, base[1]+cell_size*y),pressed='control')
- sleep(0.3)
- except (WindowNotFoundError, ElementNotFoundError, TimeoutError):
- break
- sleep(0.1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement