2010-08-10 16:02:40 +00:00
|
|
|
/*
|
2011-05-21 18:17:37 +00:00
|
|
|
Copyright (C) 2010 Birunthan Mohanathas (www.poiru.net)
|
2010-08-10 16:02:40 +00:00
|
|
|
|
|
|
|
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>
|
2011-02-03 18:09:24 +00:00
|
|
|
#include "../../Library/Export.h" // Rainmeter's exported functions
|
2010-08-10 16:02:40 +00:00
|
|
|
|
2011-02-03 18:09:24 +00:00
|
|
|
#include "../../Library/DisableThreadLibraryCalls.h" // contains DllMain entry point
|
2011-01-30 09:31:41 +00:00
|
|
|
|
2010-08-10 16:02:40 +00:00
|
|
|
/* 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
|
|
|
|
{
|
2011-10-12 13:34:04 +00:00
|
|
|
LSLog(LOG_WARNING, NULL, L"MediaKey.dll: Unknown bang");
|
2010-08-10 16:02:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT GetPluginVersion()
|
|
|
|
{
|
|
|
|
return 1000;
|
|
|
|
}
|
|
|
|
|
|
|
|
LPCTSTR GetPluginAuthor()
|
|
|
|
{
|
2011-05-21 18:17:37 +00:00
|
|
|
return L"Birunthan Mohanathas (www.poiru.net)";
|
2010-08-10 16:02:40 +00:00
|
|
|
}
|