📄 exceedtech.dashboard.ampcontrol.library.cpp
字号:
// ExceedTech.Dashboard.AmpControl.Library.cpp : Defines the initialization routines for the DLL.
//
#include "stdafx.h"
#include "ExceedTech.Dashboard.AmpControl.Library.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
static int playerID = 0;
__declspec(dllexport) void AmpControl_OpenFileDialog(void)
{
HWND hwnd_winamp = FindPlayer(0);
if (hwnd_winamp != 0) {
if (playerID == 2) {
SendMessage(hwnd_winamp, WM_COMMAND, W2_FILEPLAY, 0);
}
else if (playerID == 3) {
SendW3Key(hwnd_winamp, W3_FILEPLAY);
}
else if (playerID == 4) {
SendW3Key(hwnd_winamp, S1_FILEPLAY);
}
}
}
__declspec(dllexport) char* AmpControl_GetPlayingTitle(void)
{
HWND hwnd_winamp = FindPlayer(0);
if (hwnd_winamp != 0) {
if (playerID == 2 || playerID == 3 || playerID == 4) {
GetWindowText(hwnd_winamp, currTitle, sizeof(currTitle));
// just in case
currTitle[2047] = '\0';
if (strlen(currTitle) <= 0) {
return "None";
}
else {
return currTitle;
}
}
}
return "Not running";
}
__declspec(dllexport) void AmpControl_Next(void)
{
HWND hwnd_winamp = FindPlayer(0);
if (hwnd_winamp != 0) {
if (playerID == 2) {
SendMessage(hwnd_winamp, WM_COMMAND, W2_NEXT, 0);
}
else if (playerID == 3) {
SendW3Key(hwnd_winamp, W3_NEXT);
}
else if (playerID == 4) {
SendW3Key(hwnd_winamp, S1_NEXT);
}
}
}
__declspec(dllexport) void AmpControl_Stop(void)
{
HWND hwnd_winamp = FindPlayer(0);
if (hwnd_winamp != 0) {
if (playerID == 2) {
SendMessage(hwnd_winamp, WM_COMMAND, W2_STOP, 0);
}
else if (playerID == 3) {
SendW3Key(hwnd_winamp, W3_STOP);
}
else if (playerID == 4) {
SendW3Key(hwnd_winamp, S1_STOP);
}
}
}
__declspec(dllexport) void AmpControl_Play(void)
{
HWND hwnd_winamp = FindPlayer(0);
if (hwnd_winamp != 0) {
if (playerID == 2) {
SendMessage(hwnd_winamp, WM_COMMAND, W2_PLAY, 0);
}
else if (playerID == 3) {
SendW3Key(hwnd_winamp, W3_PLAY);
}
else if (playerID == 4) {
SendW3Key(hwnd_winamp, S1_PLAY);
}
}
}
__declspec(dllexport) void AmpControl_Pause(void)
{
HWND hwnd_winamp = FindPlayer(0);
if (hwnd_winamp != 0) {
if (playerID == 2) {
SendMessage(hwnd_winamp, WM_COMMAND, W2_PAUSE, 0);
}
else if (playerID == 3) {
SendW3Key(hwnd_winamp, W3_PAUSE);
}
else if (playerID == 4) {
SendW3Key(hwnd_winamp, S1_PAUSE);
}
}
}
__declspec(dllexport) void AmpControl_Previous(void)
{
HWND hwnd_winamp = FindPlayer(0);
if (hwnd_winamp != 0) {
if (playerID == 2) {
SendMessage(hwnd_winamp, WM_COMMAND, W2_PREV, 0);
}
else if (playerID == 3) {
SendW3Key(hwnd_winamp, W3_PREV);
}
else if (playerID == 4) {
SendW3Key(hwnd_winamp, S1_PREV);
}
}
}
__declspec(dllexport) bool AmpControl_isRunning(bool)
{
HWND hwnd_winamp = FindPlayer(0);
if (hwnd_winamp == 0)
return false;
else
return true;
}
__declspec(dllexport) bool AmpControl_isPaused(bool)
{
int ret;
HWND hwnd_winamp = FindPlayer(0);
if (hwnd_winamp != 0) {
if (playerID == 2) {
ret = SendMessage(hwnd_winamp, WM_USER, 0, W2_ISPLAYING);
if (ret == 3)
return true;
}
if (playerID == 3) {
char title[2048];
char* found;
GetWindowText(hwnd_winamp, title, sizeof(title));
title[2047] = '\0';
found = strstr(title, "(paused)");
if (found != NULL)
return true;
else
return false;
}
}
return false;
}
__declspec(dllexport) bool AmpControl_isPlaying(bool)
{
int ret;
HWND hwnd_winamp = FindPlayer(0);
if (hwnd_winamp != 0) {
if (playerID == 2) {
ret = SendMessage(hwnd_winamp, WM_USER, 0, W2_ISPLAYING);
if (ret == 1)
return true;
else
return false;
}
if (playerID == 3) {
char title[2048];
char* found;
GetWindowText(hwnd_winamp, title, sizeof(title));
title[2047] = '\0';
found = strstr(title, "(playing)");
if (found != NULL)
return true;
else
return false;
}
}
return false;
}
void SendW3Key(HWND hwnd_winamp,char message)
{
short key = VkKeyScan(message);
UINT scancode = MapVirtualKey(key, 0);
PostMessage(hwnd_winamp, WM_KEYDOWN, key, scancode);
PostMessage(hwnd_winamp, WM_CHAR, key, scancode);
PostMessage(hwnd_winamp, WM_KEYUP, key, scancode);
}
HWND FindPlayer(int wanted)
{
HWND hwnd;
if (wanted == 0 || wanted == 4) {
hwnd = FindWindow("Sonique Window Class", NULL);
if (hwnd != 0) {
playerID = 4;
return hwnd;
}
}
if (wanted == 0 || wanted == 3) {
hwnd = FindWindow("Studio", NULL);
if (hwnd != 0) {
playerID = 3;
return hwnd;
}
}
if (wanted == 0 || wanted == 2) {
hwnd = FindWindow("Winamp v1.x", NULL);
if (hwnd != 0) {
playerID = 2;
return hwnd;
}
}
playerID = 0;
return 0;
}
// CExceedTechDashboardAmpControlLibraryApp
BEGIN_MESSAGE_MAP(CExceedTechDashboardAmpControlLibraryApp, CWinApp)
END_MESSAGE_MAP()
// CExceedTechDashboardAmpControlLibraryApp construction
CExceedTechDashboardAmpControlLibraryApp::CExceedTechDashboardAmpControlLibraryApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
// The one and only CExceedTechDashboardAmpControlLibraryApp object
CExceedTechDashboardAmpControlLibraryApp theApp;
// CExceedTechDashboardAmpControlLibraryApp initialization
BOOL CExceedTechDashboardAmpControlLibraryApp::InitInstance()
{
CWinApp::InitInstance();
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -