def get_handles(self): """ Gets all the wizard handles get_clients should be called over this """ current_handles = utils.get_all_wizard_handles() if not current_handles: raise RuntimeError("No handles found") self.window_handles = current_handles
def get_new_clients(self) -> List[Client]: """ Get all new clients currently not managed Returns: List of new clients added """ all_handles = utils.get_all_wizard_handles() new_clients = [] for handle in all_handles: if handle not in self._managed_handles: self._managed_handles.append(handle) new_client = self.client_cls(handle) self.clients.append(new_client) new_clients.append(new_client) return new_clients
def wiz_command(): """ called when someone uses the "wiz" console command """ try: login_flag = sys.argv[1] except IndexError: utils.quick_launch() return if login_flag != "--login": print(f"{login_flag} is not a valid flag") return try: username = sys.argv[2] except IndexError: print("Missing username") return try: password = sys.argv[3] except IndexError: print("Missing password") return utils.quick_launch() # speed is the name :sunglasses: import time # this probably isn't enough time for some computers time.sleep(7) handles = utils.get_all_wizard_handles() newest_handle = sorted(handles)[-1] utils.wiz_login(newest_handle, username, password)
try: code = keycode_map[key.upper()] msg = 0x101 if event else 0x100 # https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendmessagew # https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-keydown user32.PostMessageW(self.window_handle, msg, code, 0) except KeyError: print("Invalid key provided") if __name__ == "__main__": """ Some tests """ from wizwalker.utils import get_all_wizard_handles try: window_handle = get_all_wizard_handles()[0] except IndexError: print("No running wizard101 windows") exit(0) keyboard = Keyboard(window_handle) async def say_hello(): keyboard.type_key("\r") await asyncio.sleep(0.2) keyboard.type_string("Hello world!\r") async def test(): # Hold down 2 keys keyboard.key_down("D") keyboard.key_down("W")