diff --git a/android_tv_rc/adb_client.py b/android_tv_rc/adb_client.py index 6b26fca..5880730 100644 --- a/android_tv_rc/adb_client.py +++ b/android_tv_rc/adb_client.py @@ -760,6 +760,8 @@ def send_keyevent_input(self, keycode: KeyCodes, long_press: bool=False): keycode (KeyCode): the keycode to send, table of key codes: https://www.temblast.com/ref/akeyscode.htm long_press (bool): specify if simulate a long press for the key or not. Defaults to False. """ + if self.__selected_device is None: + return command = f'input keyevent {keycode.name}' if long_press: command += ' --longpress' @@ -775,5 +777,7 @@ def send_text_input(self, text: str, encode_spaces: bool=True): text (str): the text string to send. encode_spaces (bool): specify if spaces should be replaced by `%s` or not. Defaults to True. """ + if self.__selected_device is None: + return processed_text = text.replace(' ', '%s') if encode_spaces else text self.execute_shell_command(f'input text {processed_text}')