[C++]Klasa za kontroliranje Winampa

Objavite dijelove ili cjelokupni izvorni kôd vaših "otvorenih" projekata ukoliko možda trebate pomoć ili jednostavno ponudite javnosti da pročačka po kôdu i nauči pokoji trik ili tehniku.
Post Reply
User avatar
UDP11
Obama s Trešnjevke
Posts: 657
Joined: Thu Nov 06, 2008 2:38 pm
Smallest prime number bigger than 20: 23

[C++]Klasa za kontroliranje Winampa

Post by UDP11 » Tue Jun 22, 2010 8:50 pm

Ovu klasu sam napisao prije 2-3 godine, tako da nisam 100% siguran je li još uvijek radi, ovaj programčić sam napravio u to vrijeme korištenjem ove klase: http://www.youtube.com/watch?v=uMfrMrGxRFc" onclick="window.open(this.href);return false;

Code: Select all

Napravite Shortcut za Winamp na desktopu, ako ga vec nemate, i dodajte
/CLASS=Winamp, u target, tako da izgleda ovako npr.
"C:\Program Files\Winamp\winamp.exe" /CLASS=Winamp. 
A sada source...

*.hpp

Code: Select all

#include <windows.h>
#include <string>
#include <iostream>
using namespace std;
class WinAmp {
	int volume;
	LRESULT version;
public:
	void getSongTitle();
	void prevTrack();
	void nextTrack();
	void play();
	void pause();
	void stop();
	void fadeNStop();
	void stopAfterCurrent(); 
	void fastForward();
	void fastRewind();
	void startOfPlaylist();
	void endOfPlaylist();
	void openFileDlg();
	void openURLDlg();
	void openFileInfo();
	void setTimeToElapsed();
	void setTimeToRemaining();
	void tooglePrefScreen();
	void openVisualizationOption();
	void openVisualizationPluginOption();
	void executeCurrVisPlugin();
	void toogleAbout();
	void titleAutoScroll();
	void toogleAlwaysTop();
	void toogleWinShade();
	void tooglePlaylistWinShade();
	void toogleDblSizeMod();
	void toogleEQ();
	void tooglePlaylistEdit();
	void toogleMainWinVisible();
	void toogleMiniBrowser();
	void toogleEasyMove();
	void raiseVolume();
	void lowerVolume();
	void toogleRepeat();
	void toogleShuffle();
	void openJumpToTime();
	void openJumpToFile();
	void openSkinSelect();
	void configureCurrentVisualization();
	void reloadCurrSkin();
	void closeWinamp();
	void moveBackTracksInPlaylist();
	void showEditBookmark();
	void addCurrToBookmark();
	void playCD();
	void loadPresetFromEQ();
	void savePresetToEQ();
	void openLoadPresetDlg();
	void openAutoLoadPresetDlg();
	void loadDefaultPreset();
	void openSavePresetDlg();
	void openAutoLoadSavePresetDlg();
	void openDeletePresetDlg();
	void openDeleteAutoLoadPresetDlg();
	void clearPlaylist();
	int getVolume();
	int setVolume(int vol);
	LRESULT getVersion();
};





*.cpp

Code: Select all

#include "WClass.h"

HWND hwndWinamp = FindWindow(L"Winamp",NULL);


void WinAmp::prevTrack() {
	SendMessage(hwndWinamp,WM_COMMAND,40044,0);
}

void WinAmp::nextTrack() {
	SendMessage(hwndWinamp,WM_COMMAND,40048,0);
}

void WinAmp::pause() {
	SendMessage(hwndWinamp,WM_COMMAND,40046,0);
}

void WinAmp::play() {
	SendMessage(hwndWinamp,WM_COMMAND,40045,0);
}

void WinAmp::stop() {
	SendMessage(hwndWinamp,WM_COMMAND,40047,0);
}

void WinAmp::fadeNStop() {
	SendMessage(hwndWinamp,WM_COMMAND,40147,0);
}

void WinAmp::stopAfterCurrent() {
	SendMessage(hwndWinamp,WM_COMMAND,40157,0);
}

void WinAmp::fastForward() {
	SendMessage(hwndWinamp,WM_COMMAND,40148,0);
}

void WinAmp::fastRewind() {
	SendMessage(hwndWinamp,WM_COMMAND,40144,0);
}

void WinAmp::startOfPlaylist() {
	SendMessage(hwndWinamp,WM_COMMAND,40154,0);
}

void WinAmp::endOfPlaylist() {
	SendMessage(hwndWinamp,WM_COMMAND,40158,0);
}

void WinAmp::openFileDlg() {
	SendMessage(hwndWinamp,WM_COMMAND,40029,0);
}

void WinAmp::openURLDlg() {
	SendMessage(hwndWinamp,WM_COMMAND,40155,0);
}

void WinAmp::openFileInfo() {
    SendMessage(hwndWinamp,WM_COMMAND,40188,0);
}

void WinAmp::setTimeToElapsed() {
	SendMessage(hwndWinamp,WM_COMMAND,40037,0);
}

void WinAmp::setTimeToRemaining() {
	SendMessage(hwndWinamp,WM_COMMAND,40038,0);
}

void WinAmp::tooglePrefScreen() {
	SendMessage(hwndWinamp,WM_COMMAND,40012,0);
}

void WinAmp::openVisualizationOption() {
	SendMessage(hwndWinamp,WM_COMMAND,40190,0);
}

void WinAmp::openVisualizationPluginOption() {
	SendMessage(hwndWinamp,WM_COMMAND,40191,0);
}

void WinAmp::executeCurrVisPlugin() {
	SendMessage(hwndWinamp,WM_COMMAND,40192,0);
}

void WinAmp::toogleAbout() {
	SendMessage(hwndWinamp,WM_COMMAND,40041,0);
}

void WinAmp::titleAutoScroll() {
	SendMessage(hwndWinamp,WM_COMMAND,40189,0);
}

void WinAmp::toogleAlwaysTop() {
	SendMessage(hwndWinamp,WM_COMMAND,40019,0);
}

void WinAmp::toogleWinShade() {
	SendMessage(hwndWinamp,WM_COMMAND,40064,0);
}

void WinAmp::tooglePlaylistWinShade() {
	SendMessage(hwndWinamp,WM_COMMAND,40266,0);
}

void WinAmp::toogleDblSizeMod() {
	SendMessage(hwndWinamp,WM_COMMAND,40165,0);
}

void WinAmp::toogleEQ() {
	SendMessage(hwndWinamp,WM_COMMAND,40036,0);
}

void WinAmp::tooglePlaylistEdit() {
    SendMessage(hwndWinamp,WM_COMMAND,40040,0);
}

void WinAmp::toogleMainWinVisible() {
	SendMessage(hwndWinamp,WM_COMMAND,40258,0);
}

void WinAmp::toogleMiniBrowser() {
	SendMessage(hwndWinamp,WM_COMMAND,40298,0);
}

void WinAmp::toogleEasyMove() {
	SendMessage(hwndWinamp,WM_COMMAND,40186,0);
}

void WinAmp::raiseVolume() {
	SendMessage(hwndWinamp,WM_COMMAND,40058,0);
}

void WinAmp::lowerVolume() {
	SendMessage(hwndWinamp,WM_COMMAND,40059,0);
}

void WinAmp::toogleRepeat() {
	SendMessage(hwndWinamp,WM_COMMAND,40022,0);
}

void WinAmp::toogleShuffle() {
	SendMessage(hwndWinamp,WM_COMMAND,40023,0);
}

void WinAmp::openJumpToTime() {
	SendMessage(hwndWinamp,WM_COMMAND,40193,0);
}

void WinAmp::openJumpToFile() {
	SendMessage(hwndWinamp,WM_COMMAND,40194,0);
}

void WinAmp::openSkinSelect() {
	SendMessage(hwndWinamp,WM_COMMAND,40219,0);
}

void WinAmp::configureCurrentVisualization() {
	SendMessage(hwndWinamp,WM_COMMAND,40221,0); 
}

void WinAmp::reloadCurrSkin() {
	SendMessage(hwndWinamp,WM_COMMAND,40291,0);
}

void WinAmp::closeWinamp() {
	SendMessage(hwndWinamp,WM_COMMAND,40001,0);
}

void WinAmp::moveBackTracksInPlaylist() {
	SendMessage(hwndWinamp,WM_COMMAND,40197,0);
}

void WinAmp::showEditBookmark() {
	SendMessage(hwndWinamp,WM_COMMAND,40320,0);
}

void WinAmp::addCurrToBookmark() {
	SendMessage(hwndWinamp,WM_COMMAND,40321,0);
}

void WinAmp::playCD() {
    SendMessage(hwndWinamp,WM_COMMAND,40323,0);
}

void WinAmp::loadPresetFromEQ() {
	SendMessage(hwndWinamp,WM_COMMAND,40253,0);
}	

void WinAmp::savePresetToEQ() {
	SendMessage(hwndWinamp,WM_COMMAND,40254,0);
}

void WinAmp::openLoadPresetDlg() {
	SendMessage(hwndWinamp,WM_COMMAND,40172,0);
}

void WinAmp::openAutoLoadPresetDlg() {
	SendMessage(hwndWinamp,WM_COMMAND,40173,0);
}

void WinAmp::loadDefaultPreset() {
	SendMessage(hwndWinamp,WM_COMMAND,40174,0);
}

void WinAmp::openSavePresetDlg() {
	SendMessage(hwndWinamp,WM_COMMAND,40175,0);
}

void WinAmp::openAutoLoadSavePresetDlg() {
	SendMessage(hwndWinamp,WM_COMMAND,40176,0);
}

void WinAmp::openDeletePresetDlg() {
	SendMessage(hwndWinamp,WM_COMMAND,40178,0);
}

void WinAmp::openDeleteAutoLoadPresetDlg() {
	SendMessage(hwndWinamp,WM_COMMAND,40180,0);
}

void WinAmp::clearPlaylist() {
	SendMessage(hwndWinamp,WM_USER,0,101);
}
int WinAmp::getVolume() { return volume;}

int WinAmp::setVolume(int vol) {
		if(vol<0 || vol>255) {
	MessageBox(hwndWinamp,L"Volume must be < 0 or >255!",L"Serious Error!!!",MB_OK);
	return 1; }
    SendMessage(hwndWinamp,WM_USER,vol,122);
	volume=vol;
	return volume;
	}



LRESULT WinAmp::getVersion() {
	version=SendMessage(hwndWinamp,WM_USER,0,0);
	return version;
}


void WinAmp::getSongTitle() {
		char this_title[300];
	GetWindowText(hwndWinamp,LPWSTR(this_title),sizeof(this_title));
	if(strlen(this_title)>300) 
		MessageBox(hwndWinamp,L"Song title longer than 300 characters, PWND!!! :(",L"Serious Error!!!",MB_OK);
    int i=strlen(this_title);
	this_title[i-8]=0;
    cout << this_title;


}


Kako koristiti klasu:

Code: Select all

#include "WClass.h"
#define cls system("cls");
int main() {
WinAmp l;

int MainInput;
int OneInput;
int Volume;
static bool State=0;
while(1) {
cout << "::Basic Winamp external controller::" << endl;
cout << "1. Set Volume" << endl;
cout << "2. Pause" << endl;
cout << "3. Stop" << endl;
cout << "4. Play" << endl;
cout << "5. Title" << endl;
cout << "6. Fast Forward" << endl;
cout << "7. Fast Rewind" << endl;
cout << "8. Next Track" << endl;
cout << "9. Previous Track" << endl;
cout << "10. About" << endl;
cout << "11. Exit" << endl;
cout << "::::::::::::::::::::::::::::::::::::" << endl;
cout << ">> ";
cin >> MainInput;
if(cin.fail())
cout << "You typed illegal value!" << endl;
switch(MainInput) {
	case 1:
		cls;
		cout << "1. for loop example";
	    cout << endl << "2. set volume to specific value" << endl;
        cin >> OneInput;
		if(cin.fail())
		cout << "You typed illegal value!" << endl << endl;;
		switch(OneInput) {
	case 1:
		cls;
		cout << "::for loop volume example::" << endl;
		l.setVolume(255);
		for(int i=100;i>0;i--) {
			Sleep(10);
			l.lowerVolume(); }
		for(int i=0;i<100;i++) {
			Sleep(10);
			l.raiseVolume(); }
		cout << "::for loop volume example succesfully finished::" << endl << endl;
		break;
	case 2:
		cls;
		cout << "::Set Volume::" << endl;
        cout << ">> ";
		cin >> Volume;
		if(cin.fail())
		cout << "You typed illegal value!" << endl << endl;
		l.setVolume(Volume);
		break;
	default:
		cout << "Input error!" << endl;
		break;
		}
		break;
	case 2:
		cls;
		State=!State;
		if(State) {
			cout << "::Paused::" << endl;
			l.pause(); }
		else {
			cout << "::Playing::" << endl;
			l.pause(); }
		 
		break;
	case 3:
		cls;
		cout << "::Stopped::" << endl;
		l.stop();
		break;
	case 4:
		cls;
		cout << "::Started::" << endl;
		l.play();
		break;
	case 5:
		cls;
		cout << "NOW PLAYING ->> " << endl;
		l.getSongTitle();
		cout << endl << endl;
		break;
	case 6:
		cls;
		cout << ">> Forwarding 5 Seconds >>" << endl;
		l.fastForward();
		break;
	case 7:
		cls;;
		cout << "<< Rewinding 5 Seconds <<" << endl;
		l.fastRewind();
		break;
	case 8:
		cls;
		l.nextTrack();
		cout << "Playing next track -> ";l.getSongTitle();
		cout << endl;
		break;
	case 9:
		cls;
		l.prevTrack();
		cout << "Playing previous track -> ";l.getSongTitle();
		cout << endl;
		break;
	case 10:
		cls;
		cout << "loosermil@net.hr";
		break;
	case 11:
		cls;
		exit(1);
	default:
		cls;
		cout << "You suck!!";
}
}
}

Image

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest