Last active
February 24, 2018 19:30
-
-
Save dogancelik/7173121 to your computer and use it in GitHub Desktop.
(HexChat) Foobar2000 Now Playing Plugin (Windows only) (Broken)
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
# Requires http://sourceforge.net/projects/pywin32/ | |
__module_name__ = 'Foobar2000 Now Playing' | |
__module_version__ = '0.1' | |
__module_description__ = 'Prints what is playing from foobar2000' | |
import xchat | |
import win32gui | |
import re | |
class WindowMgr: | |
def __init__(self): | |
self._handle = None | |
def find_window(self, class_name, window_name = None): | |
self._handle = win32gui.FindWindow(class_name, window_name) | |
def _window_enum_callback(self, hwnd, wildcard): | |
if re.match(wildcard, str(win32gui.GetWindowText(hwnd))) != None: | |
self._handle = hwnd | |
def find_window_wildcard(self, wildcard): | |
self._handle = None | |
win32gui.EnumWindows(self._window_enum_callback, wildcard) | |
def get_window_title(self): | |
return win32gui.GetWindowText(self._handle) | |
mgr = WindowMgr() | |
def NP_trigger(word, word_eol, userdata): | |
global mgr | |
mgr.find_window_wildcard(".*foobar2000.*") | |
title = mgr.get_window_title() | |
channel = xchat.get_info('channel') | |
xchat.command("msg %s %s" % (channel, title)) | |
xchat.hook_command("NP", NP_trigger, help="/NP Prints title from foobar2000") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment