Simple python script to generate image and config files for use with the OBS Input Overlay plugin. This is NOT affiliated with OBS or the plugin.
This is a simple script written for a limited use case, and as such has many limitations. Any limitations are easily bypassed by using the recommend process for creating a custom overlay, as detailed on the plugin's page, linked above. This script was created because I don't like using io-cct, as well as the fact I wanted to create a non-standard overlay.
Capabilities:
- Programmatically generate both image and config files that immediately work
- Quickly make small and large changes to your overlay
- Easily share editable files
- Avoid using io-cct!
Limitations:
- Cannot use anything other than keyboard and mouse button inputs
- Cannot specify Z level of element (which element appears on top)
If you really want these features, contact me on discord and I can help you out.
- Install the OBS Input Overlay Plugin (tutorial on linked page). Note that only Windows and Linux are supported (sorry mac users)
- Install Python
- Scroll up on this Github repo, click the green "Code" button, then click "Download ZIP"
- Extract the ZIP to a folder. It should contain one folder
imagesand several files, including:example_layout.pygenerator.pyREADME.mdRUN_THIS.bat
- You can delete
README.md - Double click
RUN_THIS.batto run it, or runpip install pillowin the command line. This installs a required dependency for the script. You only need to run this once, and you can deleteRUN_THIS.batafter running it - Make a copy of
example_layout.py. Name itmy_layout.py. Keep it in this folder - Open
my_layout.pywith a text editor (notepad works fine) - Notice
from generator import...at the top of the file. This has the be the first line in the file - Likewise, notice
generate_overlay_files((1920, 1080))at the bottom of the file. This has to be the last line in the file- You may want to change those numbers to match your desktop resolution
- To add an image to the overlay, use
add_image()with the following parameters:key. Example:key="W".keyneeds to exactly match a key in the list at the beginning ofgenerator.py. Open that file with a text editor to view the list (ignore the letters and numbers after the key). Notably, always use all caps, and CTRL/ALT/SHIFT need to end with either "_L" or "_R" (left or right). The name of the key needs to be in quotespos. Example:pos=(801, 792).posis the position of the top left corner ofpressed_imageandnot_pressed_image, in pixels. There need to be exactly two numbers, separated by a comma, all within parenthesespressed_image. Example:pressed_image="images/gui3/W.png".pressed_imageis the image that appears whenkeyis pressed.pressed_imageneeds to be the exact same size asnot_pressed_image. The file path can be relative or absolute, but note that if using absolute file paths on windows, you need to use double backslashes. For example, this is proper file path: "C:\\Users\\User\\Pictures\\picture.png"not_pressed_image. Example:not_pressed_image="images/gui3/W.png".not_pressed_imageis the image that appears whenkeyis not pressed.not_pressed_imageneeds to be the exact same size aspressed_image.not_pressed_imageis not a required parameter and can be omitted.- Example usage:
add_image(key="W", pos=(801, 792), pressed_image="images/gui3/W.png", not_pressed_image="images/gui3/E.png"). This would show E.png normally, but W.png when W is pressed - Note that the included images folder only includes a limited set of images, just the ones I've needed, and are organized for Minecraft overlays. GUI 3 and GUI 4 images will look best for 1080p GUI 3 and 4 respectively
- You can add a rectangle without an image file very similarly to adding an image by using
add_rectangle(), with the following differences:- Replace
pressed_imageandnot_pressed_imagewithpressed_colorandnot_pressed_color. Example:pressed_color=(255, 255, 255, 100).pressed_colorandnot_pressed_colorare the colors whenkeyis pressed and not pressed, respectively. The four numbers are red, green, blue, and alpha (transparency), and each range from 0 to 255.not_pressed_colorcan be omitted. To find a color, google "color picker" - Include
sizeExample:size=(48, 48).sizeis the width and height of the rectangle. There need to be exactly two numbers, separated by a comma, all within parentheses - Example usage:
add_rectangle(key="1", pos=(696, 1023), size=(48, 48), pressed_color=(255, 255, 255, 100), not_pressed_color=(50, 0, 50, 100))
- Replace
- Once you have finished making your layout, run the file containing your layout with python. To do this, open a command prompt window to the same directory as
generator.py. You can do this by typing "cmd" into the file path bar of file explorer. In the command line, type or pastepython my_layout.py. Two files, one calledoverlay_image.pngandoverlay_config.json, will be created. These two files will work with the input overlay plugin. For information on how to use or install the input overlay plugin, see it's tutorial