Skip to content

Instantly share code, notes, and snippets.

@addohm
Last active April 13, 2020 01:00
Show Gist options
  • Save addohm/a2368256875264f8893cf7aa2b5ea1fc to your computer and use it in GitHub Desktop.
Save addohm/a2368256875264f8893cf7aa2b5ea1fc to your computer and use it in GitHub Desktop.
Beat the WoW Classic Queues
import pyautogui
import time
import random
import datetime
class BypassTheWait:
"""
A script meant to eliminate queue waits by keeping your character logged in
the script was designed on a 1920x1080 resolution setting, however it does not use
discrete positions. Rather it uses percentage of screen percentage, so hopefully
it will work for other screen dimensions. This is also done with the following settings:
gamma: 1.1,
contrast: 70,
brightness: 65,
:param password: The battle.net password to type into the login screen
:type password: str
:param verbose: Verbose text output
:type verbose: bool
:param auto_run: Auto run enable option
:type auto_run: bool
:param auto_login_hour: Auto run start hour
:type auto_login_hour: int
:param auto_login_cutoff: Auto run stop hour
:type auto_login_cutoff: int
"""
loopresettime = 120
pyautogui.PAUSE = 0.1
pyautogui.FAILSAFE = True
screensize = pyautogui.size()
screenX_center = screensize.width / 2
screenY_center = screensize.height / 2
def __init__(self, password, verbose=False, auto_run=False, auto_login_hour=None, auto_login_cutoff=None):
self.password = password
self.auto_run = auto_run
self.verbose = verbose
self.auto_login_hour = auto_login_hour
self.auto_login_cutoff = auto_login_cutoff
def check_realmentered(self): # checks to see if logged into the realm
'''Check whether or not the character is logged into the realm'''
print('Are we in the realm?')
screenX_findmmnorth = self.screensize.width * 0.987
screenY_findmmnorth = self.screensize.height * 0.015
cursor_color = self.color_at_coords(screenX_findmmnorth, screenY_findmmnorth)
for x in range(10):
if cursor_color[0] >= 230:
if cursor_color[1] in range(190, 220):
if cursor_color[2] in range(30, 50):
print('Yes.')
return True
cursor_color = self.color_at_coords(screenX_findmmnorth + x, screenY_findmmnorth)
# print(pyautogui.position())
# print(cursor_color)
# pass
print('No.')
return False
def check_charselectscreen(self): # checks to see if at the character select screen
'''Check to see if we've arrived at the char select screen'''
print('Are we at the character select screen?')
screenX_findenterworldbtn = self.screensize.width * 0.50
screenY_findenterworldbtn = self.screensize.height * 0.918
cursor_color = self.color_at_coords(screenX_findenterworldbtn, screenY_findenterworldbtn)
for x in range(50):
if cursor_color[0] >= 255:
if cursor_color[1] >= 255:
if cursor_color[2] >= 255:
print('Yes.')
return True
cursor_color = self.color_at_coords(screenX_findenterworldbtn, screenY_findenterworldbtn-x)
# print(pyautogui.position())
# print(cursor_color)
# pass
print('No.')
return False
def check_loginscreen(self): # checks to see if at the login screen
'''Check to see if we're at the login screen'''
print('Are we at the login screen?')
# if self.check_loginacctbtn() is True and self.check_loginquitbtn() is True:
if self.check_loginwraith() is True:
print('Yes.')
return True
print('No.')
return False
def check_loginwraith(self): # checks for the wraith on the login screen, used to verify login screen before entering password
print("Checking for the login screen wraith's red eyes.")
screenX_loginwraith = self.screensize.width * 0.698
screenY_loginwraith = self.screensize.height * 0.18
cursor_color = self.color_at_coords(screenX_loginwraith, screenY_loginwraith)
initial_color = cursor_color
for x in range(15):
if cursor_color[0] >= 240 and initial_color[0] <= 40:
if cursor_color[1] <= 40 and initial_color[1] <= 40:
if cursor_color[2] <= 40 and initial_color[2] <= 40:
print('Login wraith found at ' + str(pyautogui.position()))
return True
cursor_color = self.color_at_coords(screenX_loginwraith, screenY_loginwraith-x)
return False
def check_loginacctbtn(self): # checks for the account button on the login screen
print('Is the login screen account button present?')
screenX_loginscreenaccount = self.screensize.width * 0.025
screenY_loginscreenaccount = self.screensize.height * 0.716
cursor_color = self.color_at_coords(screenX_loginscreenaccount, screenY_loginscreenaccount)
for x in range(20):
if cursor_color[0] >= 255:
if cursor_color[1] >= 255:
if cursor_color[2] >= 255:
print('Yes.')
return True
cursor_color = self.color_at_coords(screenX_loginscreenaccount+x, screenY_loginscreenaccount)
print('No.')
return False
def check_loginquitbtn(self): #checks for the quit button on the login screen
print('Is the login screen quit button present?')
screenX_loginscreenquit = self.screensize.width * 0.945
screenY_loginscreenquit = self.screensize.height * 0.935
cursor_color = self.color_at_coords(screenX_loginscreenquit, screenY_loginscreenquit)
for x in range(20):
if cursor_color[0] >= 255:
if cursor_color[1] >= 255:
if cursor_color[2] >= 255:
print('Yes.')
return True
cursor_color = self.color_at_coords(screenX_loginscreenquit-x, screenY_loginscreenquit)
print('No.')
return False
def check_realmselect(self): # checks to see if the realm selection dialogue is open
'''Check whether or not we're at the realm selection dialogue'''
print('Are we at the realm select screen?')
screenX_findmmnorth = self.screensize.width * 0.704
screenY_findmmnorth = self.screensize.height * 0.190
cursor_color = self.color_at_coords(screenX_findmmnorth, screenY_findmmnorth)
for x in range(15):
if cursor_color[0] >= 253:
if cursor_color[1] in range(205, 225):
if cursor_color[2] in range(30, 50):
print('Yes.')
return True
cursor_color = self.color_at_coords(screenX_findmmnorth + x, screenY_findmmnorth)
# print(pyautogui.position())
# print(cursor_color)
# pass
print('No.')
return False
def find_dialogue_button(self): # find the position of the dialogue button box
print('Getting the dialogue button position if present.')
screenX_finddialoguebtn = self.screensize.width * 0.492
screenY_finddialoguebtn = self.screensize.height * 0.555
cursor_color = self.color_at_coords(screenX_finddialoguebtn, screenY_finddialoguebtn)
for x in range(50):
if cursor_color[0] >= 255:
if cursor_color[1] >= 255:
if cursor_color[2] >= 255:
return True
cursor_color = self.color_at_coords(screenX_finddialoguebtn, screenY_finddialoguebtn-x)
# print(pyautogui.position())
# print(cursor_color)
# pass
print('No dialogue button present.')
return False
def check_dialogue(self): # checks to see if a dialoge box exists
'''Check to see if a dialogue is covering the login credentials
Does this by moving to an offset center and scanning for the blizzard text color'''
print('Is a dialogue box present?')
screenX_startdialoguecheck = self.screensize.width * 0.312
cursor_color = self.color_at_coords(screenX_startdialoguecheck, self.screenY_center)
for x in range(20):
if cursor_color[0] >= 100:
if cursor_color[1] >= 100:
if cursor_color[2] >= 100:
print('Yes.')
return True
cursor_color = self.color_at_coords(screenX_startdialoguecheck + x, self.screenY_center)
# print(pyautogui.position())
# print(cursor_color)
# pass
print('No.')
return False
# Below functions do not require RGB adjustments
def check_queue(self): # check position to see if dialogue is change realm
'''Check whether or not we're in the queue
Does this by moving to an offset center and
scanning for the position of the dialogue button'''
print('Are we in the queue?')
if self.find_dialogue_button():
if pyautogui.position().y in range(590, 600):
print('Yes.')
return True
print('No.')
return False
def check_disconnect(self): # check position to see if dialogue is disconnect
'''Check for the "disconnected from realm" dialogue box
Does this by moving to an offset center and
scanning for the position of the dialogue button'''
print('Have we been disconnected?')
if self.find_dialogue_button():
if pyautogui.position().y in range(570, 578):
print('Yes.')
return True
print('No.')
return False
def check_availability(self): # check position to see if dialogue is availability
'''Check for the "no servers currently available" dialogue box
Does this by moving to an offset center and
scanning for the position of the dialogue button'''
print('Are there servers available?')
if self.find_dialogue_button():
if pyautogui.position().y in range(555, 565):
print('No.')
return True
print('Yes.')
return False
def confirm_disconnect(self): # clicks the Okay button dialogue after disconnecting
'''Click the Okay button disconnection dialogue box'''
# disconnected OK button position
screenY_disconconfirm = self.screensize.height * 0.525
try:
print('Disconnect confirmed.')
pyautogui.moveTo(x=self.screenX_center, y=screenY_disconconfirm, duration=1.0)
self.mouse_wiggle()
pyautogui.click(x=self.screenX_center, y=screenY_disconconfirm, clicks=1, interval=1.0, button='left')
except KeyboardInterrupt:
print('\nDone.')
def confirm_availability(self): # clicks the Okay button on the lack of realm availability screen
'''Click the Okay button disconnection dialogue box'''
# disconnected OK button position
screenY_availconfirm = self.screensize.height * 0.518
try:
print('Availability confirmed.')
pyautogui.moveTo(x=self.screenX_center, y=screenY_availconfirm, duration=1.0)
self.mouse_wiggle()
pyautogui.click(x=self.screenX_center, y=screenY_availconfirm, clicks=1, interval=1.0, button='left')
except KeyboardInterrupt:
print('\nDone.')
def login(self): # clicks the login button on the login screen
'''Log in'''
screenY_login = self.screensize.height * 0.73
try:
print('Login button pressed.')
pyautogui.moveTo(x=self.screenX_center, y=screenY_login, duration=1.0)
self.mouse_wiggle()
pyautogui.click(x=self.screenX_center, y=screenY_login, clicks=1, interval=1.0, button='left')
except KeyboardInterrupt:
print('\nDone.')
def enter_password(self): # enters the account password, assumes 'remember account name' is used
'''Enter the password for the account and press enter'''
screenY_password = self.screensize.height * 0.648
pyautogui.moveTo(x=screenY_password, y=self.screenX_center, duration=1.0)
self.mouse_wiggle()
pyautogui.click(x=screenY_password, y=self.screenX_center, clicks=1, interval=1.0, button='left')
pyautogui.typewrite(self.password)
# pyautogui.press('enter')
self.login()
print('Password entered.')
def select_firstrealm(self): # clicks the realm in the top of the realm list
'''Click the first realm in the realm selection list'''
# enter world button position
screenY_firstrealm = self.screensize.height * 0.249
try:
pyautogui.moveTo(x=self.screenX_center, y=screenY_firstrealm, duration=1.0)
self.mouse_wiggle()
pyautogui.click(x=self.screenX_center, y=screenY_firstrealm, clicks=1, interval=1.0, button='left')
print('Realm selected clicked.')
except KeyboardInterrupt:
print('\nDone.')
def confirm_realm(self): # clicks the okay button at the select realm dialogue
'''Click the Okay button on the realm selection screen'''
# Realm Selection Okay position
screenX_realmselok = self.screensize.width * 0.587
screenY_realmselok = self.screensize.height * 0.79
try:
pyautogui.moveTo(x=screenX_realmselok, y=screenY_realmselok, duration=1.0)
self.mouse_wiggle()
pyautogui.click(x=screenX_realmselok, y=screenY_realmselok, clicks=1, interval=1.0, button='left')
# pyautogui.press('enter', interval=0.5)
print('Realm Selected.')
except KeyboardInterrupt:
print('\nDone.')
def enter_world(self): # clicks the enter world button at the character selection dialogue
'''Click the enter world button'''
# enter world button position
screenY_enterworld = self.screensize.height * 0.91
try:
pyautogui.moveTo(x=self.screenX_center, y=screenY_enterworld, duration=1.0)
self.mouse_wiggle()
pyautogui.click(x=self.screenX_center, y=screenY_enterworld, clicks=1, interval=1.0, button='left')
print('Enter world clicked.')
except KeyboardInterrupt:
print('\nDone.')
def get_pixel_colour(self, x, y): # gets the pixel color of the pixel underneath the mouse cursor
import PIL.ImageGrab
return PIL.ImageGrab.grab().load()[x, y]
def color_at_coords(self, x, y): # gets the pixel color of the pixel at a specified coordinate
'''Returns a list of RGB color values under the cursor position'''
try:
pyautogui.moveTo(x=x, y=y)
except KeyboardInterrupt:
print('\nDone.')
cursor_color = self.get_pixel_colour(pyautogui.position().x, pyautogui.position().y)
return cursor_color
def make_active_window(self): # click the top left corner of the screen to make window active
'''Click the enter world button'''
# enter world button position
try:
pyautogui.click(x=5, y=5, clicks=1, interval=1.0, button='left')
print('Made window active.')
except KeyboardInterrupt:
print('\nDone.')
def mouse_wiggle(self): # wiggle the cursor to force the button highlight
distance = 4
pyautogui.moveRel(distance, 0) # move right
distance -= 1
pyautogui.moveRel(0, distance) # move down
pyautogui.moveRel(-distance, 0) # move left
distance -= 1
pyautogui.moveRel(0, -distance) # move up
def rare_attk(self): # unused
i = 0
maxtime=600
n = random.randint(1,maxtime/2)
try:
while True:
r = random.randint(1,100)
if n == i:
print("Random jump sequence")
pyautogui.keyDown('2')
pyautogui.keyUp('2')
if i >= maxtime:
pyautogui.press('2')
if r % 1 == 0:
pyautogui.press('2')
else:
pyautogui.press('2')
i = 0
n = random.randint(1,maxtime/2)
# pyautogui.keyDown('tab')
# pyautogui.keyUp('tab')
pyautogui.keyDown('3')
pyautogui.keyUp('3')
pyautogui.keyDown('1')
pyautogui.keyUp('1')
pyautogui.keyDown('4')
pyautogui.keyUp('4')
i += 1
print("n = ", n)
print("r = ", r)
print("i = ", i)
except KeyboardInterrupt:
print('\nDone.')
def log_entry(self): # unused
pass
if __name__ == '__main__':
btw = BypassTheWait('password', False, True, 6, 22) # Enter your password(str), verbose(bool), auto(bool), start time(int), and end time(int)
while True:
currentDT = datetime.datetime.now()
if btw.auto_run and btw.verbose:
print("Auto run enabled. The auto login script will run at {} and will stop at {}".format(btw.auto_login_hour, btw.auto_login_cutoff))
print("The current date and time is {}".format(str(currentDT)))
if not btw.auto_run or (btw.auto_run and currentDT.hour > btw.auto_login_hour and currentDT.hour < btw.auto_login_cutoff):
if btw.auto_run and btw.verbose:
print("Auto login script running")
if not btw.password is None and not btw.password == '':
btw.make_active_window()
btw.keep_alive()
else:
print('You must enter your password into the main function where the class is instantiated')
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment