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
|
2012-01-23 06:36:15 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2010-08-10 16:02:40 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <windows.h>
|
2011-02-03 18:09:24 +00:00
|
|
|
#include "../../Library/Export.h" // Rainmeter's exported functions
|
2011-01-30 09:31:41 +00:00
|
|
|
|
2010-08-10 16:02:40 +00:00
|
|
|
void SendKey(WORD key)
|
|
|
|
{
|
|
|
|
KEYBDINPUT kbi;
|
2012-01-08 17:35:29 +00:00
|
|
|
kbi.wVk = key;
|
2010-08-10 16:02:40 +00:00
|
|
|
kbi.wScan = 0;
|
2012-01-08 17:35:29 +00:00
|
|
|
kbi.dwFlags = 0;
|
2010-08-10 16:02:40 +00:00
|
|
|
kbi.time = 0;
|
2012-01-08 17:35:29 +00:00
|
|
|
kbi.dwExtraInfo = (ULONG_PTR)GetMessageExtraInfo();
|
2010-08-10 16:02:40 +00:00
|
|
|
|
|
|
|
INPUT input;
|
|
|
|
input.type = INPUT_KEYBOARD;
|
|
|
|
input.ki = kbi;
|
|
|
|
|
|
|
|
SendInput(1, &input, sizeof(INPUT));
|
|
|
|
}
|
|
|
|
|
2012-01-08 17:35:29 +00:00
|
|
|
PLUGIN_EXPORT void ExecuteBang(LPCTSTR args, UINT id)
|
2010-08-10 16:02:40 +00:00
|
|
|
{
|
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
|
|
|
|
{
|
2012-01-08 17:35:29 +00:00
|
|
|
RmLog(LOG_WARNING, L"MediaKey.dll: Unknown bang");
|
2010-08-10 16:02:40 +00:00
|
|
|
}
|
|
|
|
}
|