PDA

View Full Version : G19 & G13 Backlight Colour Cycle Script


White--Hawk
09-23-2009, 07:20 PM
UPDATE: 29/12/09 - Added feature for users of both a G19 and a G13 (colour un-sync)!
UPDATE: 16/12/09 - Added bi-colour fades; R<>G, G<>B, or B<>R.
UPDATE: 29/10/09 - Completely re-wrote sleep/control routine, tidied some more.
UPDATE: 27/10/09 - Tweaked rate control/slider, removed redundant stuff.
UPDATE: 25/10/09 - Even shorter script, edited script comments.
UPDATE: 23/10/09 - Tidier, commented, and smoother speed indicator.

|||||||||||||||||||||||||||||||||||||||||||||||||| |||||||||||||||||||||||||||||||||||||
Download the script >>>here (http://rapidshare.com/files/327291480/Cycler_v3_1.lua)<<<.
Or simply copy all the text from the code box below into the script editor.
|||||||||||||||||||||||||||||||||||||||||||||||||| |||||||||||||||||||||||||||||||||||||

This script allows you to loop through R>G>B (forwards or
backwards) or just between two colours (R&G, G&B, B&R)
at a user-selectable speed, or to manually set a custom
colour without accessing the profiler.

At the very least, it gives a nice demo of the backlight
and opens up a range of custom colours with just a few
key presses.

When changing rate, an indicator is displayed on the LCD.

To install the script, open the Logitech Keyboard
Profiler, select the correct profile from the drop-down menu
(eg- 'Default Configuration' to operate the backlight on
the desktop, or your favorite game, or both), and go to
the menu, Edit > Script Editor.

Either use File > Import OR replace the text in the editor
with the script in the code box below. Go to File > Save.

|||||||||||||||||||||||||||||||||||||||||||||||||

Controls:
R-Ctrl +
-M1------------------------Cycle R<>G
-M2------------------------Cycle G<>B
-M3------------------------Cycle B<>R
R-Shift +
-M1------------------------Cycle RGB
-M2------------------------Cycle RBG
-M3------------------------Colour Picker
While cycling:
R-Shift +
-L-Shift--------------------Faster
-L-Ctrl---------------------Slower
R-Ctrl +
-L-Shift--------------------Unsync G19 and G13
While Picking:
R-Shift/R-Ctrl (brighter/darker) +
-L-Shift--------------------Red
-L-Ctrl---------------------Green
-L-Alt----------------------Blue
Any other M-key----------Keep new colour!*
L-Alt + R-Alt--------------Keep new colour!*


*last selected or cycled colour is retained until a further M-key press,
so lots of new colours are accessible without opening the profiler, either
by manually mixing a custom colour, or by halting the colour cycler
when the desired colour appears. The colour will be retained until a
change of M mode.

The dual Alt press should abort the script even if the profiler freezes.

|||||||||||||||||||||||||||||||||||||||||||||||||

-- G19 Backlight Colour-Cycling Script (v3.1)
-- ------------------------------------------
-- Cobbled together and imaginatively titled by
-- White--Hawk (GH)

-- Thanks to everyone.


---------------
----------|| CONTROLS: ||--------------
-- --------------- --
-- --
-- --
-- R-Ctrl + --
-- M1 - Cycle R<>G --
-- M2 - Cycle G<>B --
-- M3 - Cycle B<>R --
-- --
-- R-Shift + --
-- M1 - Cycle RGB --
-- M2 - Cycle RBG --
-- M3 - Colour Picker --
-- --
-- While Cycling: --
-- R-Shift + --
-- L-Shift - Faster --
-- L-Ctrl - Slower --
-- --
-- L-Shift + --
-- R-Ctrl - Toggle LHC mode --
-- (G19/G13 sync) --
-- --
-- While Picking: --
-- R-Shift/R-Ctrl (brighter/darker) + --
-- L-Shift - Red --
-- L-Ctrl - Green --
-- L-Alt - Blue --
-- --
-- Press any other MKey to stop --
-- cycling or picking, and keep --
-- selected colour. --
-- --
-- --
-----------------------------------------

-- **Cycle rate:
-- **(default = 150; red-to-red in ~23secs)
-- **(always set lower than mrate)
rate = 150

-- **Minimum delay:
-- **(default = 600; red-to-red in ~1.5mins)
-- **(higher is slower)
mrate = 600

-- **Static (RGB) Colour:
-- **(default = 140, 255, 150; white on my G19)
R, G, B = 140, 255, 150

function OnEvent(event,arg)

-- Cycle or set custom colour:
if (event=="M_PRESSED") and IsModifierPressed("rshift") then

-- Cycle RGB:
if arg==1 then Cycle(0, 5, 0, 1, arg)

-- Cycle RBG:
elseif arg==2 then Cycle(255, -5, 2, -1, arg)

else

-- Set custom static colour. Right Shift/Ctrl(+/-) plus Left-Shift/Ctrl/Alt(R/G/B).
run=1
while run~=null do
if IsModifierPressed("rshift") then
if IsModifierPressed("lshift") then R=R+.1
if R>255 then R=255; end
end
if IsModifierPressed("lctrl") then G=G+.1
if G>255 then G=255; end
end
if IsModifierPressed("lalt") then B=B+.1
if B>255 then B=255; end
end
elseif IsModifierPressed("rctrl") then
if IsModifierPressed("lshift") then R=R-.1
if R<0 then R=0; end
end
if IsModifierPressed("lctrl") then G=G-.1
if G<0 then G=0; end
end
if IsModifierPressed("lalt") then B=B-.1
if B<0 then B=0; end
end
end
SetBacklightColor(math.floor(R),math.floor(G),math .floor(B))
if (IsModifierPressed("lalt") and IsModifierPressed("ralt")) or GetMKeyState()~=3 then run=null; break; end
end

-- All done? Re-set new static colour after profiler applies default one.
Sleep(350)
SetBacklightColor(math.floor(R),math.floor(G),math .floor(B))
end

end

-- Reciprocating fade; Red <> Green or Green <> Blue or Blue <> Red:
if (event=="M_PRESSED") and IsModifierPressed("rctrl") then Fade(arg); end

end

function Fade(ks)
fs=0; fj=5; fd=0; run=1
while run~=null do

-- Ramp colour value 0-255 (and back), or full-off to full-on.
for col = fs, 255-fs, fj do

-- Call for delay before next colour change.
Dlay(ks)

if ks==1 then SetBacklightColor(255-col,col,0,"kb"); if lmode~="1" then SetBacklightColor(255-col,col,0,"lhc") else SetBacklightColor(col,255-col,0,"lhc") end
elseif ks==2 then SetBacklightColor(0,255-col,col,"kb"); if lmode~="1" then SetBacklightColor(0,255-col,col,"lhc") else SetBacklightColor(0,col,255-col,"lhc") end
elseif ks==3 then SetBacklightColor(col,0,255-col,"kb"); if lmode~="1" then SetBacklightColor(col,0,255-col,"lhc") else SetBacklightColor(255-col,0,col,"lhc") end
end

-- Skip out of ramps...
if run==null then break; end

end

-- Change direction...
if fd==0 then fd=1; fs=255; fj=-5
else fd=0; fs=0; fj=5

-- Skip out of reciprocating fade...
if run==null then break; end
end
end
end

function Cycle(cs, cj, rs, rj, ks)
run=1
while run~=null do

-- Loop through each of R, G, and B.
for rgb = rs, 2-rs, rj do

-- Ramp colour value 0-255, or full-off to full-on.
for col = cs, 255-cs, cj do

-- Call for delay before next colour change.
Dlay(ks)

if rgb==0 then SetBacklightColor(255-col,col,0,"kb"); if lmode~="1" then SetBacklightColor(255-col,col,0,"lhc") else SetBacklightColor(col,0,255-col,"lhc") end
elseif rgb==1 then SetBacklightColor(0,255-col,col,"kb"); if lmode~="1" then SetBacklightColor(0,255-col,col,"lhc") else SetBacklightColor(255-col,col,0,"lhc") end
elseif rgb==2 then SetBacklightColor(col,0,255-col,"kb"); if lmode~="1" then SetBacklightColor(col,0,255-col,"lhc") else SetBacklightColor(0,255-col,col,"lhc") end
end

if run==null then break; end
end

-- Skip out of RGB loops...
if run==null then break; end
end

end
end

function Dlay(ks)
-- Throttle controls during sleep.
for z = 1, rate, 1 do

-- Faster...
if IsModifierPressed("lshift") and IsModifierPressed("rshift") then rate=(rate-(mrate/6000))
if rate<2 then rate=2
if limit~=0 then limit=0; OutputLCDMessage("\n"..(string.rep(" ",37)).."MAXIMUM SPEED!!!", 3000); end
end
-- Increments for display...
dup=math.floor((60/mrate)*rate)
if nup~=dup then Disp(); end

-- Slower...
elseif IsModifierPressed("lctrl") and IsModifierPressed("rshift") then rate=(rate+(mrate/6000))
if rate>mrate then rate=mrate; end
-- Increments for display...
dup=math.floor((60/mrate)*rate)
if nup~=dup or limit~=1 then Disp(); limit=1; end
end

-- ~333ms control delay...
if tt==null then tt=0 elseif tt<334 then tt=tt+1 end
if tt>333 and IsModifierPressed("rctrl") and IsModifierPressed("lshift") then tt=0
if lmode~="1" then lmode="1" else lmode="0" end
end

-- Don't wait for delay if another M-key is pressed.
if GetMKeyState()~=ks or (IsModifierPressed("lalt") and IsModifierPressed("ralt")) then run=null; break; end
Sleep(1)

end
end

function Disp()
-- Draw an incremental slider to G19 LCD output. It grabs/drops focus rapidly. :S
text="\n\n\n\n\n\n <["..(string.rep("||",60-dup)).."|||"..(string.rep("-",dup)).."]>"
ClearLCD(); OutputLCDMessage(text, 2000)
nup=dup
end
_______________

Issues:

- The scripting display applet doesn't like a lot of data, so it tends to sulk
if the cycle rate is constantly altered. It works again after a while. This may be
because spamming the ClearLCD() & OutputLCDMessage commands causes
the script display to take focus rapidly, triggering a panel manager cool-off.
It's no big deal, but means the speed indicator won't always show.

- The RGB value 255, 255, 255 does not look white! On my keyboard,
despite the white looking good enough when set via the profiler swatches, it
looks light-purple/pink when set via the script, or by the profiler's RGB picker.
I think this is just a calibration 'feature', as matching real white requires
values nearer 140, 255, 150. I can confirm this by setting the colour to white
with the profiler colour swatches and opening the profiler's RGB picker; it will
show all values set as 255. Now hit OK without changing a thing and watch the
keyboard back-light closely.

- Changing profiles (automatically, for instance, when loading a game or an
application) can cause the script to lock out the M-keys. Better stop cycling
before loading another profile. You can do this by changing M state (press one
of the other M keys) or by pressing both Alt keys together.

_______________

Disclaimer:

While every effort has been made to get this product to you in a satisfactory condition, no guarantees, warranties, liabilities,
or STDs are accepted, implied, or otherwise conveyed in the granting of permission to use this product freely.

This product contains no artificial flavours. It may contain nuts.

Seriously, though; the user of any script accepts responsibility for any adverse conditions or damages caused by the use of it,
though such a scenario is highly unlikely. Use at your own risk!
_______________

Thanks to CRutgerXryzis and Canyon (among others) for the idea. Cheers! ;)

osten87
09-24-2009, 03:02 PM
Wicked!
I got is to work First time I tried!
THX M8.

Although I encounter a weird bug when I was writing with the script turned on.
The colours started to switch faster and faster the more I pressed the buttons until it almost became psychedelic. :S
When I stopped and restarted the script it was all back to normal.

White--Hawk
09-24-2009, 08:14 PM
LOL! That's not a bug - you were hitting the left shift key. =D

Left Shift increases the cycle rate, and Left Ctrl decreases the cycle rate. Maximum rate is a shade shift every two milliseconds, which is just psychadelic enough (1ms is almost just flickering white). Minimum is every 250 milliseconds (meaning a good few seconds between colour changes).

I can see where that left shift key could be a little annoying though, so I shall move these controls to the Left/Right Ctrl keys. ;)

EDIT: Post updated with new script!

Interceptor One
09-25-2009, 01:16 AM
Since the right Control Key is used to access special characters,
you may wanna re-think that too.
I'd suggest a key combo, or even better, a user-selectable key combo.

White--Hawk
09-25-2009, 05:28 AM
Thanks Interceptor - you are right, of course. I should have been in bed, asleep, so I was being lazy.

I've updated it to require right-shift + left-shift/left-ctrl for speed adjustment. This doesn't seem like a key combination that's likely to be used elsewhere. As for making them user selectable - I'm afraid that's beyond the scope of the script as it stands (I've had three days to learn this much).

The two lines after the comment "check for control keys" can be edited to check for other keys. I stuck with modifiers (shift/ctrl) as holding these won't result in repeated characters in whatever application you might be using at the time.

Acceptable arguments for IsModifierPressed include "lalt", "ralt", "lshift", "rshift", "lctrl", and "rctrl". Feel free to tweak to taste. :)

I am at the office, so I don't have access to the hardware. Could anyone let me know if this is working as it should? I'll check it when I get home otherwise.

I'm thinking of adding R-Shift + M3 to manually cycle through a range of colours (*press* red, *press* orange, *press* yellow, etc)... or maybe ctrl + M1/M2/M3 to shift each colour in the spectrum for manually setting a static colour.

Ideas welcome. Just don't expect a lot from a three-day-old scripter! ;)

Interceptor One
09-25-2009, 03:42 PM
I don't as yet own a G19 (the disadvantages of having been made redundant after 13 years at my old workplace),
so I can't help with testing anything.
But it seemed logical to me to use a combo that wouldn't normally be hit during normal keyboard use.

detiere
09-25-2009, 06:00 PM
Hi! I just registered and have had my new G19 all of 2 days now. Tried the script and it works hella well. One question though. Is the constant changing of the backlight going to shorten the life expectancy of the keyboard/backlight in any way?

White--Hawk
09-25-2009, 07:31 PM
@ Interceptor One; sorry to hear it. Hard times all round, methinks, and I count myself lucky that I get by, despite things being uncertain at the company for which I work... but more so for the generosity of the missus and a very, very early Christmas present.

As for the obvious logic, I can only say that a hard week and a sleepless night had somewhat dulled my mental faculties. I'm still grateful for the idea. ;)

@ Detiere; I think it would be imprudent of me to dismiss your question out of hand, and you've really made me think hard about it now, so perhaps I should include some sort of disclaimer. lol

I can tell you that LEDs don't just fail, but gradually fade with time. Dimming an LED, even repeatedly, could conceivably extend its lifespan by keeping it below its peak output for a greater portion of time, and reducing the rate of degradation.

On the other hand, as the cross-fade is entirely linear so that overall output is essentially always at peak, the action of this script could be considered a form of wear-levelling. Rather than having the most used LEDs degrading at a normal rate, all LEDs could be experiencing up to two thirds less wear.

When LED backlights fail catastrophically, it is likely as a result of electronic failure. On this point I can make no guesses, but I doubt that this script goes beyond the design limits of the provided hardware.

I have read a few posts about dead LEDs (electronic failure) in relatively new keyboards which highlights a potential for manufacturing faults. I honestly don't believe that this simple script could be held accountable for coincidental failure of Logitech's products.

I didn't really intend this script to be used persistently to be perfectly honest, hence the lack of forethought in the previous control scheme, but I have been using it constantly since I first typed it up, so it's up to you to decide if you can trust my judgement. ;)

Sorry for the waffle. Hehe.

detiere
09-26-2009, 12:31 AM
@White--Hawk: Thank you for the well thought out response. To be perfectly honest, I'm not entirely worried about it, it was more of a general thought, as I was watching the awesome that was my ever-changing keyboard color, that it might be putting extra wear on it. This is overall an awesome script that will be sure to please any of my curious friends that just come by wondering what that keyboard is that will let you watch youtube videos on it. :)

Keep up the great work!

Chong McBong
10-12-2009, 06:23 PM
very nice script :)

White--Hawk
10-27-2009, 08:54 AM
Another update:

Rate, minimum rate, and static colour defaults can now be tweaked by the user (see script comments after "CONTROLS" section). Changed default minimum rate to 600 (was 300).

Made the rate indicator a solid bar now, and it includes a "MAXIMUM SPEED!!!" notice.

Stuck the display routine back into its own function - just better, methinks (fewer lines of script, too).

Tweaked the rate controls to be more responsive at the slow end, and finer at the fast end.

Removed elseifs from the colour-picker controls so that key combos aren't exclusive any more - R, G, & B can all be raised/lowered at the same time.

Removed even more redundant crap - had some variables that weren't needed, or that were left over from previous edits.

Mostly cosmetic...

Interceptor One
10-27-2009, 12:58 PM
Erm,
can you program it so that it turns one of my my G15v1's or my v2 into a G19?
http://www.interceptor-one.com/Smileys/Innocent_Whistling.gif
http://www.interceptor-one.com/Smileys/Weights.gif

White--Hawk
10-27-2009, 01:31 PM
I believe this is possible using the ConvertToG19() function, but I keep getting a syntax error. :(
_____

Updated:

Aha! So that's how that works..

Variables passed more elegantly to cycle functions; even more redundant stuff removed; COMPLETELY re-wrote the control/sleep routine so that the slider is MUCH smoother, and control is consistently responsive regardless of the cycle rate.

StaticMatt
10-29-2009, 07:22 AM
Thanks so much for this script! This is exactly what I was hoping for when I bought this keyboard.

White--Hawk
10-29-2009, 07:31 AM
:cool:

I'm right there with you. As soon as I realised this could be done, I wondered why it hadn't been!

Wellll... it had been, just not in the way I wanted. ;)

StaticMatt
10-29-2009, 07:34 AM
Agreed. I found a script that faded the colors whenever you selected a different color, but not one that continuously faded (until I found yours), which is what I wanted. Thanks again.

T-T
12-04-2009, 08:06 PM
thx, works like a charm,
keep up the good work ! :)

White--Hawk
12-28-2009, 08:27 PM
Added feature: hold l-shift and press r-ctrl to change the left-hand controller's cycle mode (reversed in bi-colour, shifted in spectrum cycle).

Chong McBong
12-29-2009, 12:46 AM
woohoo, now i just my G13 to hurry up and arrive..

i ordered it on christmas day so it can't be much longer... :P

selcuQ.44
01-14-2010, 09:53 PM
hi people, well i have a problem.

i bought my g19 1 week ago , and now i saw this script. but i have a problem. i have downloaded the script and then i've imported in the script editor and then i've saved it. but when i press at CTRL+ M1 or another keys nothing happens. am i doing something wrong ? sry for my bad english ^^

White--Hawk
01-14-2010, 10:13 PM
1) Ensure that you have the most recent drivers installed from the Logitech site. This is important; the script uses functions that were not in the earlier drivers.

2) Open the profiler and select the profile you want it to work with (default profile is the profile running when no other profile is active, so I select this one to run the cycler when I'm not gaming). Open the script editor and import/save the script, then close the script editor.

3) Pay close heed to the controls: RIGHT-Ctrl or RIGHT-Shift are used to activate different functions (e.g- r-shift + M1/2 activates cycling). The controls are detailed in the script, and in the first post.

If you've done that precisely, then all should be well. :)

selcuQ.44
01-14-2010, 10:28 PM
co0l it works =) thank you. i had another profile. i think that was the reason.

Snacko
02-04-2010, 12:26 PM
Is there another place to download this script? RapidShare has told me the last two days "Error: Currently a lot of users are downloading files."

White--Hawk
02-04-2010, 01:05 PM
The script is in the first post. ;)

Select all the text in the code box. It has scroll bars, so drag-select from top to bottom.

Open the script editor from within the keyboard profiler. Make sure the desired profile is selected (such as 'default profile').

Replace anything in the editor with the copied text and save it.

Close the script editor and keyboard profiler.

Enjoy! :)
_____

I will see where else I can upload the script over the next couple of days. Rapidshare doesn't seem particularly reliable lately.

JackRyder
02-11-2010, 08:59 PM
I like the script but is it possible to change M1, M2, M3 to F1, F2, F3? The same key combos but replace M-keys with F-keys.

White--Hawk
02-12-2010, 03:03 AM
Nope.

The scripting engine cannot see the F keys.

Raziel
02-12-2010, 05:00 AM
For SOME reason I can't get it to work with my G13... I pasted the script in the script editor in my default configuration and tried hitting Right shift and mouse buttons, right control and mouse buttons, and nothing happens... am I doing something wrong?
EDIT: Oh God am I dumb. I thought the M keys were mouse keys, when they're actually the keys used to change the profile...thing...
Works great now :D

White--Hawk
02-12-2010, 05:45 AM
LMAO!

I can see why that might have been confusing... maybe... ;)

KILLER_K
02-25-2010, 10:51 PM
How hard would it be to make it auto scroll. Like just keep changing colors, etc by itself? Would be nice just to have something like a demo mod that just constantly changes the colors.

White--Hawk
02-26-2010, 04:36 AM
How hard would it be to make it auto scroll. Like just keep changing colors, etc by itself?

Um... I take it either that you are joking, or that this does something other than precisely that on your machine?

What do you think this does? Maybe I'm completely crazy, but you've described this script exactly.

o.O

KILLER_K
02-26-2010, 02:06 PM
You're completely crazy i found a script below in the other thread. But it is just stuck to 3 colors. Thanks anyway though.

As i wanted something that cycled through all the colors automatically. Yours you have to use two key combos to make it work. Perhaps i worded it wrong though.

White--Hawk
02-26-2010, 02:29 PM
The script in the first post of this thread is the topic of this thread. It cycles through every possible hue at maximum luminance. That means red, orange, yellow, green, cyan, blue, purple, and every shade in between. What magical colours do you wish to see? Perhaps I could simulate colours beyond the visible spectrum by including a fade to black??

While I admit to being unhinged, I'm not crazy enough to accept your stipulation that this script only cycles through three colours.

Perhaps you could better explain what you require? Are you asking for different luminance values - darker and brighter shades of the spectrum?

The keys to activate cycling are just that - activation keys. This script has several different 'modes' - bicolour/linear fading (three modes), full spectrum forward and reverse, and contra-cycling of G13 and G19 together. It also includes an 'on-the-fly' custom colour creator.
_____

If you want to have this activate as soon as you boot, add the following just after the line "function OnEvent(event, arg)", and make sure the script is part of the 'default profile':
if event=="PROFILE_ACTIVATED" then arg=1; Cycle(0, 5, 0, 1, arg); endThis will activate the basic cycle as soon as the profile is loaded. Can't add any more colours right now - not until someone invents 'em - but I'm planning on re-writing the major part of the script to incorporate an HSL (rather than pure RGB) element that will open upon more shades (brighter/darker) and possible modes. ;)

DON'T FORGET to deactivate the cycler before changing profiles!! If you forget, and the profiler freezes (the G/M keys stop responding), press both Alt keys together - this should break the cycler under these circumstances.

KILLER_K
02-26-2010, 06:44 PM
I shall try it again perhaps i goofed on my end. As in "crazy" it wasn't a personal attack as we are all crazy in one way or the other.

So don't take me serious, i was just messing with you.

White--Hawk
02-27-2010, 05:10 AM
No worries, fella'. Don't blame yourself for my apparent gruffness - I'm always a bit of a misery at this time of year. Apple oggies for being contrary. :)

I've included a line to add to the script (see previous post edit) that will (or should) activate the basic cycle upon profile activation, the same as pressing shift+M1 from the get-go. I will knock up a small, quick script that you can use as an alternative if you like, but it'll have to wait until later or tomorrow.

joshr915
02-28-2010, 03:53 PM
white hawk: tried your auto-start code line but it didnt seem to work for me.

inserted under - function OnEvent(event, arg) (didnt see one with "family" in it...?)

White--Hawk
02-28-2010, 05:24 PM
You're right - I didn't include the 'family' variable in my script. Well spotted. *slaps forehead* D'oh!

Add the following line after function OnEvent(event,arg):
if event=="PROFILE_ACTIVATED" then arg=1; Cycle(0, 5, 0, 1, arg); end

I've tested this, and it works.

joshr915
02-28-2010, 07:18 PM
ok, will try again and report status next time i restart my system.

White--Hawk
03-01-2010, 02:49 AM
As soon as you save the script with that line added, the profile will be reactivated, and the cycler will start. From there on, the script will begin executing on every startup. =D

Just remember the 'kill switch' - press both Alt keys together if another profile tries to load (ie- automatically, when an associated program or game is executed), as looping scripts tend to bork the profiler when they are forced to abort.

Enjoy! :)

joshr915
03-01-2010, 04:03 PM
i swear i pasted the code in the EXACT same place last time, but whatever, its working now X_X thanks

White--Hawk
03-01-2010, 04:26 PM
Joshr: I removed brackets from the event check - shouldn't have caused a problem, but it seems to work now. Let me know if I can add anything else.

Snacko: I guess you found the script in the code box in the first post? ;) Hope you got it working okay.

JackRyder
03-07-2010, 10:58 PM
I want it to fade from red to blue on startup so I tried adding

if event=="PROFILE_ACTIVATED" then Fade(1); end

after function OnEvent(event,arg):

but it doesn't work when I restart the profiler.

White--Hawk
03-08-2010, 08:45 AM
That looks like it should work, so long as it stands alone and isn't stuck in the middle of another function other than OnEvent(). I haven't got any way of testing it right now (I'll look at it again later, when I'm back in front of my rig), but perhaps you could try the following line instead:

if event=="PROFILE_ACTIVATED" then a=1; Fade(a); end

It's a shot in the dark right now, but I'll have a proper go at it later.

Also, try putting event=="PROFILE_ACTIVATED" inside brackets - it should work without them, but... :/

smokezem
03-10-2010, 06:36 PM
hey guys ive tried it like 10 times now i run on windows 7 i fild int his Scrypt

and nothign hapdn even added scypt to a gkey

some1 have older Cycle i might mqay use thanks all

White--Hawk
03-10-2010, 08:26 PM
@ Smokezem: Follow these instructions TO THE LETTER:

Open the Key Profiler.

Select "default profile".

Go to Edit > Script Editor.

Delete all text in the editor.

EITHER:
-Paste the script from the code box into the script Editor.
OR
-Go to Script > Import and select the downloaded script.

Go to Script > Save.

Close the Script Editor and Key Profiler.

Hold the RIGHT shift key on your keyboard, then press M1 on your G19 or G13.
_____

If the keyboard does not immediately turn red and start cycling smoothly, then there is a problem beyond the scope of any script, and an older script won't help. You need to make sure you have the latest drivers, and of course, a G19 or G13 (or even a G110).

If the keyboard does turn red and start cycling, give yourself a pat on the back and enjoy the colour show, then re-read the instructions and controls in the first post of the thread. Once you've done that, read them again.
____________________

@ JackRyder: I forgot about testing that line, sorry. I'll get onto it by the weekend. I think it's about time I updated the script - perhaps I should add the option of automatically activating the colour cycler (maybe have an AUTORUN variable with a value that determines which feature should start automatically).

In the mean time - did you have any luck getting that line to work?;)

White--Hawk
03-11-2010, 06:23 PM
JackRyder, I inserted the following line immediately after the line that reads "function OnEvent(event, arg, family), and it appears to work well:
if event=="PROFILE_ACTIVATED" then Fade(3); end
Fade(3) is red<>blue. Let me know if that works for you. :)

JackRyder
03-13-2010, 11:46 PM
It still doesn't work.

I forgot to say that I copied the code for red<>blue to 1 and 2 as well so I can use ctrl+M1 to start the fading. It doesn't work for any value for fade.

I don't think it's recognizing the PROFILER_ACTIVATED event.

micha
03-14-2010, 04:57 AM
I don't think it's recognizing the PROFILER_ACTIVATED event.

I assume you're aware that it must read PROFILE_ACTIVATED, not PROFILE"R"_ACTIVATED ? Just in case...

White--Hawk
03-14-2010, 09:42 AM
if event=="PROFILE_ACTIVATED" then Fade(3); end:)This works for me. There's no reason it shouldn't for you. Please be sure to check your typing carefully, or just copy and paste the line from the code box above to ensure it is correct.

Here's a better idea! :)

The following script will automatically start fading between red and blue, can be stopped by pressing both Alt keys, and restarted by holding either shift and pressing an M key. You can change the speed by holding right-shift, then either pressing left-shift to go faster, or left-ctrl to go slower:

--Default speed is rate, slowest speed allowed is mrate:
rate, mrate = 100, 600

function OnEvent(event, arg, family)
if event == "PROFILE_ACTIVATED" or (event=="M_PRESSED" and (IsModifierPressed("lshift") or IsModifierPressed("rshift"))) then
fs=0; fj=5; fd=0; run=1
while run~=null do

-- Ramp colour value 0-255 (and back), or full-off to full-on.
for col = fs, 255-fs, fj do
-- Call for delay before next colour change.
Dlay()
-- Set Backlight
SetBacklightColor(col,0,255-col)
if run==null then break; end
end

-- Change direction...
if fd==0 then fd=1; fs=255; fj=-5
else fd=0; fs=0; fj=5
end
end
end

end

function Dlay()
-- Throttle controls during sleep.
for z = 1, rate, 1 do
-- Faster...
if IsModifierPressed("lshift") and IsModifierPressed("rshift") then rate=(rate-(mrate/6000))
if rate<2 then rate=2; end
-- Slower...
elseif IsModifierPressed("lctrl") and IsModifierPressed("rshift") then rate=(rate+(mrate/6000))
if rate>mrate then rate=mrate; end
end

-- Don't wait for delay if another M-key is pressed.
if (IsModifierPressed("lalt") and IsModifierPressed("ralt")) then run=null; break; end
Sleep(1)
end
endJust replace everything in the script editor with the script above, and let me know if it's good for you. ;)

JackRyder
03-14-2010, 10:34 PM
Actually it does work. Looks like I was using the Mass Effect profile (installed the game but haven't really played it) the whole time and I just pasted your code in that profile. I switched it to the default profile now and it works.

Thanks.

White--Hawk
04-02-2010, 06:11 PM
Hehe - in the last 24hrs, the downloads for the 3.1 script hit 1000. Thanks all.

I can't imagine how many people have copy/pasted out of the thousands who have visited. It goes to show how increasingly popular the G-series keyboards are - most downloading appeared to occur just after Christmas '09! =D

Musje
04-02-2010, 06:31 PM
I have never tried any scripting at all on the G19 (or G15), is there any way to make the RGB cycle run constantly? (even if I change M mode)
Would be even better if it autostarts (and I guess it would continue when you switch profile then, if I pasted the script there also?)

edit
if event=="PROFILE_ACTIVATED" then Cycle(0, 5, 0, 1, 1); end seems to start the cycle on starting the profile. Now just trying to find the lines where it stopd on pressing an M key :P

edit2
that only works when in M1...
It only resets to red when in M2 or M3

edit3
found the line responsible for the stopping when you press an M key and now it doesn't stop anymore on pressing an M key.
It also starts when in M2 or M3 now :)
Just a little flash of the lights in the color setting of the profiler, but I guess that can't be helped.
I put the default colors to black, so I just get a split second of no backlighting when I choose another M group.

There don't seem to be any problems when switching profiles, it just restarts the cycle on changing.

White--Hawk
04-02-2010, 08:07 PM
Good work. :)

Yup - there appears to be nothing that can be done with the little 'flash' when the profiler applies the default M-key colour.

I think I might spend a bit of time this weekend creating a new script. This one developed as I went along, so I think it is a lot clunkier than it needs to be. I might start from scratch and build it all around a central function.

I really want to put a random element in and maybe even take advantage of RGB<>HSL conversions to make everything more dynamic (transitions between modes could be much smoother then).

Garyth
04-03-2010, 07:27 AM
don't forget the morse code function - put a line of text in the function. It reads the line, converts it and flashes it out. :D

micha
04-03-2010, 07:39 AM
Yup! Agenda says that movie titles will be morsed, (from V 27.3445 :D.)

EDIT: OOPS, wrong thread, sorry ;-)

White--Hawk
04-27-2010, 09:43 AM
That's just... brilliant! lol

You know, of course, I might just have to do that now.
_____

You know - I only just realised you weren't being funny, Micha! lol

I should have realised - I don't have a version 27.x yet! :P

micha
04-27-2010, 10:10 AM
Oh, the time for v. 27 will sure come ;-)

That post was because I took the previous one for a reply to another open thread. Looks as if my multitasking abilities were not that good, eh? :)

BAKER12
04-28-2010, 08:34 AM
I dont now how to do it like what i press and when and how im new to the whole scripting thing please i need help.

White--Hawk
04-28-2010, 08:36 AM
If the instructions in the first post aren't easy enough, try following the ones in this post (http://www.g15forums.com/showpost.php?p=43862&postcount=44) instead.

BesTCooL
04-29-2010, 06:35 PM
very very nice script bravo

smokezem
05-15-2010, 05:51 PM
1) Ensure that you have the most recent drivers installed from the Logitech site. This is important; the script uses functions that were not in the earlier drivers.

2) Open the profiler and select the profile you want it to work with (default profile is the profile running when no other profile is active, so I select this one to run the cycler when I'm not gaming). Open the script editor and import/save the script, then close the script editor.

3) Pay close heed to the controls: RIGHT-Ctrl or RIGHT-Shift are used to activate different functions (e.g- r-shift + M1/2 activates cycling). The controls are detailed in the script, and in the first post.

If you've done that precisely, then all should be well. :)

thanks Color Sycle Works perfectly now :D

jupstejuho
08-03-2010, 10:12 AM
I can't get this to work on my G19. I imported the script to the script editor and tried assigning the sript to G1 but nothing happends, I can't see anything in the LCD regarding to this script, not even in the apps menu in the LCD.

What should I do to make this work?

White--Hawk
08-04-2010, 09:05 AM
Are you kidding? lol

Besides instructions in the original post, the post right before yours even includes a quote that repeats simpler instructions still and suggests paying attention to the controls.

Why are you assigning G1 to script? Where does it say to do that? :P

tric565
08-24-2010, 02:09 PM
Love this script.

Just wondering if there is a way I can edit the script to change to the pulsing red to blue or green to red to something like red and black so it looks as if the light is pulsing on and off.

White--Hawk
08-24-2010, 04:32 PM
There is indeed. :)

I have been keeping in touch with the forum via my Android for the last couple of months, but plan to spend some decent time on my PC quite soon. When I do, I plan to catch up on a number of requests, and to update some of my scripts.

Watch this space. :)

Wickad
09-02-2010, 05:21 AM
I didnt realise and i dont think many people did either? you have to select the profile from the keyboard itself., lol just realised, thanks for the script was what i was hoping for!!!

White--Hawk
09-02-2010, 05:28 AM
Well... aside from the instructions in the first post, perhaps you will find this post (http://www.g15forums.com/showpost.php?p=43862&postcount=44) a little more helpful? ;)

Aznboy1993
09-05-2010, 02:57 PM
thanks for this!