#include "voidapi.h" v_window* wnd; v_control* ctrl; v_thread* thrd; HWND winamp; void destroy(v_window* wind) { wind->destroy(); // destroy the window } void loop(v_thread* thread, void* data) { // this thread checks song title every 500 milliseconds while(true) { char text[256]; // create a text buffer int len = GetWindowText(winamp, text, 256); // get song title for (int x = 0; x < 9; x++) { text[len-x] = 0; // trim " - Winamp" from song title } int inc = 0; // char num while (text[inc] != '.') // loop till a "." is found inc++; // increase char num inc += 2; // increase twice to compensate for ". " char text_buf[256]; // new text buffer for (int x = 0; x < len; x++) //create a new song string text_buf[x] = text[x+inc]; ctrl->set_text(text_buf); // set the label text thread->sleep(500); // sleep for 500 ms } } int main() { thrd = new v_thread(&loop, NULL); // make a new thread wnd = new v_window("WinAMP Music", new v_size(400,55)); // make a new window ctrl = new v_label( "NP: ", new v_size(400,55), new v_point(0,0), wnd->get_hwnd() ); // make a new label wnd->register_event(WM_CLOSE, &destroy); // register close event wnd->control_add(ctrl); // add the label winamp = FindWindow("Winamp v1.x", NULL); // get winamp handle (v5.2 only?) thrd->start(); //start thread wnd->show(); // show the window }