Source Code Python Overlay Library (WIP) (SHOW OFF)

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

erxn

Full Member
May 5, 2019
11
1,943
1
How long you been coding/hacking?
on and off a few months
Hi!

I've been working on kind of a wrapper for pygame to use it for overlays on top on other windows. I got tired of making overlays from scratch. So I made this general purpose overlay class to streamline the building process. This is a work in progress and I've only been working on this for a few days.

Here is the basic loop you need to make it work:

Basic loop:
from pyOP import Overlay

ovr = Overlay(class_name="GLFW30") #Tell the overlay to find the window with class name "GLFW30" and put itself on top of it. As of now you can search by window title (window_name) or class name (class_name)

while True: #Overlay loop
    ovr.track() #this is the function that keeps the overlay on top of the game window.
    #Other Stuff here
    ovr.update() # This always has to be at the end. Its the function that update all the draw calls.
As of now it is very basic. And I haven't added much. It can draw lines, squares, text, menu panels and buttons.

Here is a few examples on how to use:

Draw text on screen

Draw Text:
while True: #Overlay loop
    ovr.track() #this is the function that keeps the overlay on top of the game window.
    
    #This basically just draws the text "Hello World" in white at position (200,80) with a font size of 40
    ovr.draw_text("Hello World", (255,255,255), 200, 80, 40) #ovr.draw_text(msg,color,x_pos,y_pos,font size)

    ovr.update() # This always has to be at the end. Its the function that update all the draw calls.
text_helloworld.jpg


Here is the same, but with a red rectangle around the text:
Text and rect:
while True: #Overlay loop
    ovr.track() #this is the function that keeps the overlay on top of the game window.

    ovr.draw_text("Hello World", (255,255,255), 200, 80, 40)
    ovr.draw_rect((255,0,0), 200, 80, 155, 35) #ovr.draw_rect(color,x_pos,y_pos,width,height)

    ovr.update() # This always has to be at the end. Its the function that update all the draw calls.
text_helloworld_redrect.jpg


Very basic, I know... But it can do more powerful things. Like make buttons that calls functions.
Here is a basic example:
Buttons:
def hello_world():
    print("Hi!")

def hello_world2(text):
    print(text)

while True: #Overlay loop
    ovr.track() #this is the function that keeps the overlay on top of the game window.

    #If you press this button it calls the function hello world. (hello_world())
    ovr.draw_button("Click Me!", (255,0,0),(120,0,0), 200, 80, 100, 35, show_border=False,action=hello_world) #ovr.draw_button(txt,hover_color,non_hover_color,x,y,w,h)

    #You can also pass parameters into the function like this:
    ovr.draw_button("Click Me!", (0,255,0),(0,120,0), 200, 120, 100, 35, show_border=True,action=hello_world2, param="yo")
    #It then calls hello_world2("yo")

    ovr.update() # This always has to be at the end. Its the function that update all the draw calls.
basic_buttons.jpg


console prints:
basic_buttons_cmd.jpg


If we go back to the hello world, red square example and put the draw calls inside an If statement and make a variable for True/False. We can make a function that changes that variable and tie it to the button.
Button to show/hide text:
show_text = False

def text_func():
    global show_text
    show_text = not show_text

while True: #Overlay loop
    ovr.track() #this is the function that keeps the overlay on top of the game window.

    ovr.draw_button("Show Text", (0,255,0),(0,120,0), 200, 120, 100, 35, show_border=True,action=text_func)
    
    if show_text:
        ovr.draw_text("Hello World", (255,255,255), 200, 80, 40)
        ovr.draw_rect((255,0,0), 200, 80, 155, 35)
    

    ovr.update() # This always has to be at the end. Its the function that update all the draw calls.
basic_buttons_show.jpg


Whenever you click the button the text shows/hides.

Here is a little demo I made to show off a few features of the overlay

Code for demo:
from pyOP import Overlay

s_options = False
s_square = False

def exit():
    quit()

def show_options():
    global s_options
    s_options = not s_options

def show_square(param):
    global s_square
    if param == "on":
        s_square = True
    elif param == "off":
        s_square = False

def draw_options():
    ovr.draw_menu("Options", (0,0,0), (220,220,220), 15, 90, 250, 500,show_border=True,show_title=True)
    ovr.draw_text("Draw Square", (255,255,255), 20, 150, 25)
    ovr.draw_button("On", (0,120,0), (0,255,0), 140, 150, 25, 25,show_border=False,action=show_square,param="on") #Calls function show_square("on")
    ovr.draw_button("Off", (120,0,0), (255,0,0), 180, 150, 25, 25,show_border=False,action=show_square,param="off") #Calls function show_Square("off")

def draw_square():
    #The get_window() function returns the x_pos, y_pos, width, height and hwnd handle of the parent window. In that order.
    ovr.draw_rect((0,0,255), (ovr.get_window()[2]/2)-29, 298, 60, 80,thickness=10)

#Start of program:

#could either use class_name or window_name
ovr = Overlay(class_name="GLFW30") #Tell the overlay to find the window with class name "GLFW30" and put itself on top of it

while True: #Overlay loop
    ovr.track() #this is the function that keeps the overlay on top of the game window, even if the window moves around.
    ovr.draw_button("X",(255,0,0),(120,0,0), ovr.get_window()[2] - 40, 35, 25, 25, show_border=False, action=exit) #Draw the X button (exit button)
    ovr.draw_button("Options", (220,220,220), (0,0,0), 15, 35, 75, 25, action=show_options) #Draw the options button. If you click it it calls the function show_options
    #ovr.draw_rect((0,0,255), (ovr.get_window()[2]/2)-29, 298, 60, 80,thickness=10)

    if s_options == True:
        draw_options() #You dont have to use the functions, you could just put the draw calls inside these if statements.
    if s_square == True:
        draw_square()

    ovr.update() # This always has to be at the end. Its the function that update all the draw calls.
I'm gonna keep working on this and expanding Its features. The next thing I want to add is textboxes.
Feel free to use this in your own project or expand on it/make it better. Pls keep me updated here on this forum if you expand on this yourself :)

TO USE:
You need to pip install pygame and pywin32.
 

Attachments

Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods