-
-
Save yat1ma30/d26c1d62bdd121fa3d3b6c17bec40f8e to your computer and use it in GitHub Desktop.
monitor windows notifications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sqlite3 | |
import time | |
from bs4 import BeautifulSoup | |
ids = set() | |
user = os.environ['USERPROFILE'].replace("\\", "/") | |
adr = u"file:" + user + u"/AppData/Local/Microsoft/Windows/Notifications/wpndatabase.db?mode=ro" | |
def run(): | |
# con = sqlite3.connect("file:C:/Users/fnx/AppData/Local/Microsoft/Windows/Notifications/wpndatabase.db?mode=ro", uri=True) | |
con = sqlite3.connect(adr, uri=True) | |
cur = con.cursor() | |
x = cur.execute(""" | |
SELECT | |
n.id AS id, | |
n.type AS type, | |
nh.primaryid AS src, | |
nh.createdtime AS ctime, | |
nh.modifiedtime AS mtime, | |
n.payload as data | |
FROM | |
notification n | |
INNER JOIN | |
notificationhandler nh ON n.handlerid = nh.recordid | |
ORDER BY id ASC | |
""") | |
resp = x.fetchall() | |
for row in resp: | |
id = row[0] | |
if id not in ids: | |
ids.add(id) | |
src = row[2] | |
time = row[3] | |
data = row[5] | |
soup = BeautifulSoup(data, "html.parser") | |
print(id, src, time) | |
for d in soup.find_all("text"): | |
print("\t" + d.text) | |
print() | |
con.close() | |
while True: | |
run() | |
time.sleep(3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment