Reply
Logi Visitor
Mpyra
Posts: 32
Registered: ‎06-30-2010
0

hello, i am trying to get scripts to work in different m-states

hello, i have some different scripts that i only want to work in different m-states, at the moment it seems that my scriptsf for different g-keys work in all different m-states, is there a way to make them m-state specific?

 

thanks!

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

Re: hello, i am trying to get scripts to work in different m-states

Yes, you need to check the M state as well as the G key before you continue.

 

Example:

 

  if event == "G_PRESSED" and arg == 1 and GetMKeyState("lhc") == 1 then

    -- do your script

  end

Logi Visitor
Mpyra
Posts: 32
Registered: ‎06-30-2010
0

Re: hello, i am trying to get scripts to work in different m-states

hello bystander, thank you for your responce, um like this:

 

function OnEvent(event, arg, family)

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

        ReleaseKey("b"); PressKey("b"); PressKey("w")

    end

if (event=="G_PRESSED" and arg==10) and GetMKeyState("lhc")

        ReleaseKey("b"); PressKey("b"); PressKey("a")

    end

    if (event=="G_PRESSED" and arg==11) and GetMKeyState("lhc")

        ReleaseKey("b"); PressKey("b"); PressKey("s")

    end

    if (event=="G_PRESSED" and arg==12) and GetMKeyState("lhc")

        ReleaseKey("b"); PressKey("b"); PressKey("d")

    end

    if (event=="G_PRESSED" and arg==13) and GetMKeyState("lhc")

        PressKey("q"); Sleep(100);  PressKey("f"); Sleep(100);  PressKey("b")

    end

if (event=="G_PRESSED" and arg==2) and GetMKeyState("lhc")

        PressKey("q");  PressKey("l")

    end

    if (event=="G_RELEASED" and arg==4) and GetMKeyState("lhc")

        ReleaseKey("w")

    end

    if (event=="G_RELEASED" and arg==10) and GetMKeyState("lhc")

        ReleaseKey("a")

    end

    if (event=="G_RELEASED" and arg==11) and GetMKeyState("lhc")

        ReleaseKey("s")

    end

    if (event=="G_RELEASED" and arg==12) and GetMKeyState("lhc")

        ReleaseKey("d")

    end

    if (event=="G_RELEASED" and arg==2) and GetMKeyState("lhc")

        ReleaseKey("q");  ReleaseKey("l")

    end

    if (event=="G_RELEASED" and arg==13) and GetMKeyState("lhc")

        ReleaseKey("q");  Sleep(100);  ReleaseKey("f"); Sleep(100);  ReleaseKey("b")

    end

     end

 

what do i put where it says "lhc"?

 

also i am getting a syntax error line5 with this scripty any idea why?

 

thanks!

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

Re: hello, i am trying to get scripts to work in different m-states

[ Edited ]

If you are going to do it for everything, you would be best to use GetMKeyState one time per OnEvent.

 

Example:

 

function OnEvent(event, arg, family)

  mState = GetMKeyState("lhc")

 

  if event == "G_PRESSED" and arg == 4 and mState == 1 then

    ReleaseKey("b"); PressKey("b"); PressKey("w")

  end

....

 

 

You forget to compare GetMKeyState to a value.  GetMKeyState will return what Mstate it is on, you now have to make sure that Mstate is the state you want the script to run on.

 

As to your other question, what to put in place of "lhc"...

"lhc" is what you would use if you wanting the script to run on a G13 (or other left handed controllers), use "kb" for keyboards and "mouse" for the mouse (currently there are no Mstates for mouse, but "mouse" does work for SetBacklightColor.)

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

Re: hello, i am trying to get scripts to work in different m-states

Another note, "lhc", "kb" and "mouse" are all families.  You can also test to make sure the event generated from the right device by adding a comparison for family.

Logi Visitor
Mpyra
Posts: 32
Registered: ‎06-30-2010
0

Re: hello, i am trying to get scripts to work in different m-states

great okay, thanks, so i have rebuilt the script, this si what i've got:

 

function OnEvent(event, arg, family)

mState = GetMKeyState("lhc")

  if event == "G_PRESSED" and arg == 4 and mState == 1 then

   ReleaseKey("b"); PressKey("b"); PressKey("w")

    end

    if (event=="G_PRESSED" and arg==10) and and mState == 1 then

        ReleaseKey("b"); PressKey("b"); PressKey("a")

    end

    if (event=="G_PRESSED" and arg==11) and mState == 1 then

        ReleaseKey("b"); PressKey("b"); PressKey("s")

    end

    if (event=="G_PRESSED" and arg==12) and mState == 1 then

        ReleaseKey("b"); PressKey("b"); PressKey("d")

    end

    if (event=="G_PRESSED" and arg==13) and mState == 1 then

        PressKey("q"); Sleep(100);  PressKey("f"); Sleep(100);  PressKey("b")

    end

if (event=="G_PRESSED" and arg==2) and mState == 1 then

        PressKey("q");  PressKey("l")

    end

    if (event=="G_RELEASED" and arg==4) and mState == 1 then

        ReleaseKey("w")

    end

    if (event=="G_RELEASED" and arg==10) and mState == 1 then

        ReleaseKey("a")

    end

    if (event=="G_RELEASED" and arg==11) and mState == 1 then

        ReleaseKey("s")

    end

    if (event=="G_RELEASED" and arg==12) and mState == 1 then

        ReleaseKey("d")

    end

    if (event=="G_RELEASED" and arg==2) and mState == 1 then

        ReleaseKey("q");  ReleaseKey("l")

    end

    if (event=="G_RELEASED" and arg==13) and mState == 1 then

        ReleaseKey("q");  Sleep(100);  ReleaseKey("f"); Sleep(100);  ReleaseKey("b")

    end

     end

 

there's a problem though, syntax error line 5? why?

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

Re: hello, i am trying to get scripts to work in different m-states

[ Edited ]

You have two and's in the comparison on line 6.

 

Many syntax errors will give you the line before the actual error (seems to be most the time for me).

Logi Visitor
Mpyra
Posts: 32
Registered: ‎06-30-2010
0

Re: hello, i am trying to get scripts to work in different m-states

, oh wow, lol, how did i miss that thanks again bystander!