Sending text to Nostale chat

07/22/2015 04:22 IsThisMyName#1
Hi.
Does anyone know how to send text or single characters to opened chat window (preferable WinApi function)?
I tried SendMessage, PostMessage, keybd_event (works fine in loging screen but not in chat).
I'd be grateful for any help or hint.

EDIT:

Actually keybd_event works in this case (probably SendInput also).
Problem occured because of different behaviour of WinApi function in Delphi and C#.
07/22/2015 13:38 WalrossGreat#2
Send packet "say" to server.
07/22/2015 13:51 k4r3r#3
But when you send "say", other players see it, but you not. You also have to emulate "msg" packet ;)
07/22/2015 14:20 BladeTiger12#4
Whats the problem :D
Itīs important that other players see it.

I dont think that he know, how to send packets.
07/22/2015 14:30 FI0w#5
Do it like Spam bot? xD Send Text like a bot to Nostale and after that the key "Enter"
07/22/2015 23:42 k4r3r#6
Quote:
Originally Posted by BladeTiger12 View Post
Whats the problem :D
Itīs important that other players see it.

I dont think that he know, how to send packets.
There are too many tutorials on e*pvp...
07/23/2015 00:03 IsThisMyName#7
It's not an issue of knowing how to send packets - just don't want to interfere in game.
Only reading memory and responding by simulating player with WinApi keyboard and mouse functions.
07/23/2015 11:57 WalrossGreat#8
@k4r3r
Where? I saw only sources without any comments to copy&paste :D

@topic
You should do function that changes char in byte key code, then sending it for example with PostMessage.
07/23/2015 17:28 IsThisMyName#9
@WalrossGreat
I'm using WinApi's VkKeyScan to get the numeric code of a character with combination of PostMessage or keybd_event (SendInput is too complicated for now :P )

PostMessage and SendMessage function can send keycodes to nt window but not the focused element like chat or login edit boxes - probably something to do with directX and openGL in game interface. Maybe just finding handle to speific controll would do the trick but this is too much work :P
By PostMessage or SendMessage and keycodes I use ingame keyboardcontroled features like opening specific windows, using skills etc.

keybd_event and SendInput send key to active focused controll instead of entire window, so they can be used to send text (char by char from string as a char table).
Downside of this method is that the nt window must be visible and focused during sending text - for me not an issue, I don't require it to work on minimized window.
07/23/2015 20:18 k4r3r#10
Code:
void SimulateKey(char key)
{
	short val = VkKeyScanA(tolower(key));

	SendMessage(hWnd, WM_KEYDOWN, val, NULL);
	SendMessage(hWnd, WM_KEYUP, val, NULL);
}

SimulateKey('1');
Just get hWnd of the window and you can send keys in background, enjoy ;d
07/23/2015 21:07 Trollface-#11
If you know how to call asm functions, i can attach you the chat function. :-)
07/24/2015 12:14 ernilos#12
Quote:
Originally Posted by Trollface- View Post
If you know how to call asm functions, i can attach you the chat function. :-)
Wow, I'm interested on this, could you post them? ^~^
07/24/2015 14:05 BladeTiger12#13
@ernilos this function is easy to find & to implement, here:
Code:
#include <iostream>
#include <string>

struct NosWChar {
private:
	int m_len;
	wchar_t m_msg[256];

public:
	NosWChar(const std::string &str) {
		m_len = str.length() * 2;

		for (unsigned int i = 0; i < str.length(); i++)
			m_msg[i] = str[i];

		m_msg[str.length()] = 0x00;
	}

	wchar_t *msg() {
		return m_msg;
	}
	int length() {
		return m_len;
	}
};

void main() {
	NosWChar nosStr("Message in chat");

	DWORD callSendChat = 0x00626904;
	wchar_t *pMsg = nosStr.msg();

	__asm {
		MOV EDX, pMsg
		MOV EAX, DWORD PTR DS : [0x678AD8]
		MOV EAX, [EAX]
		CALL callSendChat
	}
}
@Thread Creator: If you can call functions use this.
07/24/2015 14:39 WalrossGreat#14
@BladeTiger12
Nice, but just send "say" is easier, isn't it?
07/24/2015 15:40 BladeTiger12#15
Ye, you're right, but if you use the function, you'll see own message in chat.
(And it's just easier if you write a function like sendPacket("say MESSAGE"))