Четверг, 28.03.2024, 21:38
Приветствую Вас Гость

LabSoft

Меню сайта
Категории каталога
Статьи по кодингу [24]
Материалы по кодингу
КреатиFF [144]
Рассказы, истории, анекдоты...
Разное [8]
Советы, трюки, полезные рекомендации, статьи о новом и забытом старом...
Наш опрос
Пользуетесь ли вы прокси?
Всего ответов: 13
Главная » Статьи » Статьи по кодингу

Взаимодействие с mIRC
Я думаю, не стоит говорить о том как популярен проигрыватель Winamp, а сколько для него написано плагинов и модулей. Для непосредственного обращения к этому замечательному плееру были созданы специальные функции - WinampApi. Я покажу как можно легко организовать способ взаимодействия плеера с mIRC'ом.

Первое, что нужно знать:
* Необходимо найти окно проигрывателя, что не представляет сложности: findwindow('Winamp v5.x',nil);
* И послать ему команду - Sendmessage, которое может принимать вид: WM_COMMAND или WM_USER, с параметрами.

Привожу параметры (не все! Полный список можно взять с официального сайта...):
Для WM_COMMAND:

Previous track button 40044
Next track button 40048
Play button 40045
Pause/Unpause button 40046
Stop button 40047
Fadeout and stop 40147
Stop after current track 40157
Fast-forward 5 seconds 40148
Fast-rewind 5 seconds 40144
Start of playlist 40154
Go to end of playlist 40158
Open file dialog 40029
Open URL dialog 40155
Open file info box 40188
Set time display mode to elapsed 40037
Set time display mode to remaining 40038
Toggle preferences screen 40012
Open visualization options 40190
Open visualization plug-in options 40191

Для WM_USER:

0 Retrieves the version of Winamp running. Version will be 0x20yx for 2.yx. This is a good way to determine if you did in fact find the right window, etc.
100 Starts playback. A lot like hitting 'play' in Winamp, but not exactly the same
101 Clears Winamp's internal playlist.
102 Begins play of selected track.
103 Makes Winamp change to the directory C:\\download
104 Returns the status of playback. If 'ret' is 1, Winamp is playing. If 'ret' is 3, Winamp is paused. Otherwise, playback is stopped.
105 If data is 0, returns the position in milliseconds of playback. If data is 1, returns current track length in seconds. Returns -1 if not playing or if an error occurs.
106 Seeks within the current track. The offset is specified in 'data', in milliseconds.
120 Writes out the current playlist to Winampdir\winamp.m3u, and returns the current position in the playlist.
121 Sets the playlist position to the position specified in tracks in 'data'.
122 Sets the volume to 'data', which can be between 0 (silent) and 255 (maximum).
123 Sets the panning to 'data', which can be between 0 (all left) and 255 (all right).
124 Returns length of the current playlist, in tracks.
125 Returns the position in the current playlist, in tracks (requires Winamp 2.05+).

Приступим непосредственно к кодингу, т.е. реализации идеи:
library dll_for_mIRC;
uses
windows, messages;

function play_botton(mWnd, aWnd: HWND; data, parms: PChar; show, nopause:boolean):integer; stdcall;
export;
var h:HWND;
begin
h:=findwindow('Winamp v5.x',nil);
sendmessage(h,WM_COMMAND,40045,0); //играй гармонь =)
end;
exports play;

function stop_botton(mWnd, aWnd: HWND; data, parms: PChar; show, nopause:boolean):integer; stdcall;
export;
var h:HWND;
begin
h:=findwindow('Winamp v5.x',nil);
sendmessage(h,WM_COMMAND,40147,0); //стоп
end;
exports stop;

function next_botton(mWnd, aWnd: HWND; data, parms: PChar; show, nopause:boolean):integer;
stdcall; export;
var h:HWND;
begin
h:=findwindow('Winamp v5.x',nil);
sendmessage(h,WM_COMMAND,40048,0); //след трек
end;
exports nexttrack;

function previous_botton(mWnd, aWnd: HWND; data, parms: PChar; show, nopause:boolean):integer;
stdcall; export;
var h:HWND;
begin
h:=findwindow('Winamp v5.x',nil);
sendmessage(h,WM_COMMAND,40044,0);
end;
exports prevtrack;

function pause_botton(mWnd, aWnd: HWND; data, parms: PChar; show, nopause:boolean):integer; stdcall;
export;
var h:HWND;
begin
h:=findwindow('Winamp v5.x',nil);
sendmessage(h,WM_COMMAND,40046,0);
end;
exports pause;

function trackname(mWnd, aWnd: HWND; data, parms: PChar; show, nopause:boolean): integer; stdcall;
var h: hwnd;
buf: array[0..255] of char;
l: integer;
begin
h:= findwindow(pchar('winamp v5.x'), nil);
l:= sendmessage(h, wm_gettextlength, 0, 0);
sendmessage(h, wm_gettext, l + 1, integer(@buf));
lstrcpy(data, PChar(copy(buf, pos('.', buf) + 2, l - pos(' - winamp', buf) -
length(' - winamp') - pos('.', buf))));
result:= 3;
end;
exports trackname;
begin
end.

Как видишь это легко, при желании ты можешь нарастить ее. Ах да... чуть не забыл, тепер переходим к mIRC'у...
Копируй дллку в папку с mIRC. Запускай, заходи на канал (любой...) и пиши, в поле для ввода текта, вот эту команду:
"/dll name.dll command" (без кавычек =)), где name.dll - название твоей дллки, а command:
pause_botton
previous_botton
next_botton
stop_botton
play_botton

Также существует возможность просмотра всех команд:
"$dll(name.dll, command)" , где name.dll - название твоей дллки, а command:
trackname

Вроде усе....

Категория: Статьи по кодингу | Добавил: Jimmy (08.02.2008) | Автор: Jimmy Jonezz
Просмотров: 1180 | Комментарии: 6 | Рейтинг: 0.0/0 |
Всего комментариев: 1
1 Jimmy  
0
По мойму примитивно, но для новичка это как глоток свежей воды...

Имя *:
Email *:
Код *:
Форма входа
Поиск
Друзья сайта
Статистика

Онлайн всего: 1
Гостей: 1
Пользователей: 0