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! ;)
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! ;)