2010-08-10 16:02:40 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2010 poiru
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <string>
|
|
|
|
#include "..\..\Library\Export.h" // Rainmeter's exported functions
|
|
|
|
|
|
|
|
/* The exported functions */
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
__declspec( dllexport ) UINT Update(UINT id);
|
|
|
|
__declspec( dllexport ) UINT GetPluginVersion();
|
|
|
|
__declspec( dllexport ) LPCTSTR GetPluginAuthor();
|
|
|
|
__declspec( dllexport ) void ExecuteBang(LPCTSTR args, UINT id);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SendKey(WORD key);
|
|
|
|
|
|
|
|
/*
|
|
|
|
This function is called when new value should be measured.
|
|
|
|
The function returns the new value.
|
|
|
|
*/
|
|
|
|
UINT Update(UINT id)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SendKey(WORD key)
|
|
|
|
{
|
|
|
|
KEYBDINPUT kbi;
|
|
|
|
kbi.wVk = key; // Provide your own
|
|
|
|
kbi.wScan = 0;
|
|
|
|
kbi.dwFlags = 0; // See docs for flags (mm keys may need Extended key flag)
|
|
|
|
kbi.time = 0;
|
|
|
|
kbi.dwExtraInfo = (ULONG_PTR) GetMessageExtraInfo();
|
|
|
|
|
|
|
|
INPUT input;
|
|
|
|
input.type = INPUT_KEYBOARD;
|
|
|
|
input.ki = kbi;
|
|
|
|
|
|
|
|
SendInput(1, &input, sizeof(INPUT));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ExecuteBang(LPCTSTR args, UINT id)
|
|
|
|
{
|
2010-12-18 19:38:33 +00:00
|
|
|
if (_wcsicmp(args, L"NextTrack") == 0)
|
2010-08-10 16:02:40 +00:00
|
|
|
{
|
|
|
|
SendKey(VK_MEDIA_NEXT_TRACK);
|
|
|
|
}
|
2010-12-18 19:38:33 +00:00
|
|
|
else if (_wcsicmp(args, L"PrevTrack") == 0)
|
2010-08-10 16:02:40 +00:00
|
|
|
{
|
|
|
|
SendKey(VK_MEDIA_PREV_TRACK);
|
|
|
|
}
|
2010-12-18 19:38:33 +00:00
|
|
|
else if (_wcsicmp(args, L"Stop") == 0)
|
2010-08-10 16:02:40 +00:00
|
|
|
{
|
|
|
|
SendKey(VK_MEDIA_STOP);
|
|
|
|
}
|
2010-12-18 19:38:33 +00:00
|
|
|
else if (_wcsicmp(args, L"PlayPause") == 0)
|
2010-08-10 16:02:40 +00:00
|
|
|
{
|
|
|
|
SendKey(VK_MEDIA_PLAY_PAUSE);
|
|
|
|
}
|
2010-12-18 19:38:33 +00:00
|
|
|
else if (_wcsicmp(args, L"VolumeMute") == 0)
|
2010-08-10 16:02:40 +00:00
|
|
|
{
|
|
|
|
SendKey(VK_VOLUME_MUTE);
|
|
|
|
}
|
2010-12-18 19:38:33 +00:00
|
|
|
else if (_wcsicmp(args, L"VolumeDown") == 0)
|
2010-08-10 16:02:40 +00:00
|
|
|
{
|
|
|
|
SendKey(VK_VOLUME_DOWN);
|
|
|
|
}
|
2010-12-18 19:38:33 +00:00
|
|
|
else if (_wcsicmp(args, L"VolumeUp") == 0)
|
2010-08-10 16:02:40 +00:00
|
|
|
{
|
|
|
|
SendKey(VK_VOLUME_UP);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-12-18 19:38:33 +00:00
|
|
|
LSLog(LOG_WARNING, L"Rainmeter", L"MediaKeyPlugin: Unknown bang!");
|
2010-08-10 16:02:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT GetPluginVersion()
|
|
|
|
{
|
|
|
|
return 1000;
|
|
|
|
}
|
|
|
|
|
|
|
|
LPCTSTR GetPluginAuthor()
|
|
|
|
{
|
|
|
|
return L"poiru";
|
|
|
|
}
|