So, there was this code on Github, which is written in C#
MSNEventListener
The code listens to MSN events and checks if its contains an specific {Array} [].
Osu! has toggleable options that, if turned on, integrates a {string} 'title - artist' of the now playing song into the status of a {messenger} ['MSN, 'Skype', 'Yahoo']. The code above eavedrops on the communication between osu and MSN.
I tried to rewrite it using Java and the JNA library: (while I am a newb in java)
If somebody can look, compile and fix my beginner code. That would be awesome! EVEN more awesome if it is done without any extra libraries like JNA
I am willing to gift a game on Steam after successful help.
MSNEventListener
The code listens to MSN events and checks if its contains an specific {Array} [].
Osu! has toggleable options that, if turned on, integrates a {string} 'title - artist' of the now playing song into the status of a {messenger} ['MSN, 'Skype', 'Yahoo']. The code above eavedrops on the communication between osu and MSN.
I tried to rewrite it using Java and the JNA library: (while I am a newb in java)
public class MSNeventListener {
LRESULT WINAPI MyMSNwnd(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
if (Msg == WM_COPYDATA)
{
COPYDATASTRUCT* pcds = (COPYDATASTRUCT*) lParam;
if (pcds->dwData == 1)
{
LPCSTR lpszString = (LPCSTR) (pcds->lpData);
printf("%.*s\n", lpszString, pcds->cbData);
return TRUE;
}
}
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
public Array getNowPlayingMSN() {
JNIEXPORT jint JNICALL Java_WindowsIPC_openDataCopy
(JNIEnv * env, jobject obj, jstring message)
{
WNDCLASS WndClass;
memset(&WndClass, 0, sizeof(WndClass));
WndClass.lpfnWndProc = &MyMSNwnd;
WndClass.lpszClassName = TEXT("MsnMsgrUIManager");
WndClass.hInstance = GetModuleHandle(NULL);
if (!RegisterClass(&WndClass)) {
printf("failed to register class: %d\n", GetLastError());
return -1;
}
HWND hwnd = CreateWindowEx(0, WndClass.lpszClassName, NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL);
if (hwnd == NULL) {
printf("Window Creation failed: %d\n", GetLastError());
return -1;
}
MSG msg;
while (GetMessage (&msg, NULL, 0, 0)) {
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return 0; // success
}
}
}
If somebody can look, compile and fix my beginner code. That would be awesome! EVEN more awesome if it is done without any extra libraries like JNA
I am willing to gift a game on Steam after successful help.