How to read text from balloon popup window using python?

1.3k views Asked by At

I am transferring a large file of about 500MB using bluetooth from one system to another. During this time I will get a balloon popup window saying "Bluetooth Connection" having a text that the mode has changed to high speed mode. I want to get this text in a variable using python. Any clue about how to read text from balloon popups???

Hope to get a reply asap.

Regards Sim

1

There are 1 answers

0
halex On

I combined posts of here and here to write the following example for you.

You need Python for Windows extensions which you can download here.

You can get the classname (you need it for the function win32gui.FindWindow) of your balloon tip, with the tool Spy++.

import win32gui, win32con

def get_text(hwnd):
    buf_size = 1 + win32gui.SendMessage(hwnd, win32con.WM_GETTEXTLENGTH, 0, 0)
    buffer = win32gui.PyMakeBuffer(buf_size)
    win32gui.SendMessage(hwnd, win32con.WM_GETTEXT, buf_size, buffer)
    return buffer[:buf_size]

if __name__ == "__main__":
    hwnd = win32gui.FindWindow("tooltips_class32", 0)
    content_of_balloon_tip = get_text(hwnd)
    print content_of_balloon_tip