snap
unknown
python
a year ago
2.3 kB
18
Indexable
import time
import pyautogui
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout
class SnapchatAutomationApp(App):
def build(self):
layout = BoxLayout(orientation='vertical')
start_button = Button(text='Start Automation', size_hint=(1, 0.2))
start_button.bind(on_press=self.start_automation)
layout.add_widget(start_button)
return layout
def start_automation(self, instance):
self.run_automation()
def run_automation(self):
# Open Snapchat
pyautogui.hotkey('home')
time.sleep(1)
pyautogui.click(x=100, y=100) # Adjust x, y to the location of Snapchat icon on the home screen
time.sleep(5) # Wait for Snapchat to open
while True:
self.hold_resource_id("com.snapchat.android:id/camera_capture_button", 5)
time.sleep(0.5) # Wait for any resulting action
self.click_resource_id("com.snapchat.android:id/sent_to_button_label_mode_view")
self.scroll_up(steps=1) # Adjust the number of steps as needed
self.click_resource_id("com.snapchat.android:id/send_to_last_snap") # select last people
time.sleep(0.5) # Wait for the send_to_last_snap button to be visible
self.click_resource_id("com.snapchat.android:id/send_to_send_button") # send button
self.click_resource_id("com.snapchat.android:id/ngs_camera_icon_container")
time.sleep(5) # Wait for 5 seconds before repeating the actions
def hold_resource_id(self, resource_id, duration):
print(f"Holding down on resource ID '{resource_id}' for {duration} seconds...")
# Implement holding functionality with pyautogui
def click_resource_id(self, resource_id):
print(f"Clicking on resource ID '{resource_id}'...")
# Implement clicking functionality with pyautogui
def scroll_up(self, steps=1):
print("Scrolling up...")
for _ in range(steps):
pyautogui.scroll(1)
time.sleep(1) # Adjust as needed to ensure the scroll completes
if __name__ == "__main__":
SnapchatAutomationApp().run()
Editor is loading...
Leave a Comment