bobdylanfrank (05-29-2020),UnderFear (11-10-2020)
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
}
bobdylanfrank (05-29-2020),UnderFear (11-10-2020)
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
bobdylanfrank (05-29-2020)
To use the funtion, BackgroundClick(x, y, messageDelay, PID). The x and y are coordinates. What is message delay and PID
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?
Last edited by bobdylanfrank; 06-04-2020 at 11:22 PM.
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.
bobdylanfrank (06-05-2020)
It doesn't work help
My code:
F6::WinGet, pidn, PID, A
F7::MsgBox, %pidn%
F10::BackgroundClick(888, 488, 100, %pidn%)