- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
hello, i am trying to get scripts to work in different m-states
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
04-08-2012 09:39 AM
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!
Re: hello, i am trying to get scripts to work in different m-states
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
04-08-2012 09:43 AM
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
Re: hello, i am trying to get scripts to work in different m-states
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
04-08-2012 09:54 AM
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!
Re: hello, i am trying to get scripts to work in different m-states
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
04-08-2012 10:32 AM - edited 04-08-2012 10:33 AM
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.)
Re: hello, i am trying to get scripts to work in different m-states
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
04-08-2012 10:35 AM
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.
Re: hello, i am trying to get scripts to work in different m-states
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
04-08-2012 10:56 AM
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?
Re: hello, i am trying to get scripts to work in different m-states
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
04-08-2012 11:00 AM - edited 04-08-2012 11:00 AM
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).
Re: hello, i am trying to get scripts to work in different m-states
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
04-08-2012 11:04 AM
, oh wow, lol, how did i miss that thanks again bystander!
