Skip to content

Instantly share code, notes, and snippets.

@EricTendian
Created July 27, 2014 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EricTendian/8be228115f77c0d4df3b to your computer and use it in GitHub Desktop.
Save EricTendian/8be228115f77c0d4df3b to your computer and use it in GitHub Desktop.
This script writes the title of a SDR# (SDRSharp) Frequency Scanner plugin window to a textfile, to be read by ProScan and fed into Icecast2 metadata. In this case, it is used for streaming Chicago Transit Authority radio traffic. However, it can be adapted to save other window titles given a certain flag to look for. Use this script in the even…
import win32gui, time
def enum_window_titles():
def callback(handle, data):
titles.append(win32gui.GetWindowText(handle))
titles = []
win32gui.EnumWindows(callback, None)
return titles
def write_title(title):
f = open('ctascanner-caption.txt', 'w')
f.write(title)
f.close()
ctatitle = ''
while True:
titles = enum_window_titles()
newtitle = ''
for title in titles:
if title.find('CTA')>0:
newtitle = title
if len(newtitle) and newtitle!=ctatitle:
ctatitle = newtitle
write_title(ctatitle)
print time.strftime("[%m/%d %H:%M:%S] ", time.localtime()) + ctatitle
elif not len(newtitle):
write_title('')
time.sleep(0.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment