Skip to content

Commit

Permalink
Adjustments to language in wizard, changes to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
nchietala committed Mar 1, 2024
1 parent 4d977b5 commit 6da475b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 34 deletions.
13 changes: 9 additions & 4 deletions AutoADB.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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"
)
Expand Down
34 changes: 4 additions & 30 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.

0 comments on commit 6da475b

Please sign in to comment.