Saves a window with the title provided as a file using the provided filename. If one of them is missing, then a window is created and the information collected :param filename: :param title: :return:
(filename=None, title=None, crop=True)
| 79 | return titles |
| 80 | |
| 81 | def save_win(filename=None, title=None, crop=True): |
| 82 | """ |
| 83 | Saves a window with the title provided as a file using the provided filename. |
| 84 | If one of them is missing, then a window is created and the information collected |
| 85 | |
| 86 | :param filename: |
| 87 | :param title: |
| 88 | :return: |
| 89 | """ |
| 90 | C = 7 if crop else 0 # pixels to crop |
| 91 | try: |
| 92 | fceuxHWND = win32gui.FindWindow(None, title) |
| 93 | rect = win32gui.GetWindowRect(fceuxHWND) |
| 94 | rect_cropped = (rect[0] + C, rect[1], rect[2] - C, rect[3] - C) |
| 95 | grab = ImageGrab.grab(bbox=rect_cropped) |
| 96 | grab.save(filename) |
| 97 | sg.cprint('Wrote image to file:') |
| 98 | sg.cprint(filename, c='white on purple') |
| 99 | except Exception as e: |
| 100 | sg.popup('Error trying to save screenshot file', e, keep_on_top=True) |
| 101 | |
| 102 | |
| 103 | def main(): |