AutoHotKey无法将鼠标单击事件发送到不活动的Roblox窗口

时间:2018-08-29 15:39:06

标签: click mouse autohotkey roblox

我使用AutoHotKey自动点击Roblox,因为许多游戏都是简单的答题器游戏。如果我使用常规的ClickMouseClick命令,则可以正常工作,但这实际上将鼠标光标移到Roblox窗口中进行单击。我希望能够在使用鼠标和键盘在另一台显示器上的计算机上执行操作时将鼠标单击事件发送到Roblox窗口。

我相信ControlClick命令是为此目的而设计的,它似乎适用于其他窗口(例如文本编辑器),但是即使Roblox是活动/对焦窗口。我也尝试过使用PostMessage命令,但还是没有运气。

以下是我尝试使用的代码片段:

方法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
}

方法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
}

方法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
}

方法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
}

方法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 
}

我想这个问题可能会发生在很多/任何视频游戏中,而不仅仅是Roblox,但我不确定。如果您有任何想法或建议让我尝试,我将不胜感激。谢谢!

0 个答案:

没有答案