1

I'm using AutoHotKey to auto-click in Roblox, as many of the games are simple clicker games. This works fine if I use the regular Click or MouseClick commands, but that actually moves my mouse cursor into the Roblox window to do the click. I'm looking to be able to send mouse click events to the Roblox window while I do things on the computer on another monitor with the mouse and keyboard.

I believe the ControlClick command is made for this purpose, and it seems to work for other windows (like text editors), but doesn't seem to perform a click in the Roblox window, even if Roblox is the active/in-focus window. I've also tried using the PostMessage command, again with no luck.

Here are some code snippets of what I've tried using:

Method 1:

; This works, but moves the mouse cursor to the window, which I don't want.
MouseGetPos, mouseX, mouseY, windowId
Loop, 100
{
    Click, %mouseX%, %mouseY%
    Sleep, 10
}

Method 2:

; This does not actually perform a click in Roblox.
MouseGetPos, mouseX, mouseY, windowId
Loop, 100
{
    ControlClick, x%mouseX% y%mouseY%, ahk_id %windowId%
    Sleep, 10
}

Method 3:

; This does not actually perform a click in Roblox.
MouseGetPos, mouseX, mouseY, windowId
SetControlDelay -1
Loop, 100
{
    ControlClick, x%mouseX% y%mouseY%, ahk_id %windowId%,,,, NA
    Sleep, 10
}

Method 4:

; This does not actually perform a click in Roblox.
; Use Window title to match and try sending 2 clicks.
MouseGetPos, mouseX, mouseY, windowId
SetControlDelay -1
Loop, 100
{
    ControlClick, x%mouseX% y%mouseY%, Roblox, , Left, 2
    Sleep, 10
}

Method 5:

; This does not actually perform a click in Roblox.
MouseGetPos, mouseX, mouseY, windowId
Loop, 100
{
    PostClick(mouseX, mouseY, windowId)
    Sleep, 10
}

PostClick(x,y,windowId) 
{
    lParam := x & 0xFFFF | (y & 0xFFFF) << 16
    PostMessage, 0x201, , %lParam%, , ahk_id %windowId% ;WM_LBUTTONDOWN 
    PostMessage, 0x202, , %lParam%, , ahk_id %windowId% ;WM_LBUTTONUP 
}

I imagine this problem likely happens with many/any video games, not just Roblox, but I'm not certain. If you have any ideas or suggestions for me to try I'd greatly appreciate it. Thanks!

1 Answer 1

0

As far as I know roblox has some security stuff that prevents you from doing that. You probably have to make a deeper winApi call using DllCall.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.