Log in

View Full Version : Tibia 11 - Send keys to tibia window



Mahatesh
10-21-2016, 23:24
How do you send keystrokes to the tibia11 client?
This is my sample code (shift + F2):


SendMessage(Util.Handle, Constants.WM_KEYDOWN, (IntPtr)0x10, (IntPtr)0x2A0001);
SendMessage(Util.Handle, Constants.WM_KEYDOWN, (IntPtr)0x71, (IntPtr)0x3C0001);
SendMessage(Util.Handle, Constants.WM_KEYUP, (IntPtr)0x71, (IntPtr)0x3C0001);
SendMessage(Util.Handle, Constants.WM_KEYUP, (IntPtr)0x10, (IntPtr)0x2A0001);

But instead of sending shift+F2, it sends just F2 (or at least, thats the hotkey that is activated)
When I look at spy++, it seems that my fake sends are not the same as actual key presses, key event-wise (pic (http://imgur.com/a/swRwe)).

I don't know spy++ well enough to understand the s/r/p flag, but I wonder if you also use WinAPI to send keys, or do you have another way to send keys to a window that isn't necessarily the focused window.

UPDATE:
I switched to PostMessage, and spy++ shows the EXACT same messages. Same issue as before.

blackd
10-21-2016, 23:38
I am afraid this Tibia client checks if window is focused or not. A lot of things will be ignored unless it is focused.

Mahatesh
10-21-2016, 23:49
This doesn't change the fact that shift is not sent to the client.
I delayed the commands so I would be sure tibia is focused while I send the keys, and I STILL get F2 instead of shift+F2.

Do you use a different mechanism for sending keys to the client? Do you even send keys to the client at all?

blackd
10-22-2016, 00:23
I don't really use it in my main bot, however I have a tool that can send keys when a desired pixel of screen changes. It is called Blackd Guardian and it is open source.
http://blackdtools.com/freedownloads.php