def kill_counter(): try: r = reader.D2Reader() r.map_ptrs() # r.unit_map = dict() except other_utils.pymem_err_list: messagebox.showerror( 'No process', 'Diablo not opened. Start Diablo and then start the kill counter again' ) sys.exit() root = tk.Tk() root.wm_attributes("-topmost", 1) sv = tk.StringVar() # sv2 = tk.StringVar() def add_to_killed(): try: ingame = r.in_game() except other_utils.pymem_err_list: messagebox.showerror( 'No process', 'Diablo not opened. Start Diablo and then start the kill counter again' ) sys.exit() if not ingame: r.observed_guids = set() r.dead_guids = [] r.kill_counts = defaultdict(lambda: 0) sv.set('') else: r.update_dead_guids() sv.set('\n'.join( ['%s: %s' % (k, v) for k, v in r.kill_counts.items()])) # sv2.set('\n'.join([str(x) for x in sorted(r.unit_map)])) # sv2.set('\n'.join(['%s: %s' % (k, v) for k, v in r.unit_map.items()])) root.after(50, add_to_killed) add_to_killed() tk.Label(root, text='killcount').pack() tk.Label(root, textvariable=sv).pack() # tk.Label(root, textvariable=sv2).pack() root.mainloop()
def load_memory_reader(self, show_err=True): err = None d2_game_open = reader.process_exists(reader.D2_GAME_EXE) d2_se_open = reader.process_exists(reader.D2_SE_EXE) if not self.is_user_admin: err = ( 'Elevated access rights', 'You must run the app as ADMIN to initialize memory reader for advanced automode.\n\nDisabling advanced automode.' ) self.d2_reader = None elif self.automode != 2: err = ( 'Automode option', 'Automode has not been set to "Advanced" - Will not initiate memory reader' ) self.d2_reader = None elif reader.number_of_processes_with_names( [reader.D2_GAME_EXE, reader.D2_SE_EXE]) > 1: err = ( 'Number of processes', 'Several D2 processes have been opened, this bugs out the memory reader.\n\nDisabling advanced automode.' ) self.d2_reader = None elif not d2_game_open and not d2_se_open: self.d2_reader = None else: process_name = reader.D2_SE_EXE if d2_se_open else reader.D2_GAME_EXE try: self.d2_reader = reader.D2Reader(process_name=process_name) if self.d2_reader.dlls_loaded: self.d2_reader.map_ptrs() if not self.d2_reader.patch_supported: err = ( 'D2 version error', 'Advanced automode currently only supports D2 patch versions 1.13c, 1.13d and 1.14d, your version is "%s".\n\nDisabling automode.' % self.d2_reader.d2_ver) else: self.d2_reader = None except other_utils.pymem_err_list as e: logging.debug('Load reader error: %s' % e) self.d2_reader = None if err is not None and (not self.advanced_error_thrown or show_err): self.advanced_error_thrown = True messagebox.showerror(*err) else: self.advanced_error_thrown = False