Skip to content

Instantly share code, notes, and snippets.

@tbnorth
Last active March 15, 2023 21:08
Show Gist options
  • Save tbnorth/de063ed81916bd08e74fa49a104c06d7 to your computer and use it in GitHub Desktop.
Save tbnorth/de063ed81916bd08e74fa49a104c06d7 to your computer and use it in GitHub Desktop.
Open a big red window when a window called r".*Reminder.*" exists. Because Outlook reminder windows get buried and fail to remind.
"""
Open a big red window when a window called r".*Reminder.*" exists.
Because Outlook reminder windows get buried and fail to remind.
Thanks to http://stackoverflow.com/q/18146596/1072212
[email protected], 2016-09-19
"""
import sys
import win32gui
import time
from tkinter import *
def callback(hwnd, main):
"""from win32gui.EnumWindows, per window handle (hwnd)"""
text = win32gui.GetWindowText(hwnd)
if win32gui.IsWindowVisible(hwnd):
windows.add(text)
windows = set()
print("Watching for Outlook hiding reminders")
while True:
windows.intersection_update(set()) # clear set
win32gui.EnumWindows(callback, 0)
reminder = any('Reminder' in i for i in windows)
nooutlook = not any(i.startswith('Inbox -') for i in windows)
message = "Outlook not running" if nooutlook else "Reminder present"
if reminder or nooutlook:
print("Reminder present")
root = Tk()
w = Label(root, text=message, bg='red', width=120, height=60)
w.pack()
root.call('wm', 'attributes', '.', '-topmost', '1')
root.resizable(0, 0)
root.attributes('-toolwindow', True)
root.mainloop()
print("reoport_reminder.py: %s" % time.asctime())
time.sleep(10)
# DON'T USE THIS use the Tk version above
"""
Open a big red window when a window called r".*Reminder.*" exists.
Because Outlook reminder windows get buried and fail to remind.
Thanks to http://stackoverflow.com/q/18146596/1072212
[email protected], 2016-09-19
"""
import sys
import win32gui
import time
from PyQt4 import QtGui, QtCore, Qt
from PyQt4.QtCore import Qt as QtConst
def callback(hwnd, main):
"""from win32gui.EnumWindows, per window handle (hwnd)"""
text = (win32gui.GetWindowText(hwnd))
if win32gui.IsWindowVisible(hwnd):
windows.add(text)
windows = set()
app = Qt.QApplication(sys.argv)
main = QtGui.QMainWindow(None,
QtConst.WindowStaysOnTopHint |
QtConst.CustomizeWindowHint |
QtConst.WindowCloseButtonHint
)
main.resize(800,800)
main.move(40,40)
qtextedit = QtGui.QTextEdit()
main.setCentralWidget(qtextedit)
qtextedit.setPlainText('A Reminder is present')
qtextedit.setReadOnly(True)
qtextedit.setStyleSheet("background: red;")
while True:
windows.intersection_update(set()) # clear set
win32gui.EnumWindows(callback, 0)
if any('Reminder' in i for i in windows):
main.show()
main.move(40,40)
app.exec_()
time.sleep(30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment