Skip to content

Commit

Permalink
Add GetGameWindowSize() function to helpers.py
Browse files Browse the repository at this point in the history
  • Loading branch information
DylDevs committed Jul 5, 2024
1 parent e5ba76a commit 879e2f4
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import src.controls as controls
import src.variables as variables
import win32gui
import pygetwindow as gw

lastRow = 0
lastParent = None
Expand Down Expand Up @@ -547,7 +548,21 @@ def autoTune(self, feedback_value, current_time=None):
self.Ki += self.ITerm
self.Kd += self.DTerm
self.clear()


def GetGameWindowSize():
"""Gets the size of the game window.
Returns:
tuple: (x1, y1, x2, y2) of the game window, or None if not found.
"""
titles = gw.getAllTitles()
for title in titles:
if title == "Euro Truck Simulator 2" or title == "Euro Truck Simulator 2 - Multiplayer" or title == "American Truck Simulator" or title == "American Truck Simulator - Multiplayer":
window = gw.getWindowsWithTitle(title)[0]
window = window.topleft[0], window.topleft[1], window.bottomright[0], window.bottomright[1]
return window
return None

popups = []
timeoutlessPopups = []
def ShowPopup(text, title, type="info", translate=True, timeout=4, indeterminate=False, closeIfMainloopStopped=False):
Expand Down

0 comments on commit 879e2f4

Please sign in to comment.