diff --git a/Bluestacks/adbserver_manager.py b/Bluestacks/adbserver_manager.py new file mode 100644 index 0000000..af3b848 --- /dev/null +++ b/Bluestacks/adbserver_manager.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +""" +INITIAL CREATION: Rawrafied 1/3/25 +DESCRIPTION: + - Main script to instantiate Last War Bot environment. +""" +# LIBRARY IMPORTS: ################################ +#import sys +#import os +import subprocess +#path = os.getcwd() # Check current directory's path + +import time + +from ppadb.client import Client as AdbClient + +# ADBSERVER_MANAGER CLASS FUNCTIONS: ########################## +class adbserver_manager(): + # MAIN FUNCTION: + def __init__(self, verbose): + # INITIALIZE CLASS VARIABLES + self.verbose = verbose + + # INITIAL FUNCTION CALLS + print("INITIALIZING ADBSERVER_MANAGER") + self.run_server() + + # INITIALIZE ADBSERVER TO INTERFACE WITH BLUESTACKS + def run_server(self): + # Run the adb server + adbexe_hc = "C:/Users/talks/AppData/Local/Android/Sdk/platform-tools/adb.exe" + #os.startfile(adbexe_hc) + self.adbserver = subprocess.run([adbexe_hc, "start-server"]) + + # List all devices + #apk_path = "example.apk" + #"HD-Player.exe" + + # Default is local host "127.0.0.1" and 5037 + self.clients = AdbClient(host="127.0.0.1", port=5037) + self.devices = self.clients.devices() + + if self.verbose: + print ("client =\n" + str(self.clients)) + print ("devices =\n" + str(self.devices)) + + # CHECK IF NO DEVICES ARE RUNNING + if len(self.devices) == 0: + print("NO DEVICES RUNNING") + # OPEN VP BOT BLUESTACKS + lastwarexe = "C:\Program Files\BlueStacks_nxt\HD-Player.exe" + instancet2r = "Pie64" + #instancet2r = "Pie64_1" + lastwarapp = 'com.fun.lastwar.gp' + # CALL THE ANDROID-APP/PACKAGE VIA THE ADB SHELL COMMAND + subprocess.run([lastwarexe, "shell", "--instance", instancet2r, "--cmd", "launchApp", "--package", 'com.fun.lastwar.gp']) + time.sleep(20) #PAUSE FOR 20 SECS + # CALL THE AUTOCLICKER APP + + + \ No newline at end of file diff --git a/Bluestacks/vpbot.py b/Bluestacks/vpbot.py new file mode 100644 index 0000000..88bc83b --- /dev/null +++ b/Bluestacks/vpbot.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +""" +INITIAL CREATION: Rawrafied 1/3/25 +DESCRIPTION: + - Main script to instantiate Last War Bot environment. +""" +# LIBRARY IMPORTS: ################################ +#import sys +#import os +#import subprocess +#path = os.getcwd() # Check current directory's path + +#import pytessract + +# BOT LIBRARY FILES +import adbserver_manager + +# TESTING VARIABLES: ############################## +# Variables: +verbose = 1 + +if verbose: + print ("test") + +# VPBOT CLASS FUNCTIONS: ########################## +# MAIN FUNCTION: +def main(): + print("INITIALIZING VPBOT INTELLIGENCE ASSISTANCE CODE") + adbmgr = adbserver_manager.adbserver_manager(verbose) + + +# MAIN SOFTWARE ################################### +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/Windows/ImageRef/Screenshot 2025-02-08 211603.png b/Windows/ImageRef/Screenshot 2025-02-08 211603.png new file mode 100644 index 0000000..2101cf3 Binary files /dev/null and b/Windows/ImageRef/Screenshot 2025-02-08 211603.png differ diff --git a/Windows/ImageRef/Screenshot 2025-02-08 212424.png b/Windows/ImageRef/Screenshot 2025-02-08 212424.png new file mode 100644 index 0000000..9abd7ed Binary files /dev/null and b/Windows/ImageRef/Screenshot 2025-02-08 212424.png differ diff --git a/Windows/ImageRef/Screenshot 2025-02-09 163615.png b/Windows/ImageRef/Screenshot 2025-02-09 163615.png new file mode 100644 index 0000000..3209b2a Binary files /dev/null and b/Windows/ImageRef/Screenshot 2025-02-09 163615.png differ diff --git a/Windows/adbserver_manager.py b/Windows/adbserver_manager.py new file mode 100644 index 0000000..af3b848 --- /dev/null +++ b/Windows/adbserver_manager.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +""" +INITIAL CREATION: Rawrafied 1/3/25 +DESCRIPTION: + - Main script to instantiate Last War Bot environment. +""" +# LIBRARY IMPORTS: ################################ +#import sys +#import os +import subprocess +#path = os.getcwd() # Check current directory's path + +import time + +from ppadb.client import Client as AdbClient + +# ADBSERVER_MANAGER CLASS FUNCTIONS: ########################## +class adbserver_manager(): + # MAIN FUNCTION: + def __init__(self, verbose): + # INITIALIZE CLASS VARIABLES + self.verbose = verbose + + # INITIAL FUNCTION CALLS + print("INITIALIZING ADBSERVER_MANAGER") + self.run_server() + + # INITIALIZE ADBSERVER TO INTERFACE WITH BLUESTACKS + def run_server(self): + # Run the adb server + adbexe_hc = "C:/Users/talks/AppData/Local/Android/Sdk/platform-tools/adb.exe" + #os.startfile(adbexe_hc) + self.adbserver = subprocess.run([adbexe_hc, "start-server"]) + + # List all devices + #apk_path = "example.apk" + #"HD-Player.exe" + + # Default is local host "127.0.0.1" and 5037 + self.clients = AdbClient(host="127.0.0.1", port=5037) + self.devices = self.clients.devices() + + if self.verbose: + print ("client =\n" + str(self.clients)) + print ("devices =\n" + str(self.devices)) + + # CHECK IF NO DEVICES ARE RUNNING + if len(self.devices) == 0: + print("NO DEVICES RUNNING") + # OPEN VP BOT BLUESTACKS + lastwarexe = "C:\Program Files\BlueStacks_nxt\HD-Player.exe" + instancet2r = "Pie64" + #instancet2r = "Pie64_1" + lastwarapp = 'com.fun.lastwar.gp' + # CALL THE ANDROID-APP/PACKAGE VIA THE ADB SHELL COMMAND + subprocess.run([lastwarexe, "shell", "--instance", instancet2r, "--cmd", "launchApp", "--package", 'com.fun.lastwar.gp']) + time.sleep(20) #PAUSE FOR 20 SECS + # CALL THE AUTOCLICKER APP + + + \ No newline at end of file diff --git a/Windows/appwindow_manager_pywin.py b/Windows/appwindow_manager_pywin.py new file mode 100644 index 0000000..e724cc4 --- /dev/null +++ b/Windows/appwindow_manager_pywin.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +""" +INITIAL CREATION: Rawrafied 1/3/25 +DESCRIPTION: + - Class to manage interfacing with application +""" +# LIBRARY IMPORTS: ################################ +import pywinauto +import pyautogui + + +import subprocess +import time + +# ADBSERVER_MANAGER CLASS FUNCTIONS: ########################## +class appwindow_manager_pywin(): + # MAIN FUNCTION: + def __init__(self, verbose): + # INITIALIZE CLASS VARIABLES + self.verbose = verbose + self.appexedir = str('C:\\Users\\talks\\AppData\\Local\\TheLastWar\\Launch.exe') + self.appopen = 0 + + # INITIAL FUNCTION CALLS + print("INITIALIZING APPWINDOW_MANAGER") + self.open_window() + self.gotovpscreen() + + # INITIALIZE CONNECTION BETWEEN SCRIPT AND APP + def open_window(self): + self.AppWindow = pywinauto.application().connection(title="Last War-Survival") + print (self.AppWindow) + + + # FUNCTION TO OPEN SECRETARY POSITION SCREEN: + def gotovpscreen(self): + print("GOING TO VP DISPLAY") + + \ No newline at end of file diff --git a/Windows/appwindow_manager_win.py b/Windows/appwindow_manager_win.py new file mode 100644 index 0000000..295d071 --- /dev/null +++ b/Windows/appwindow_manager_win.py @@ -0,0 +1,129 @@ +# -*- coding: utf-8 -*- +""" +INITIAL CREATION: Rawrafied 1/3/25 +DESCRIPTION: + - Class to manage interfacing with application +""" +# LIBRARY IMPORTS: ################################ +import win32gui +import win32con +import win32api + +import subprocess +import time +from datetime import datetime + +#TODO: Move to its own library +import pytesseract +from PIL import Image + +# ADBSERVER_MANAGER CLASS FUNCTIONS: ########################## +class appwindow_manager(): + # MAIN FUNCTION: + def __init__(self, verbose): + # INITIALIZE CLASS VARIABLES + self.verbose = verbose + self.appexedir = str('C:\\Users\\talks\\AppData\\Local\\TheLastWar\\Launch.exe') + #self.appexedir = str('LastWar') + self.appopen = 0 + + # INITIAL FUNCTION CALLS + print("INITIALIZING APPWINDOW_MANAGER") + self.open_window() + self.gotovpscreen() + print("INITIALIZATION DONE; RUNNING VP\nNOTE: Code is in progress. Temporary solution to exit program is by opening task manager via 'ctrl + shift + esc'") + while True: + self.runvp() + currentmin = datetime.now().strftime("%M") + print("Current min = "+currentmin) + if int(currentmin) % 15 == 0: + subprocess.call("TASKKILL /F /IM LastWar.exe", shell=True) + # Restart program every 5 mins + time.sleep(2) + currenttime = datetime.now().strftime("%H:%M") + print("INITIALIZING APPWINDOW_MANAGER @ "+str(currenttime)) + self.open_window() + self.gotovpscreen() + print("INITIALIZATION DONE; RUNNING VP\nNOTE: Code is in progress. Temporary solution to exit program is by opening task manager via 'ctrl + alt + del'") + + + + # INITIALIZE CONNECTION BETWEEN SCRIPT AND APP + def open_window(self): + self.AppWindow = win32gui.FindWindow(None, "Last War-Survival Game") + print (self.AppWindow) + + if self.AppWindow: + win32gui.ShowWindow(self.AppWindow, win32con.SW_RESTORE) + AppWindowChild = win32gui.GetWindow(self.AppWindow,win32con.GW_CHILD) + print (AppWindowChild) + self.appopen = 1 + else: + print("APP NOT OPEN; OPENING...") + subprocess.call(self.appexedir) + #subprocess.call("LastWar.exe") + WAITTIME = 20 + time.sleep(WAITTIME) + if self.verbose: + print("WAITED " + str(WAITTIME) + " SECS") + self.opengamescenarios() + + # SEND CLICKS TO GAME WINDOW + #TODO: CURRENTLY RELIES ON MOVING CURSOR; WANT IT TO SEND CLICKS IN BCKGND + def sendclick(self, x, y): + WAITTIME = 1 + time.sleep(WAITTIME) + if self.verbose: + print("WAITED " + str(WAITTIME) + " SECS") + self.AppWindow = win32gui.FindWindow(None, "Last War-Survival Game") + rect = win32gui.GetWindowRect(self.AppWindow) + lparam = win32api.MAKELONG(100,680) + if self.verbose: + print(lparam) + print (rect) + win32api.SetCursorPos((x,y)) + win32api.PostMessage(self.AppWindow, win32con.WM_LBUTTONDOWN, win32con.MK_LBUTTON, lparam) + win32api.PostMessage(self.AppWindow, win32con.WM_LBUTTONUP, None, lparam) + + # FUNCTION TO OPEN SECRETARY POSITION SCREEN: + def gotovpscreen(self): + print("GOING TO VP DISPLAY") + #self.sendclick(360, 80) # Click icon + #self.sendclick(760, 480) # Server num + self.sendclick(360, 80) # Click icon + self.sendclick(760, 280) # Server num + + # FUNCTION TO RUN VIP CLICKS + def runvp(self): + for x in range(5): + if x < 3: + self.sendclick(650 - 100*(x-1), 470) # Click Position + else: + self.sendclick(650 - 100*(x-4), 320) # Click Position + self.sendclick(780, 590) # Click List + self.sendclick(720, 190) # Click Accept First Entry + self.sendclick(650, 660) # Click exit + self.sendclick(650, 660) # Click exit + def runvp_farleft(self): + for x in range(5): + if x < 3: + self.sendclick(290 - 100*(x-1), 450) # Click Position + else: + self.sendclick(290 - 100*(x-4), 300) # Click Position + self.sendclick(420, 590) # Click List + self.sendclick(380, 170) # Click Accept First Entry + self.sendclick(290, 650) # Click exit + self.sendclick(290, 650) # Click exit + + def opengamescenarios(self): + currentday = int(datetime.today().weekday()) # Mon =0; Sun =6 + currenthour = int(datetime.now().strftime("%H")) + print("Current Day = "+str(currentday)+"; Current hour = "+str(currenthour)) + if currentday == 5 or(currentday == 6 and currenthour < 21) or (currentday == 4 and currenthour >= 21): + print("TODAY IS SUNDAY; ACCOUNT FOR LOOT DOMINO.") + #TEMP SOLN: on friday/saturday, loot domino. can exit via click outside menu. + self.sendclick(360, 80) # Click icon + #if currentday == 6: + #TEMP SOLN: Click for when there's capitol war + #self.sendclick(650, 450) # Click x + \ No newline at end of file diff --git a/Windows/vpbot.py b/Windows/vpbot.py new file mode 100644 index 0000000..a681fb5 --- /dev/null +++ b/Windows/vpbot.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +""" +INITIAL CREATION: Rawrafied 1/3/25 +DESCRIPTION: + - Main script to instantiate Last War Bot environment. +""" +# LIBRARY IMPORTS: ################################ +#import sys +#import os +#import subprocess +#path = os.getcwd() # Check current directory's path + + +# BOT LIBRARY FILES +import appwindow_manager_win + +# TESTING VARIABLES: ############################## +# Variables: +verbose = False + +if verbose: + print ("test") + +# VPBOT CLASS FUNCTIONS: ########################## +# MAIN FUNCTION: +def main(): + print("INITIALIZING VPBOT INTELLIGENCE ASSISTANCE CODE") + + #Variables: + role =["VPBOT"] # Options: VPBOT, FARMER, FIGHTER + firstopened = True + + appwindow_mgr = appwindow_manager_win.appwindow_manager(verbose) + + +# MAIN SOFTWARE ################################### +if __name__ == '__main__': + main() \ No newline at end of file