Skip to content

Instantly share code, notes, and snippets.

@devxpy
Created May 14, 2025 21:30
Show Gist options
  • Save devxpy/11ed27cb15bbb259bdf67c249a85cc86 to your computer and use it in GitHub Desktop.
Save devxpy/11ed27cb15bbb259bdf67c249a85cc86 to your computer and use it in GitHub Desktop.
"""
README: Android UI Automator Script for Hinge App
This script automates the process of liking profiles in the Hinge Android app using the uiautomator2 library. It connects to an Android device, scrolls through the app, finds the like button, and presses it, then attempts to send the like. The process repeats in a loop with random delays and scrolls to mimic human behavior.
**Requirements:**
- Python 3.x
- [uiautomator2](https://github.com/openatx/uiautomator2) (`pip install uiautomator2`)
- An Android device with USB debugging enabled
- Hinge app installed on the device
- Device connected via USB or accessible over the network
**Usage:**
1. Connect your Android device and ensure it is discoverable by uiautomator2.
2. Install the required Python package: `pip install uiautomator2`
3. Run this script: `python python-android-ui.py`
4. The script will continuously scroll, find, and press the like button in the Hinge app, then attempt to send the like.
**Disclaimer:**
- Use this script responsibly and at your own risk. Automating app interactions may violate the app's terms of service.
"""
import uiautomator2 as u2
import time
import random
d = u2.connect()
def get_clickable_elements():
elements = d.xpath('//*[@clickable="true"]').all()
print(f"Found {len(elements)} clickable elements")
return elements
def random_scroll():
# Get screen size
width, height = d.window_size()
x = width // 2
# Add randomness to scroll start and end positions
start_y = int(height * random.uniform(0.55, 0.65))
end_y = int(height * random.uniform(0.35, 0.45))
d.swipe(x, start_y, x, end_y, duration=0.2)
print(f"Scrolled down from {start_y} to {end_y}")
time.sleep(random.uniform(0.2, 1.0))
i = 0
while True:
time.sleep(random.uniform(1.5, 3.5))
random_scroll()
# Step 1: Press the like button (resource-id: co.hinge.app:id/like_button)
like_btn = None
clickable_elements = get_clickable_elements()
for elem in clickable_elements:
if elem.attrib.get("resource-id") == "co.hinge.app:id/like_button":
like_btn = elem
break
if not like_btn:
print("Like button not found on the current screen.")
continue
print("Like button found. Pressing it...")
like_btn.click()
print("Like button pressed.")
time.sleep(random.uniform(1.5, 3.5))
clickable_elements = get_clickable_elements()
send_like_btn = clickable_elements and clickable_elements[-2]
if send_like_btn:
print("Send Like button found. Pressing it...")
send_like_btn.click()
print("Send Like button pressed.")
else:
print("Send Like button not found on the current screen.")
i += 1
print(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment