View Full Version : Script to temporary switch M-mode with G-key
Siddhagod
09-22-2009, 08:29 AM
I'm looking for a script where I can press a G-key (say "G15" which is by my pinkie) to swap the gameboard from M1 to M2 and then return to M1 when I release the G-key.
Anyone with skillz?
Siddhagod
09-22-2009, 09:24 AM
-- Lets G15 temporary shift to M2 and G23 to M3
-- Note: Set G15 and G23 to "script" in M1 and M2/M3
function OnEvent(event, arg, family)
if ( family == "lhc" ) then
if ( event == "G_PRESSED" ) then
if ( arg == 15 ) then
SetMKeyState( 2, family );
elseif ( arg == 9 ) then
SetMKeyState( 3, family );
end
elseif ( event == "G_RELEASED" ) then
if ( arg == 15 ) then
SetMKeyState( 1, family );
elseif ( arg == 9 ) then
SetMKeyState( 1, family );
end
end
end
end
gadgetfl
10-28-2009, 06:38 AM
Thank You
This worked perfect for me
Mr.Edyd
10-30-2009, 06:13 AM
how do u use the script?
White--Hawk
10-31-2009, 02:03 AM
Neat. :)
I hope you don't mind, Siddhagod, but I whittled your script a little. It should still do the same thing, but work on either family of device (you set it to 'left-hand controller' :S ), changing only the M key state of the device used.
Mr.Edyd - you open your Key Profiler (it should be in your system tray) and go to the menu item 'Edit', then select 'Script Editor'. Paste Siddhagod's script into the editor, replacing any text you find. Go to 'Save' in the editor's 'File' menu, or press Ctrl+S. Close the script editor and click on the relevant G keys in the key profiler, selecting 'Assign Script' for each.
function OnEvent(event, arg, family)
if event == "G_PRESSED" then
if arg == 15 then SetMKeyState(2, family)
elseif arg == 9 then SetMKeyState(3, family)
end
elseif event == "G_RELEASED" then
if arg == 15 then SetMKeyState(1, family)
elseif arg == 9 then SetMKeyState(1, family)
end
end
end
Mr.Edyd
11-02-2009, 10:11 AM
Ok TY so much and btw my name is mr.eddy but I accidentally typed in mr.edyd lol thanks again :D
pilly
02-25-2010, 09:27 PM
Hiya,is it possible to insert a second function at the same moment M1 switches to M2?
Would like to achieve that when going to M2 it also uses Shift+2 (in-game keyb to go to second set quickbars) and when going back to M1 it uses Shift+1 (keybind for first set of quickbars)
thx in advance
White--Hawk
02-25-2010, 10:14 PM
This should do it:
function OnEvent(event, arg, family)
if event == "G_PRESSED" then
if arg == 15 then SetMKeyState(2, family)
PressKey("lshift"); PressAndReleaseKey("2"); ReleaseKey("lshift")
elseif arg == 9 then SetMKeyState(3, family)
end
elseif event == "G_RELEASED" then
if arg == 15 then SetMKeyState(1, family)
PressKey("lshift"); PressAndReleaseKey("1"); ReleaseKey("lshift")
elseif arg == 9 then SetMKeyState(1, family)
PressKey("lshift"); PressAndReleaseKey("1"); ReleaseKey("lshift")
end
end
end
...but let me know.
pilly
02-27-2010, 12:06 PM
thx for the fast reply,will try the script asap and let you know
White--Hawk
02-27-2010, 07:02 PM
I just spotted a little problem with the script - try that one instead. Sorry about that.
pilly
02-28-2010, 03:46 PM
Well when I tried it in profileviewer it worked fine but once in-game it didnt work.
Then I changed it to this
function OnEvent(event, arg, family)
if event == "G_PRESSED" then
if arg == 15 then SetMKeyState(2, family)
PressKey("lshift"); PressAndReleaseKey("2")
elseif arg == 9 then SetMKeyState(3, family)
end
elseif event == "G_RELEASED" then
if arg == 15 then SetMKeyState(1, family)
PressKey("lshift"); PressAndReleaseKey("1")
elseif arg == 9 then SetMKeyState(1, family)
PressKey("lshift"); PressAndReleaseKey("1"); ReleaseKey("lshift")
end
end
end
and it worked like a charm.
So thank you verry much for your help,this script makes it a lot more fun ingame for me
White--Hawk
02-28-2010, 05:31 PM
That's weird. Funny that should work - doesn't it leave the shift key stuck on? :S
Perhaps it was because I didn't include any pauses between keys. Maybe a little sleep before releasing the shift key would correct it. If you get a chance to try it, please do let me know if this also works:
function OnEvent(event, arg, family)
if event == "G_PRESSED" then
if arg == 15 then SetMKeyState(2, family)
PressKey("lshift"); PressAndReleaseKey("2"); Sleep(100); ReleaseKey("lshift")
elseif arg == 9 then SetMKeyState(3, family)
end
elseif event == "G_RELEASED" then
if arg == 15 then SetMKeyState(1, family)
PressKey("lshift"); PressAndReleaseKey("1"); Sleep(100); ReleaseKey("lshift")
elseif arg == 9 then SetMKeyState(1, family)
PressKey("lshift"); PressAndReleaseKey("1"); Sleep(100); ReleaseKey("lshift")
end
end
end
pilly
03-01-2010, 05:04 PM
My bad , posted the wrong 1 it seems but I tested the one you posted with the sleep added and it works perfect,thx again.
vBulletin® v3.8.3, Copyright ©2000-2010, Jelsoft Enterprises Ltd.