HelpA question to an experienced developers

Posts 1–2 of 2 · Page 1 of 1
A question to an experienced developers
So I try to implement a macro using win32api, so far I tried SendInput and PostMessage functions. I run it elevated and with different delays, but they only seem to affect the games console. Does the game use some other way to gather events? (Using a microcontroller akin to rubberducky usb does work).
PostMessage
Using spy++ I found that when you press the 'F' key for example, 3 messages are send:

First a WM_KEYDOWN with nVirtKey='F', cRepeat=1 and ScanCode=21
Then a WM_CHAR with chCharCode='102', cRepeat=1 and ScanCode=21
Finally a WM_KEYIP with nVirtKey='F', cRepeat=1 and ScanCode=21

While the nVirtKey (or/and the chCharcode, I don't really know tbh) does affect the game's console, it is the ScanCode that affects the game.
For example, a ScanCode of 21 corresponds to fishing, 10 is using potion. You can find out which ScanCode corresponds to an action by watching messages with spy++ while doing it.

In order to replay the message with the right ScanCode, I found out that you can use (in Python):
Code:
win32api.PostMessage(hwnd,win32con.WM_KEYDOWN, x, y)
time.sleep(0.1)
win32api.PostMessage(hwnd,win32con.WM_KEYUP, x, y)
Where :
  • hwnd is the window corresponding to Trove, you can use win32gui.FindWindow(None, "Trove") to get it.
  • x corresponds to nVirtKey (you can leave it to 0)
  • y contains the ScanCode, if y=0x210000 the ScanCode will be 21, y=0x100000 the ScanCode will be 10, etc...

Hoping this can help you !
Posts 1–2 of 2 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us