forum

Java code to intercept MSN status integration?

posted
Total Posts
5
Topic Starter
Nekres
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)

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.
Zain Sugieres
Who uses MSN nowadays lmao
Hika
wait what was the point of rewriting it in java
Topic Starter
Nekres
@Zain Sugieres no one, it just abuses the option in osu (or other programs with such) so I can show the song title in other programs.

@Hika I want to implement it in Phantombot , which is written in java and calls java methods with javascript.

It may come in handy in other little tools as well
Stefan
An actual case for the development forum, moved.
Please sign in to reply.

New reply