def render(self, offset = 0): # Border cprint("%s%s" % ((Cursor.UP(self.heightwb - offset) if offset <= self.heightwb else ''), '*' + '-' * (self.width + 2) + '*'), *self.borderstyle) for i in range(self.height): cprint("| %s |" % (' ' * self.width), *self.borderstyle) cprint("%s" % ('*' + '-' * (self.width + 2) + '*'), *self.borderstyle) print("%s" % Cursor.UP(self.heightwb), end = '') # CLI Name print("%s" % Cursor.FORWARD(3), end = '') print(self.title) # for l in range(self.height): # print("%s" % Cursor.FORWARD(), end = '') # print("%d" % self.cnt) for line in self.components: print("%s" % Cursor.FORWARD(2), end = '') for comp in line: print(comp, end = '') print('') # Footer print("%s" % Cursor.FORWARD(30), end = '') print(self.footer)
def ShowDownloadStatus(self): ''' Shows downloader info ''' content = self.DL.report(strings.DEBUG_DOWNLOAD_STATUS(None)) print(content, Cursor.UP(content.count('\n') + 1)) time.sleep(1)
def MEMORIA_INTERFAZ(): print(Style.BRIGHT + Fore.BLUE + Back.WHITE) print("Obteniendo...") for arch in ["cat", "proc", "meminfo"]: numero = random.randrange(1,2) sleep(numero-.5) print(Cursor.UP(1)+Cursor.FORWARD(20) +str(arch))
def SISTEMA_INTERFAZ(): print(Style.BRIGHT + Fore.RED + Back.BLACK) print("Obteniendo...") for arch in ["SO","Kernel","Procesador","Arquitectura"]: #pequeño truco para que se vea como más coqueto el programa numero = random.randrange(1,2) sleep(numero-.5) print(Cursor.UP(1)+Cursor.FORWARD(20) +str(arch))
def __printInfo(self, flag, listProcess): os.system("cls") process = None if listProcess.numberProcess() > 0: process = listProcess.getAcualProcess() numberBatch = self.__listBatch.numberBatch() if numberBatch == 0: numberBatch = 1 listProcess.printListProcessToExecute(1, 2, numberBatch - 1) print("\n") self.__listProcessFinish.printListCompleteOfProcess(80, 9) print("\n") print(Fore.RESET) print(Fore.LIGHTCYAN_EX + Cursor.FORWARD(46) + Cursor.UP(self.__cursorY) + "proceso en ejecucion", end="\n") print(Fore.RESET) if flag: self.__printProcessActual(process) self.__flagToContinuePrintProcess = True self.__statusOfInterruptionOutside(listProcess, process) else: self.__printProcessActual(process) print("\n\n\n\n") if not flag: self.__listProcessFinish.numberProcessComplete()
def enviarGenerar_datos(usuario1, usuario2, enviar, generar): from time import sleep init() if enviar == 1: print("Enviando Clave del Usuario", usuario1, "al Usuario", usuario2) if generar == 1: print("Generando Clave final para el usuario", usuario1, " ") for arch in range(101): sleep(0.01) print(Cursor.UP(1) + Cursor.FORWARD(42) + Fore.YELLOW + str(arch), "%") if enviar == 1: print( Cursor.UP(0) + Fore.GREEN + "----------------------> 'Enviado'" + Fore.RESET) if generar == 1: print( Cursor.UP(0) + Fore.GREEN + "..............'Hecho!'" + Fore.RESET)
def printListProcessToExecute(self, x, y, lotsPending): print(Fore.LIGHTRED_EX + Cursor.UP(y) + Cursor.FORWARD(x) + "Numero de lotes pendientes: ", lotsPending) print(Fore.RESET) for index in range(1, 6): if index >= len(self.__list): print(" ", end="\n") elif index < len(self.__list): print(Cursor.FORWARD(x) + "process: ", self.__list[index], end="\n")
def async_alert_str(*, terminal_columns: int, prompt: str, line: str, cursor_offset: int, alert_msg: str) -> str: """Calculate the desired string, including ANSI escape codes, for displaying an asynchronous alert message. :param terminal_columns: terminal width (number of columns) :param prompt: prompt that is displayed on the current line :param line: current contents of the Readline line buffer :param cursor_offset: the offset of the current cursor position within line :param alert_msg: the message to display to the user :return: the correct string so that the alert message appears to the user to be printed above the current line. """ from colorama import ( Cursor, ) # Split the prompt lines since it can contain newline characters. prompt_lines = prompt.splitlines() # Calculate how many terminal lines are taken up by all prompt lines except for the last one. # That will be included in the input lines calculations since that is where the cursor is. num_prompt_terminal_lines = 0 for line in prompt_lines[:-1]: line_width = style_aware_wcswidth(line) num_prompt_terminal_lines += int(line_width / terminal_columns) + 1 # Now calculate how many terminal lines are take up by the input last_prompt_line = prompt_lines[-1] last_prompt_line_width = style_aware_wcswidth(last_prompt_line) input_width = last_prompt_line_width + style_aware_wcswidth(line) num_input_terminal_lines = int(input_width / terminal_columns) + 1 # Get the cursor's offset from the beginning of the first input line cursor_input_offset = last_prompt_line_width + cursor_offset # Calculate what input line the cursor is on cursor_input_line = int(cursor_input_offset / terminal_columns) + 1 # Create a string that when printed will clear all input lines and display the alert terminal_str = '' # Move the cursor down to the last input line if cursor_input_line != num_input_terminal_lines: terminal_str += Cursor.DOWN(num_input_terminal_lines - cursor_input_line) # Clear each line from the bottom up so that the cursor ends up on the first prompt line total_lines = num_prompt_terminal_lines + num_input_terminal_lines terminal_str += (colorama.ansi.clear_line() + Cursor.UP(1)) * (total_lines - 1) # Clear the first prompt line terminal_str += colorama.ansi.clear_line() # Move the cursor to the beginning of the first prompt line and print the alert terminal_str += '\r' + alert_msg return terminal_str
def printListCompleteOfProcess(self, x, y): print( Cursor.UP(y) + Cursor.FORWARD(x) + Fore.GREEN + "Procesos completados") print(Fore.RESET) for index in range(0, len(self.__list)): print( Cursor.FORWARD(x) + self.__list[index].toStringProcessComplete())
def _update_status(self, message): if self._have_terminal: if self._console_state == ConsoleState.STATUS: cursor_position = Cursor.UP() else: cursor_position = "" print("%-80s" % (cursor_position + Style.BRIGHT + message + Style.RESET_ALL,)) self._console_state = ConsoleState.STATUS else: print(Style.BRIGHT + message + Style.RESET_ALL)
def _update_status(self, message): if self._have_terminal and not self._plain_terminal: if self._console_state == ConsoleState.STATUS: cursor_position = Cursor.UP() else: cursor_position = "" self._uprint(cursor_position, Style.BRIGHT, "%-80s" % message, Style.RESET_ALL) self._console_state = ConsoleState.STATUS else: self._uprint(Style.BRIGHT, message, Style.RESET_ALL)
def __printEnqueueBloquedProcess(self): print(Cursor.DOWN(2)) self.__bloqued_process.print_queue() print("\r" + Fore.LIGHTYELLOW_EX + "Contador del programa: ", str(self.__countProgram), end="") print(Fore.RESET) print(Cursor.UP(15)) self.__flag_unlock_process = is_time_bloqued_finish( self.__bloqued_process) calculate_bloqued_time(self.__bloqued_process) sleep(1)
def main(): colorama_init() c = Controller() c.find_joystick(False) while True: c.update_inputs() # Start Printout print_b(space_between(f'{Fore.BLUE}Controller Debug{Fore.CYAN}', c.get_joystick_name()), end='\n\n') CHECK = Fore.GREEN + str("✓") CROSS = Fore.RED + str("✗") # Joystick Position (js_changed, theta, magnitude) = c.get_joystick_pos_polar() print_b(f'{Fore.BLUE}Joystick Position {Fore.LIGHTBLACK_EX}(Polar)') print_b(space_between( f'{Fore.MAGENTA}θ = {theta:.2f}, |x| = {magnitude:.2f}', f'{Fore.LIGHTBLACK_EX}Changed? {CHECK if js_changed else CROSS}'), end='\n\n') # Trigger Position (trig_changed, lt, rt) = c.get_trigger_pos() print_b(f'{Fore.BLUE}Trigger Position {Fore.LIGHTBLACK_EX}(Percent)') print_b(space_between( f'{Fore.MAGENTA}lt% = {lt:.3f}, rt% = {rt:.3f}', f'{Fore.LIGHTBLACK_EX}Changed? {CHECK if trig_changed else CROSS}' ), end='\n\n') # Buttons print_b(f'{Fore.BLUE}Buttons {Fore.LIGHTBLACK_EX}(0 = Up, 1 = Down)') print_b( bool_symbol('A ', c.is_button_pressed(Button.A)) + bool_symbol('B ', c.is_button_pressed(Button.B)) + bool_symbol('X ', c.is_button_pressed(Button.X)) + bool_symbol('Y ', c.is_button_pressed(Button.Y)) + bool_symbol('↑ ', c.is_button_pressed(Button.DPAD_UP)) + bool_symbol('↓ ', c.is_button_pressed(Button.DPAD_DOWN)) + bool_symbol('← ', c.is_button_pressed(Button.DPAD_LEFT)) + bool_symbol('→ ', c.is_button_pressed(Button.DPAD_RIGHT)) + bool_symbol('LB ', c.is_button_pressed(Button.LEFT_BUMPER)) + bool_symbol('RB ', c.is_button_pressed(Button.RIGHT_BUMPER)) + bool_symbol('LS ', c.is_button_pressed(Button.LEFT_THUMB)) + bool_symbol('RS ', c.is_button_pressed(Button.RIGHT_THUMB))) # End Printout print_b('', end='\r' + Cursor.UP(10)) sleep(0.06)
def __printProcessActual(self, process): maximunTime = 1 idProgram = " " operation = " " timeRest = " " time = " " index = 1 if process is not None: maximunTime = process.getMaximumTime() idProgram = process.getNumberProgram() operation = str(process.getFirstNumber()) + " " +\ process.getOperation() + " "+str(process.getSecondNumber()) if process.getTimeTranscurred() > 0: index = process.getTimeTranscurred() print("\r" + Cursor.FORWARD(46) + "Operacion: " + operation, end="\n") print("\r" + Cursor.FORWARD(46) + "ID: " + str(idProgram), end="\n") while self.__flagToContinuePrintProcess: self.__interruption.listenInterruption() if index < maximunTime + 1: if process is not None: timeRest = maximunTime - index time = index print("\r" + Cursor.FORWARD(46) + "Tiempo transcurrido: " + str(time) + "\n" + Cursor.FORWARD(46) + "Tiempo restante: " + str(timeRest) + " ", end="") if process is not None: process.setTimeTranscurred(time) print(Cursor.DOWN(4)) self.__countProgram += 1 print("\r" + Fore.LIGHTYELLOW_EX + "Contador del programa: ", str(self.__countProgram), end="") print(Fore.RESET) print(Cursor.UP(8)) self.__statusOfInterruptionInside() if idProgram is not 0: sleep(1) else: break else: break index = index + 1
def __print_information_to_console(self, flag): os.system("cls") process = self.__ready_process.getactual_process() self.__ready_process.print_queue( 1, 2, self.__queue_new_process.numberProcess()) print("\n") self.__listProcessFinish.printListCompleteOfProcess(80, 10) print("\n") print(Fore.RESET) print(Fore.LIGHTCYAN_EX + Cursor.FORWARD(46) + Cursor.UP(self.__cursorY) + "proceso en ejecucion", end="\n") print(Fore.RESET) if flag: self.__refreshVisualInformation(process) if self.__flag_unlock_process: self.__enqueue_process_bloqued_to_ready() self.__flag_unlock_process = False else: self.__statusOfInterruptionOutside(process) if not flag: self.__refreshVisualInformation(process) self.__listProcessFinish.print_table_bcp()
def draw_object(level_object) -> None: handle = win32file.CreateFile( PIPE_NAME, win32file.GENERIC_READ | win32file.GENERIC_WRITE, 0, None, win32file.OPEN_EXISTING, 0, None) blocks_drawn = 0 for object_list in chunks(level_object.block_data, CHUNK_SIZE): print( indent( dedent(f''' {Fore.GREEN}Drawing blocks ({blocks_drawn}/{len(level_object.block_data)}) '''), " ")) object_string = ';'.join([str(x) for x in object_list]) + ';' win32file.WriteFile(handle, object_string.encode()) blocks_drawn += CHUNK_SIZE sleep(0.05) print((Cursor.UP() + colorama.ansi.clear_line()) * 3, end='')
def clear(self, offset = 0): print("%s%s" % (Cursor.UP(self.heightwb - offset), (' ' * self.widthwb + '\n') * self.heightwb)) print("%s" % (Cursor.UP(self.heightwb - offset + 1)), end = '')
def update_progress(self, num_frames, sample_rate): if self.args.has_log: return # log output until we run out of space on this line def output_what_fits(init, output_strings): print_str(init) w = 0 for _str in output_strings: _len = len(_str) if w + _len >= (self.term_width - 1): return print_str(_str) w += _len # make progress bar width flexible if self.term_width < 70: prog_width = 10 elif self.term_width < 100: prog_width = 40 - (100 - self.term_width) else: prog_width = 40 # song position/progress calculations if num_frames > 0 and sample_rate > 0: self.song_position += (num_frames * 1000) / sample_rate pos_seconds = self.song_position // 1000 dur_seconds = self.song_duration // 1000 pct = int(self.song_position * 100 // self.song_duration) \ if self.song_duration > 0 else 0 x = int(pct * prog_width // 100) # don't move cursor on first update if self.show_total: if self.move_cursor: print(Cursor.UP(2)) else: self.move_cursor = True # song output text output_strings = [ "Progress:", " [" + ("=" * x) + (" " * (prog_width - x)) + "]", " " + format_time(pos_seconds, dur_seconds) ] if self.song_eta is not None: _spaces = max(22 - len(output_strings[2]), 1) * " " output_strings.append(_spaces) _str = "(~" + \ format_time(self.song_eta, short=True) + " remaining)" output_strings.append(_str) output_what_fits("\r\033[2K", output_strings) if self.show_total: # total position/progress calculations total_position = self.total_position + self.song_position total_pos_seconds = total_position // 1000 total_dur_seconds = self.total_duration // 1000 total_pct = int(total_position * 100 // self.total_duration) \ if self.total_duration > 0 else 0 total_x = int(total_pct * prog_width // 100) # total output text output_strings = [ "Total:", " [" + ("=" * total_x) + (" " * (prog_width - total_x)) + "]", " " + format_time(total_pos_seconds, total_dur_seconds) ] if self.total_eta is not None: _spaces = max(22 - len(output_strings[2]), 1) * " " output_strings.append(_spaces) _str = "(~" + format_time(self.total_eta, short=True) + \ " remaining)" output_strings.append(_str) output_what_fits("\n\033[2K", output_strings)
def draw_screen(self, xxx_todo_changeme, r): """Paint screen with rendered canvas.""" # quick return if nothing has changed if r is self._screen_buf_canvas: return (cols, rows) = xxx_todo_changeme assert self._started assert r.rows() == rows, "canvas size and passed size don't match" print(Cursor.POS() + Cursor.UP(), end='') output = '' y = -1 for row in r.content(): y += 1 first = True lasta = None nr = 0 for a, cs, seg in row: if cs != 'U': seg = seg.translate(UNPRINTABLE_TRANS_TABLE) assert isinstance(seg, bytes) if first or lasta != a: output += self._setattr(a) #print(self._setattr(a), end='') lasta = a try: if cs in ("0", "U"): for i in range(len(seg)): #print('\u2592', end='') #output += chr(seg[i])#.decode('cp850') output += '#' #output += fix_box_draw[chr(seg[i])]#.decode('cp850') #output += '\u2592' #print(0x400000 + seg[i], end='') else: assert cs is None if PYTHON3: assert isinstance(seg, bytes) output += seg.decode('cp850') #print(seg.decode('850'), end='') else: output += seg #print(seg, end='') except: raise Exception # it's ok to get out of the # screen on the lower right #if (y == rows-1 and nr == len(row)-1): # pass #else: # perhaps screen size changed # quietly abort. # return nr += 1 #self.cmd.set_cursor_position((1,1)) #import sys #sys.stdout.write(output) #self._clear() #print(output[:-1], end='') print(output, end='') #bug = '# win32 warning: droped terminal last row to avoid flickering' #bug_style = Fore.BLACK + Style.BRIGHT + Back.BLACK + bug #print(' '*(cols-len(bug)-1) + bug_style, end='') #self.cmd.set_cursor_position((rows+1, cols)) #self.cmd.set_cursor_position((1, 1)) try: x, y = r.cursor self.cmd.set_cursor_position((y + 1, x + 1)) except: pass self._screen_buf_canvas = r
def up(n): return Cursor.UP(n)
def clear_line(number_of_lines: int) -> None: print((Cursor.UP() + colorama.ansi.clear_line()) * number_of_lines, end='')
#!/usr/bin/env python3 from time import sleep from colorama import Cursor, init, Fore init() print("Copiando archivos... ") for arch in ["111", "222", "333", "444", "555"]: sleep(1) print(Cursor.UP(1) + Cursor.FORWARD(20) + Fore.YELLOW + str(arch)) print(Cursor.POS(25, 2) + Fore.GREEN + ">>> Proceso finalizado")
+ Téléchargez mon CV depuis le + + lien présent dans le post. + + ( https://bit.ly/3idwFOz ) + + N'hésitez pas à visiter mon + + profil LinkedIn: + + https://www.linkedin.com/in/lf-henao/ + + Email: [email protected] + +++++++++++++++++++++++++++++++++++++++++""" init() for char in ok: print(Fore.YELLOW + Back.BLUE + char + Back.RESET, end="", flush=True) sleep(0.07) print(Cursor.UP(1) + "\n") for char in find: print(Fore.YELLOW + Back.BLUE + char, end="", flush=True) sleep(0.07) print(Back.RESET, Cursor.UP(1) + '\n') print( Fore.BLUE + Back.WHITE + "Searching: \"le meilleur alternant en Web Dev à Paris\"", emoji.emojize(':detective:')) for i in range(12): sleep(0.3) print(Cursor.UP(1) + Cursor.FORWARD(55) + "." * i)
def move_up(self, index): """ return char to move up to index and update current """ diff = self.current - index self.current -= diff return Cursor.UP(diff)
def _clear_status(self): if not self._plain_terminal and self._console_state == ConsoleState.STATUS: self._uprint(Cursor.UP(), 80 * " ")
def main(): pymem_hook() os.system(f'title {__program_name__}') print( dedent(f'''\ {Fore.CYAN}{__program_name__} v{__version__} by {__author__} {Fore.MAGENTA}Randomize menu music every time you return to the menu. Usage: Simply copy files to <game installation folder>\\Resources\\Menu Music. The program will help you create and open it if it doesn't exist. Known issue: - Music will reset when returning to the title screen ''')) game = pymem.Pymem() while True: no_music_message_printed = False # only print hint message once while True: pid = get_process_id_by_window('GLFW30', 'Geometry Dash') if not pid: if not no_music_message_printed: print( f'{Fore.RED}Waiting for Geometry Dash... Please make sure the game is opened.' ) no_music_message_printed = True time.sleep(1) else: game.open_process_from_id(pid) print(f'{Fore.GREEN}Game loaded.') break # get os encoding to correctly decode ascii characters os_encoding = locale.getpreferredencoding() game_file_path = Path( game.process_base.filename.decode(os_encoding)).resolve() game_file_size = game_file_path.stat().st_size # check whether game version is 2.113 by file size correct_game_file_size = 6854144 if game_file_size != correct_game_file_size: print( f'{Fore.RED}Your game version is not 2.113 ' f'(exe size is {game_file_size} bytes, should be {correct_game_file_size} bytes)' ) print(f'{Fore.RED}Press any key to exit the program.') msvcrt.getch() sys.exit(1) # patch the memory offsets = [ 0x24530, 0x24977, 0x249a4, 0xce8a8, 0x14bb1c, 0x1583ec, 0x18cefc, 0x1907ef, 0x1ddf5c, 0x20d9e2, 0x21f989, 0x22471b, 0x22b308 ] new_address = game.allocate(4 * 1024) for offset in offsets: address = get_multi_level_offset(game, [offset]) game.write_uint(address, new_address) game.write_string(new_address, 'menuLoop.mp3' + '\x00') game_directory = game_file_path.parent music_directory = game_directory / 'Resources' / 'Menu Music' if not music_directory.exists(): os.mkdir(music_directory) os.startfile(music_directory) print(f'{Fore.GREEN}Searching music in {music_directory}') no_music_message_printed = False music_found_previously = False try: while True: music_files = [ item for item in music_directory.glob('*') if item.is_file() ] if not music_files: if not no_music_message_printed: print( fr'{Fore.RED}There are no music files in Resources\Menu Music directory. ' 'Menu song restored to default.') no_music_message_printed = True game.write_string(new_address, 'menuLoop.mp3' + '\x00') # restore to default menu music music_found_previously = False else: if music_found_previously: # clear the previous line to make "Found x music" always on the same line print(Cursor.UP() + colorama.ansi.clear_line(), end='') print(f'{Fore.GREEN}Found {len(music_files)} music.') music_file = random.choice(music_files) game.write_string(new_address, str(music_file.resolve()) + '\x00') no_music_message_printed = False music_found_previously = True time.sleep(1) except pymem.exception.MemoryWriteError as err: # check whether exception is caused by game close or unexpected errors all_process_id = [ process.th32ProcessID for process in pymem.process.list_processes() ] if game.process_id not in all_process_id: continue raise finally: game.close_process()
def up(self, count): self.print(Cursor.UP(count), end='')
def _clear_status(self): if self._console_state == ConsoleState.STATUS: print(Cursor.UP() + (80 * " "))
def up_screen(fix_count=1): for i in range(width * fix_count): print(cursor.BACK()) for i in range(height * fix_count): print(cursor.UP())
from colorama import Cursor up = lambda n=1: print(Cursor.UP(n), end="") down = lambda n=1: print(Cursor.DOWN(n), end="") left = lambda n=1: print(Cursor.BACK(n), end="") right = lambda n=1: print(Cursor.FORWARD(n), end="") pos = lambda x, y: print(Cursor.POS(x, y), end="") class cursor: def __init__(self): pos(0, 0) self.x = 0 self.y = 0 self.saved_positions = {} def down(self, n=1): self.y += n pos(self.x, self.y) def up(self, n=1): self.y -= n pos(self.x, self.y) def right(self, n=1): self.x += n pos(self.x, self.y) def left(self, n=1): self.x -= n