All pastes #831158 Raw Edit

Stuff

public text v1 · immutable
#831158 ·published 2007-12-24 16:44 UTC
rendered paste body
#include <windows.h>
#include <stdio.h>
#include <string.h>

void setClipBoardWinAmpMusical(void);

int main(void) {
	
		     int a = 1;
		     while(a) {
		    	// Remember kids, 113 is F2, btw holding button down is -32767
		    	 if(GetAsyncKeyState(113) == -32767) {
		    		 setClipBoardWinAmpMusical();
		    		 printf("S");
		    	 } else if(GetAsyncKeyState(114) == -32767) break; // F3 = Quit
		    	 Sleep(100);
		     }
	return 0;
 }



void setClipBoardWinAmpMusical() {
	// hi2u
	HWND winamp = FindWindow("Winamp v1.x", NULL);
	if(winamp == NULL) printf("Getting winamp.exe top window FAILED!\n"); 
	else {
		printf("We have winamp.exe HWND!\n");
		
		char song[30];
		char buf[90];
		GetWindowText(winamp, (char *)&song, 30);
		char intro[] = " kuulab ";
		strcat((char *)buf, (char *)intro);
		strcat((char *)buf, (char *)song);
		strcat((char *)buf, " [WinAmp+WinApi plugin by Chris -,-]\n");
		
		     // Try to open the clipboard
		     OpenClipboard(NULL);
		     
		     // Remove any data that is currently on the clipboard
		     EmptyClipboard();
		     
		     CHAR *Buff = NULL;
		     
		     // Allocate memory for the buffer
		     HGLOBAL Mem = GlobalAlloc(GHND, sizeof(char *) * strlen(buf));
		     
		     // Lock the buffer into global memory
		     Buff = (CHAR*)GlobalLock(Mem);
		     
		     // Unlock the global memory object
		     GlobalUnlock(Mem);
		     
		     // Copy the string into the buffer
		     strcpy(Buff, buf);
		     
		     // Write the data to the clipboard
		     SetClipboardData(CF_TEXT, Mem);
		     
		     // Close the clipboard
		     CloseClipboard();
		     
		     GlobalFree(Mem);
}
}