Reply
Logi Browser
Hella
Posts: 7
Registered: ‎03-18-2011
0
Accepted Solution

MouseMoveTo help

[ Edited ]

Hey all, I am trying to set up a script that runs when I press G4. This is what I have exactly;

 

function OnEvent(event, arg)

if (event == "G_PRESSED" and arg == 4) then

MoveMouseTo(52114, 13665)

Sleep(500)

PressAndReleaseMouseButton(2)

Sleep(500)

MoveMouseTo(45442, 18799)

Sleep(500)

PressAndReleaseMouseButton(1)

 

 

I am having a few problems. I don't know if this matters but the "script" is assigned to the G4 key (like you would assign a macro to a key)

 

Anyway,

1. It hangs at the first MoveMouseTo event and doesn't execute the command, it doesn't even move to the location.

2. When I save and then switch to the program the script is for it attempts to run the script before I even press G4 (but still fails at the first MoveMouseTo.

 

Any help? If you need more info please let me know.

 

Forgot to metion this is for the g510

Logi Guru
bystander
Posts: 1,121
Registered: ‎06-04-2010
0

Re: MouseMoveTo help

Can you post the full script?

 

What you currently have wouldn't run.  There is no end at the end of the if then statement nor one for the OnEvent function.

Logi Browser
Hella
Posts: 7
Registered: ‎03-18-2011
0

Re: MouseMoveTo help

Ok, the no "end" on the two was my first problem. The remaining problem is that when I save from the editor and then alt-talb into the program, or click on the program in the background to switch to it, the script will run instantly upon switching to the program without me pressing G4 to start it, and G4 key is what i have the script bound to. this is the new full script, copied everything

 

function OnEvent(event, arg)

end

if (event == "G_PRESSED" and arg == 4) then

end

MoveMouseTo(52114, 13665)
Sleep(500)
PressAndReleaseMouseButton(2)
Sleep(500)
MoveMouseTo(45442, 18799)
Sleep(500)
PressAndReleaseMouseButton(1)

kgober
Posts: 3,754
Kudos: 436
Solutions: 286
Registered: ‎05-28-2009

Re: MouseMoveTo help

you probably want this:

 

function OnEvent(event, arg)
    if (event == "G_PRESSED" and arg == 4) then
        MoveMouseTo(52114, 13665)
        Sleep(500)
        PressAndReleaseMouseButton(2)
        Sleep(500)
        MoveMouseTo(45442, 18799)
        Sleep(500)
        PressAndReleaseMouseButton(1)
    end
end

 

-ken

 

________________________________
I do not work for Logitech. I'm just a user.
Logi Guru
bystander
Posts: 1,121
Registered: ‎06-04-2010
0

Re: MouseMoveTo help

Ya, that's what I was talking about.

Logi Browser
Hella
Posts: 7
Registered: ‎03-18-2011
0

Re: MouseMoveTo help

Exactly what i needed, thanks :smileyhappy:

Logi Apprentice
Baramon
Posts: 208
Registered: ‎12-31-2011
0

Re: MouseMoveTo help

Makes me sad when i realized this can't be done for G700 now

Logi Guru
bystander
Posts: 1,121
Registered: ‎06-04-2010
0

Re: MouseMoveTo help


Baramon wrote:

Makes me sad when i realized this can't be done for G700 now


Why not?

 

kgober
Posts: 3,754
Kudos: 436
Solutions: 286
Registered: ‎05-28-2009
0

Re: MouseMoveTo help

G700 isn't supported in LGS yet.  supposedly LGS 8.40 will add it (along with G9, G9x and a few others also).

 

-ken

________________________________
I do not work for Logitech. I'm just a user.
Logi Guru
bystander
Posts: 1,121
Registered: ‎06-04-2010
0

Re: MouseMoveTo help

[ Edited ]

It is possible still, although at the time I thought the G700 supported the LGS.  It requires a bit more work and I have a script setup that will do it rather easily.

 

http://www.logitechusers.com/game-profiles-macros-discussion/14412-ll-project-part-2-a.html

 

You'll notice that it looks a lot like the format kgober showed us once, but with added functionality.

 

Given your level of coding, it may be beyond your ability.