diff --git a/AutoADB.py b/AutoADB.py index 1a43638..d51a091 100644 --- a/AutoADB.py +++ b/AutoADB.py @@ -69,7 +69,7 @@ def add_service(self, _, service_type, name): if short_name not in self.names: self.names.append(short_name) self.infos.append(zeroconf.get_service_info(service_type, name)) - print(f"\r{len(self.names)}: {short_name}\n Which service? ", end="") + print(f"\r{len(self.names)}: {short_name}\n Which service (input row number only)? ", end="") def update_service(self, *_, **__): pass @@ -129,7 +129,7 @@ def main(service_name: str, script_path: str, silent: bool): execute = [sys.executable, service_name] if script_path: execute.extend(["-p", script_path]) - Popen(execute, creationflags=subprocess.CREATE_NO_WINDOW) + t = Popen(execute, creationflags=subprocess.CREATE_NO_WINDOW) return listener = AdbListener(service_name, script_path) @@ -144,7 +144,8 @@ def main(service_name: str, script_path: str, silent: bool): listener = SetupListener() ServiceBrowser(zeroconf, "_adb-tls-connect._tcp.local.", listener) - print("Searching for ADB services...") + print("Ensure android device has wireless debugging enabled and is on the same network\n" + "Searching for ADB services...") index = -1 while index < 0 or index >= len(listener.names): # noinspection PyBroadException @@ -168,8 +169,12 @@ def main(service_name: str, script_path: str, silent: bool): pairing_conf.close() if input("Automate connection? (Y/n) ").lower().strip()[:1] in "1yt": + arguments = f"{listener.names[0]} -s" script_path = input("Enter automated command to run on connection (default blank): ") - arguments = f"{listener.names[index]}{(' -p ' + script_path) if script_path else ''} -s" + if script_path: + script_path = script_path.replace('"', '^"') + arguments += f' -p "{script_path}"' + shortcut_path = os.path.join( os.environ["APPDATA"], r"Microsoft\Windows\Start Menu\Programs\Startup", f"AutoADB.lnk" ) diff --git a/Readme.md b/Readme.md index fc5e7f4..7ddd90e 100644 --- a/Readme.md +++ b/Readme.md @@ -26,34 +26,13 @@ cases, but it was not developed with those in mind. ### Installation -1. **Download the Executable**: Download the latest version of the `AutoADB.exe` from the Releases section. -2. **Place the Executable**: Put the `.exe` file in a convenient location on your system. +Download the latest release. The process runs from a standalone executable, there is no installation. -### Configuration +### Configuration / Usage -1. **Create a Shortcut**: Right-click on the `AutoADB.exe` and create a shortcut. -2. **Modify the Shortcut Target**: Right-click the shortcut, go to Properties, and modify the Target field by adding the Android device name and the optional script path. For example: +Run the executable. It is a command line tool and when launched without options it will create a terminal wizard to configure the android device and to automate its own startup. -``` -"path\to\AutoADB.exe" adb-0123456789ABCD-XXXXXX -p C:\Users\MyUserName\Desktop\scrcpy-noconsole.lnk -``` -or if you're not interested in automating an external script: -``` -"path\to\AutoADB.exe" adb-0123456789ABCD-XXXXXX -``` -You **must** specify the adb service name, the applicaiton will not run without knowing which android device to connect to. - -3. **Add to Startup**: Place the shortcut in your startup folder to have it run automatically at system startup. The startup folder can typically be found at: - -``` -C:\Users\MyUserName\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup -``` - -4. Use the Android developer settings to enable wireless debugging, use adb to pair your computer to your device - -## Usage - -Once configured, the tool will automatically start with your system, immediately beginning to listen for the specified Android device's ADB service advertisements. When detected, it will connect to the device and, if configured, execute your specified script. +If you choose to automate the connection you will be asked to specify a command to run when the connection is made, in my case the command is `scrcpy-noconsole` ## Building and Contributing @@ -63,11 +42,6 @@ This was created using pyinstaller on python 3.9.13 2. Install packages: `pip install -r requirements.txt` 3. Run PyInstaller with the script: `pyinstaller --onefile --hidden-import=zeroconf._utils.ipaddress --hidden-import=zeroconf._handlers.answers -w .\AutoADB.py` -## Tentative future plans - -- I may add a feature to allow the app to make it easier to browse and copy adb service names -- I may add a feature to allow the app to generate and display adb pairing QR codes - ## License This project is licensed under the MIT License - see the LICENSE file for details.