Camilo
Camilo

Reputation: 21

Logitech G-Hub script mouse movement relative active/target window

I just started scripting with G Hub and managed to get some scripts working, but i have read the api and didnt found a easy way to get mouse movements relative to the active/target window.

Is there a way to do it easily or I will have to set the window position (and dimensions) to a variable and not move the window from that position?

I assumed by the api that is not possible to get actions to a target window (?) ie: simulate m key press on a background window

(I know it sounds more like i should use AHK, but just to know)

Upvotes: 1

Views: 20292

Answers (1)

joleytime
joleytime

Reputation: 11

I just started scripting in G series Lua also. I'm assumming that G Series API doc you found is v.8.45 I think that API might be outdated as script won't work at all following it.

This will get you pull mouse position and output it when G9 button is pressed on my G502

function OnEvent(event, arg)
    if event == "MOUSE_BUTTON_PRESSED" and arg == 9 then
    x, y=GetMousePosition()
    OutputLogMessage("Mouse at %d, %d\n",x, y)
end
end

which led me to work it with something like

function OnEvent(event, arg)
    if event == "MOUSE_BUTTON_PRESSED" and arg == 9 then
        MoveMouseTo(32793, 52683)
        Sleep(1000)
        PressMouseButton(1);
        Sleep(20);
        ReleaseMouseButton(1);
        Sleep(1000);
    end
end

Hope this is what you are looking for. Now I just need to get this to loop...

Upvotes: 1

Related Questions