Trove Background Click and ClickDrag Functions For AHK

Posts 115 of 30 · Page 1 of 2
Trove Background Click and ClickDrag Functions For AHK
I present to you the 2 functions I made for clicking and click-dragging in trove while the window is not focused.
It's not perfect and I can't guarantee that it will work in all situations but seems to work pretty well for me.

Enjoy you freeloaders.


BackgroundClick(x, y, messageDelay, PID) {

lParam := x | (y << 16)

SendMessage, 0x006, 00000002, 00000000, , ahk_pid %PID% ;ACTIVE
PostMessage, 0x200, 00000001, %lParam%, , ahk_pid %PID% ;MOUSEMOVE

PostMessage, 0x201, 0x00120BD6, 0x01D80041, , ahk_pid %PID% ;LBUTTONDOWN
Sleep, %messageDelay%
PostMessage, 0x202, 0x00120BD6, 0x01D80041, , ahk_pid %PID% ;LBUTTONUP

return
}

BackgroundClickDrag(startX, startY, endX, endY, messageDelay, PID) {
;MessageDelay is used twice because we are using 3 messages that use the mouse

lParam := startX | (startY << 16)

SendMessage, 0x006, 00000002, 00000000, , ahk_pid %PID% ;ACTIVE

PostMessage, 0x200, 00000001, %lParam%, , ahk_pid %PID% ;MOUSEMOVE

PostMessage, 0x201, 00000001, %lParam%, , ahk_pid %PID% ;LBUTTONDOWN
Sleep, %messageDelay%
lParam := endX | (endY << 16)
PostMessage, 0x200, 0x0001, %lParam%, , ahk_pid %PID% ;MOUSEMOVE
Sleep, %messageDelay%
PostMessage, 0x202, 00000000, 02020001, , ahk_pid %PID% ;LBUTTONUP

return
}
Could you please tell me how to locate and specify coordinates for the programme? I have a coordinate script but not sure if its the same for this ahk script. The check coordinate script I uses is simple:

CoordMode, Mouse, Screen
SetTimer, Check, 20
return

Check:
MouseGetPos, xx, yy
Tooltip %xx%`, %yy%
return

Esc::ExitApp
Quote Originally Posted by bobdylanfrank View Post
Could you please tell me how to locate and specify coordinates for the programme? I have a coordinate script but not sure if its the same for this ahk script. The check coordinate script I uses is simple:

CoordMode, Mouse, Screen
SetTimer, Check, 20
return

Check:
MouseGetPos, xx, yy
Tooltip %xx%`, %yy%
return

Esc::ExitApp
I use the window spy that comes with ahk and pick the client coords.
To use the funtion, BackgroundClick(x, y, messageDelay, PID). The x and y are coordinates. What is message delay and PID
Quote Originally Posted by bobdylanfrank View Post
To use the funtion, BackgroundClick(x, y, messageDelay, PID). The x and y are coordinates. What is message delay and PID
MessageDelay is the milliseconds to sleep between each message in the function it's used once in the click and twice in the drag-click.
PID = ProcessID. You can get it with WinGet, check the AHK docs for more info on it.
Quote Originally Posted by phj280600 View Post
MessageDelay is the milliseconds to sleep between each message in the function it's used once in the click and twice in the drag-click.
PID = ProcessID. You can get it with WinGet, check the AHK docs for more info on it.
Do not forget that Send / Post are different, the first sends the message immediately and waits for a response, and the second puts the message in the queue.
Wow, I got it working really good. Just 1 last question to clear things up. Using windows spy, I see 3 coordinates for mouse position: screen, window and client. Which one of these things should I be using?
Quote Originally Posted by bobdylanfrank View Post
Wow, I got it working really good. Just 1 last question to clear things up. Using windows spy, I see 3 coordinates for mouse position: screen, window and client. Which one of these things should I be using?
You send a message to the WINDOW (client area), so you must use the coordinates of the WINDOW (client area).

WM_NCMOUSEMOVE - mouse movement in a non-client area (window title ...)
WM_MOUSEMOVE - mouse movement in the client area

You connect Spy ++ to the game window, activate the window (just go into it), and get the coordinates. Just notice, if you change the size of the window, then the coordinates will change.
Quote Originally Posted by Tisako View Post
You send a message to the WINDOW (client area), so you must use the coordinates of the WINDOW (client area).

WM_NCMOUSEMOVE - mouse movement in a non-client area (window title ...)
WM_MOUSEMOVE - mouse movement in the client area

You connect Spy ++ to the game window, activate the window (just go into it), and get the coordinates. Just notice, if you change the size of the window, then the coordinates will change.
Well said
It doesn't work help

My code:
F6::WinGet, pidn, PID, A
F7::MsgBox, %pidn%
F10::BackgroundClick(888, 488, 100, %pidn%)
Quote Originally Posted by Trollface482 View Post
It doesn't work help

My code:
F6::WinGet, pidn, PID, A
F7::MsgBox, %pidn%
F10::BackgroundClick(888, 488, 100, %pidn%)
Could you be more specific then "it doesn't work"? Are you sure you have the right coords? are you sure trove was active when you got the PID since you're using A to get it from the current active window?
Quote Originally Posted by phj280600 View Post
Could you be more specific then "it doesn't work"? Are you sure you have the right coords? are you sure trove was active when you got the PID since you're using A to get it from the current active window?
The coordinates I was looking through Spy++ (Relative). I got the PID by pressing F6 in the active Trove window. I forgot to click the translate button. Sorry
Quote Originally Posted by Trollface482 View Post
Координаты я смотрел через Spy++ (Relative). PID я получал по нажатию F6 в активном окне Trove.
I don't speak Russian.
Quote Originally Posted by phj280600 View Post
I don't speak Russian.
I fixed it
Quote Originally Posted by Trollface482 View Post
I fixed it
Idk what the issue is, try checking if the message is sent with Spy++
Posts 115 of 30 · Page 1 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?