Özgürcan
80+ Silver
- Katılım
- 14 Temmuz 2020
- Mesajlar
- 4,153
- En İyi Cevap
- 1
Dahası
- Reaksiyon skoru
- 2,615
- İsim
- Özgürcan
arkadaslar mouse yazılımını acıyorum ss de gordugunuz gıbı varsıyaln yazan yere sag tıklayıp komut dosyası yazma yerıne tıklıyoruz bı pencere cıkıcak oraya assıga verdıgım yazının hepsını kopyalayıp oncekı pencereye yapıstırıyoruz ve kapatıyor be sıra sıra renk degısıyor yapamayanlara elımden geldıgınce yardımcı olmaya calısırım merak edıp arasıtırp buldum sızınlede paylasmak ıstedım.
kopyalayacagnız komut;
-- Code update by Bystander on 5/13/2012
DEVICE = "mouse" -- "kb" for keyboard, "lhc" for left handed controller, such as the G13
------------------------------------------------------------------------------------------------------------
POLL_DELAY = 0 -- Sleep time after each poll (beware of number below 16)
POLL_FAMILY = "kb" -- The device polling will take place on. Prefered to not be on macroed device.
------------------------------------------------------------------------------------------------------------
speed = POLL_DELAY -- this should alwasy be equal or larger than POLL_DELAY
inc = 1
lcd = OutputLCDMessage
function _onActivation(event, arg, family)
--
-- ADD ANY START UP ROUTINES HERE
--
ctDiscoColors = CoThread:new(discoColors)
ctDiscoColors:start()
Toggle = true
end
function _OnEvent(event, arg, family)
--
-- ADD EVENT FUNCTIONALITY HERE
--
if event == "G_PRESSED" and arg == 1 then
Toggle = not Toggle
if Toggle then
lcd("Fade resumed.", 3000)
else
lcd("Fade paused.", 3000)
end
end
if event == "G_PRESSED" and arg == 2 then
speed = speed-POLL_DELAY
if speed < POLL_DELAY then -- if speed is 0 or less, the program will not reliquish control
speed = POLL_DELAY
end
lcd(speed .. "ms between updates")
end
if event == "G_PRESSED" and arg == 3 then
speed = speed+POLL_DELAY
lcd(speed .. "ms between updates")
end
if event == "G_PRESSED" and arg == 4 then
inc = inc + 9
lcd(inc.." color increment(s)")
end
if event == "G_PRESSED" and arg == 5 then
if inc > 1 then
inc = inc - 9
end
lcd(inc.." color increment(s)")
end
if Toggle then
ctDiscoColors:run()
end
end
function discoColors(ct)
while true do
for i = 0, 255, inc do
SetBacklightColor(i,0,255,DEVICE)
-- OutputLogMessage("Red: %i, Green: %i, Blue: %i\n", i, 0, 255)
ct:sleep(speed)
end
-- now to red
for i = 255, 0, -inc do
SetBacklightColor(255,0,i,DEVICE)
-- OutputLogMessage("Red: %i, Green: %i, Blue: %i\n", 255, 0, i)
ct:sleep(speed)
end
-- now to green-red
for i = 0, 255, inc do
SetBacklightColor(255,i,0,DEVICE)
-- OutputLogMessage("Red: %i, Green: %i, Blue: %i\n", 255, i, 0)
ct:sleep(speed)
end
-- now to green
for i = 255, 0, -inc do
SetBacklightColor(i,255,0,DEVICE)
-- OutputLogMessage("Red: %i, Green: %i, Blue: %i\n", i, 255, 0)
ct:sleep(speed)
end
-- now to green-blue
for i = 0, 255, inc do
SetBacklightColor(0,255,i,DEVICE)
-- OutputLogMessage("Red: %i, Green: %i, Blue: %i\n", 0, 255, i)
ct:sleep(speed)
end
-- back to blue
for i = 255, 0, -inc do
SetBacklightColor(0,i,255,DEVICE)
-- OutputLogMessage("Red: %i, Green: %i, Blue: %i\n", 0, i, 255)
ct:sleep(speed)
end
end
end
--------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------
--
-- NOTHING BELOW HERE NEEDS TO BE ALTERED
--
--------------------------------------------------------------------------------------------------------
function OnEvent(event, arg, family)
-- POLLING INITIATED HERE
_GetRunningTime = GetRunningTime()
if event == "PROFILE_ACTIVATED" then
ClearLog()
POLL = Poll:new(POLL_FAMILY, POLL_DELAY)
POLL:start()
if KB_EVENTS then
kb = EventHandler:new("kb")
kbrocessEvent(event, arg, family)
end
if LHC_EVENTS then
lhc = EventHandler:new("lhc")
lhcrocessEvent(event, arg, family)
end
_onActivation(event, arg, family)
else
-- POLLING ROUTINES BELOW
POLL:run(event,arg,family)
if KB_EVENTS then kbrocessEvent(event, arg, family) end
if LHC_EVENTS then lhcrocessEvent(event, arg, family) end
_GetRunningTime = GetRunningTime()
_OnEvent(event, arg, family) -- Runs myOnEvent to compartmentalize
end
if KB_EVENTS then kb:CleanupAfterEvent() end
if LHC_EVENTS then lhc:CleanupAfterEvent() end
end
log = OutputLogMessage
function Type(v)
if type(v) == "table" then
if v.Type ~= nil then
return v.Type
elseif v.type ~= nil then
return v.type
end
end
return type(v)
end
Poll = {}
Poll.__index = Poll
Poll.__newindex = function(table, key, value)
for k,v in pairs(table) do
if k == key then
rawset(table,key,value) return
end
end
error("'" .. key .. "' is not a member of Poll.", 2)
end
function Poll:new(family, delay)
local self = {}
self.delay = delay or 50
if family ~= "kb" and family ~= "lhc" then
error("Poll:new() - 'pFamily' must be 'kb' or 'lhc'", 2)
end
self.pFamily = family
self.presses = 0
self.running = false
self.runMKeyModifier = false
self.MKeyModifier = { nil, nil, nil } -- "default" or Modifiers. i.e. "lshift", "ctrl"
self.modFamily = ""
self.Type = "Poll"
setmetatable(self, Poll)
return self
end
function Poll:setMKeyModifier( m1, m2, m3, family )
self.runMKeyModifier = true
self.MKeyModifier[1] = m1
self.MKeyModifier[2] = m2
self.MKeyModifier[3] = m3
if family ~= "kb" and family ~= "lhc" then error("Poll:setMKeyModifier() family - needs to be 'kb' or 'lhc'",2) end
self.modFamily = family
end
function Poll:start()
self.running = true
self:setMKeyState()
end
function Poll:stop()
self.running = false
end
function Poll:_press()
if self.running then
self.presses = self.presses + 1
end
end
function Poll:release()
if self.running then
self.presses = self.presses - 1
end
end
function Poll:setMKeyState()
if self.runMKeyModifier then
local default = nil
local i = 1
local modMKeyState = nil
for i = 1, 3, 1 do
if self.MKeyModifier == "default" then
default = i
elseif self.MKeyModifier == "" then
-- do nothing
elseif string.find(self.MKeyModifier,"mb%d") then
local iMB = tonumber(string.sub(self.MKeyModifier,3))
if IsMouseButtonPressed(iMB) then
modMKeyState = i
end
elseif IsModifierPressed(self.MKeyModifier) then
modMKeyState = i
end
end
if modMKeyState == nil then
modMKeyState = default
end
if modMKeyState ~= nil then
if self.pFamily == self.modFamily then
SetMKeyState(modMKeyState, self.pFamily)
return
elseif GetMKeyState(self.modFamily) ~= modMKeyState then
SetMKeyState(modMKeyState, self.modFamily)
end
end
end
SetMKeyState( GetMKeyState(self.pFamily), self.pFamily )
end
function Poll:run(event, arg, family)
if self.running and self.pFamily == family then
if event == "M_PRESSED" then
self:_press()
Sleep(self.delay)
elseif event == "M_RELEASED" then
if self.presses == 1 then
self:setMKeyState()
Sleep(self.delay)
end
self:release()
end
end
end
CoThread = {}
CoThread.__index = CoThread
function CoThread:new(f) -- f - function(MultiThread)
local self = {}
if type(f) ~= "function" then
error("A function is needed",2)
end
self.func = f
self.co = nil
self.sleepUntilTimeStamp = nil
self.Type = "CoThread"
setmetatable(self, CoThread)
return self
end
function CoThread:recreate()
self:kill()
self.co = coroutine.create(self.func)
end
function CoThread:create()
self.co = coroutine.create(self.func)
end
function CoThread:isDead()
if self.co == nil then
return true
elseif coroutine.status(self.co) == "dead" then
self.co = nil
return true
else
return false
end
end
function CoThread:run(...)
if self:isDead() then
return
end
if self.sleepUntilTimeStamp ~= nil then
if _GetRunningTime < self.sleepUntilTimeStamp then
return
else
self.sleepUntilTimeStamp = nil
end
end
coroutine.resume(self.co, self, ...)
end
function CoThread:kill()
self.co = nil
self.sleepUntilTimeStamp = nil
end
function CoThread:yield()
coroutine.yield()
end
function CoThread:sleep(Milliseconds)
self.sleepUntilTimeStamp = _GetRunningTime + Milliseconds
coroutine.yield()
end
function CoThread:start()
self:recreate()
end
function CoThread:stop()
self:kill()
end
function CoThread:isFinished()
return self:isDead()
end
kopyalayacagnız komut;
-- Code update by Bystander on 5/13/2012
DEVICE = "mouse" -- "kb" for keyboard, "lhc" for left handed controller, such as the G13
------------------------------------------------------------------------------------------------------------
POLL_DELAY = 0 -- Sleep time after each poll (beware of number below 16)
POLL_FAMILY = "kb" -- The device polling will take place on. Prefered to not be on macroed device.
------------------------------------------------------------------------------------------------------------
speed = POLL_DELAY -- this should alwasy be equal or larger than POLL_DELAY
inc = 1
lcd = OutputLCDMessage
function _onActivation(event, arg, family)
--
-- ADD ANY START UP ROUTINES HERE
--
ctDiscoColors = CoThread:new(discoColors)
ctDiscoColors:start()
Toggle = true
end
function _OnEvent(event, arg, family)
--
-- ADD EVENT FUNCTIONALITY HERE
--
if event == "G_PRESSED" and arg == 1 then
Toggle = not Toggle
if Toggle then
lcd("Fade resumed.", 3000)
else
lcd("Fade paused.", 3000)
end
end
if event == "G_PRESSED" and arg == 2 then
speed = speed-POLL_DELAY
if speed < POLL_DELAY then -- if speed is 0 or less, the program will not reliquish control
speed = POLL_DELAY
end
lcd(speed .. "ms between updates")
end
if event == "G_PRESSED" and arg == 3 then
speed = speed+POLL_DELAY
lcd(speed .. "ms between updates")
end
if event == "G_PRESSED" and arg == 4 then
inc = inc + 9
lcd(inc.." color increment(s)")
end
if event == "G_PRESSED" and arg == 5 then
if inc > 1 then
inc = inc - 9
end
lcd(inc.." color increment(s)")
end
if Toggle then
ctDiscoColors:run()
end
end
function discoColors(ct)
while true do
for i = 0, 255, inc do
SetBacklightColor(i,0,255,DEVICE)
-- OutputLogMessage("Red: %i, Green: %i, Blue: %i\n", i, 0, 255)
ct:sleep(speed)
end
-- now to red
for i = 255, 0, -inc do
SetBacklightColor(255,0,i,DEVICE)
-- OutputLogMessage("Red: %i, Green: %i, Blue: %i\n", 255, 0, i)
ct:sleep(speed)
end
-- now to green-red
for i = 0, 255, inc do
SetBacklightColor(255,i,0,DEVICE)
-- OutputLogMessage("Red: %i, Green: %i, Blue: %i\n", 255, i, 0)
ct:sleep(speed)
end
-- now to green
for i = 255, 0, -inc do
SetBacklightColor(i,255,0,DEVICE)
-- OutputLogMessage("Red: %i, Green: %i, Blue: %i\n", i, 255, 0)
ct:sleep(speed)
end
-- now to green-blue
for i = 0, 255, inc do
SetBacklightColor(0,255,i,DEVICE)
-- OutputLogMessage("Red: %i, Green: %i, Blue: %i\n", 0, 255, i)
ct:sleep(speed)
end
-- back to blue
for i = 255, 0, -inc do
SetBacklightColor(0,i,255,DEVICE)
-- OutputLogMessage("Red: %i, Green: %i, Blue: %i\n", 0, i, 255)
ct:sleep(speed)
end
end
end
--------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------
--
-- NOTHING BELOW HERE NEEDS TO BE ALTERED
--
--------------------------------------------------------------------------------------------------------
function OnEvent(event, arg, family)
-- POLLING INITIATED HERE
_GetRunningTime = GetRunningTime()
if event == "PROFILE_ACTIVATED" then
ClearLog()
POLL = Poll:new(POLL_FAMILY, POLL_DELAY)
POLL:start()
if KB_EVENTS then
kb = EventHandler:new("kb")
kbrocessEvent(event, arg, family)
end
if LHC_EVENTS then
lhc = EventHandler:new("lhc")
lhcrocessEvent(event, arg, family)
end
_onActivation(event, arg, family)
else
-- POLLING ROUTINES BELOW
POLL:run(event,arg,family)
if KB_EVENTS then kbrocessEvent(event, arg, family) end
if LHC_EVENTS then lhcrocessEvent(event, arg, family) end
_GetRunningTime = GetRunningTime()
_OnEvent(event, arg, family) -- Runs myOnEvent to compartmentalize
end
if KB_EVENTS then kb:CleanupAfterEvent() end
if LHC_EVENTS then lhc:CleanupAfterEvent() end
end
log = OutputLogMessage
function Type(v)
if type(v) == "table" then
if v.Type ~= nil then
return v.Type
elseif v.type ~= nil then
return v.type
end
end
return type(v)
end
Poll = {}
Poll.__index = Poll
Poll.__newindex = function(table, key, value)
for k,v in pairs(table) do
if k == key then
rawset(table,key,value) return
end
end
error("'" .. key .. "' is not a member of Poll.", 2)
end
function Poll:new(family, delay)
local self = {}
self.delay = delay or 50
if family ~= "kb" and family ~= "lhc" then
error("Poll:new() - 'pFamily' must be 'kb' or 'lhc'", 2)
end
self.pFamily = family
self.presses = 0
self.running = false
self.runMKeyModifier = false
self.MKeyModifier = { nil, nil, nil } -- "default" or Modifiers. i.e. "lshift", "ctrl"
self.modFamily = ""
self.Type = "Poll"
setmetatable(self, Poll)
return self
end
function Poll:setMKeyModifier( m1, m2, m3, family )
self.runMKeyModifier = true
self.MKeyModifier[1] = m1
self.MKeyModifier[2] = m2
self.MKeyModifier[3] = m3
if family ~= "kb" and family ~= "lhc" then error("Poll:setMKeyModifier() family - needs to be 'kb' or 'lhc'",2) end
self.modFamily = family
end
function Poll:start()
self.running = true
self:setMKeyState()
end
function Poll:stop()
self.running = false
end
function Poll:_press()
if self.running then
self.presses = self.presses + 1
end
end
function Poll:release()
if self.running then
self.presses = self.presses - 1
end
end
function Poll:setMKeyState()
if self.runMKeyModifier then
local default = nil
local i = 1
local modMKeyState = nil
for i = 1, 3, 1 do
if self.MKeyModifier == "default" then
default = i
elseif self.MKeyModifier == "" then
-- do nothing
elseif string.find(self.MKeyModifier,"mb%d") then
local iMB = tonumber(string.sub(self.MKeyModifier,3))
if IsMouseButtonPressed(iMB) then
modMKeyState = i
end
elseif IsModifierPressed(self.MKeyModifier) then
modMKeyState = i
end
end
if modMKeyState == nil then
modMKeyState = default
end
if modMKeyState ~= nil then
if self.pFamily == self.modFamily then
SetMKeyState(modMKeyState, self.pFamily)
return
elseif GetMKeyState(self.modFamily) ~= modMKeyState then
SetMKeyState(modMKeyState, self.modFamily)
end
end
end
SetMKeyState( GetMKeyState(self.pFamily), self.pFamily )
end
function Poll:run(event, arg, family)
if self.running and self.pFamily == family then
if event == "M_PRESSED" then
self:_press()
Sleep(self.delay)
elseif event == "M_RELEASED" then
if self.presses == 1 then
self:setMKeyState()
Sleep(self.delay)
end
self:release()
end
end
end
CoThread = {}
CoThread.__index = CoThread
function CoThread:new(f) -- f - function(MultiThread)
local self = {}
if type(f) ~= "function" then
error("A function is needed",2)
end
self.func = f
self.co = nil
self.sleepUntilTimeStamp = nil
self.Type = "CoThread"
setmetatable(self, CoThread)
return self
end
function CoThread:recreate()
self:kill()
self.co = coroutine.create(self.func)
end
function CoThread:create()
self.co = coroutine.create(self.func)
end
function CoThread:isDead()
if self.co == nil then
return true
elseif coroutine.status(self.co) == "dead" then
self.co = nil
return true
else
return false
end
end
function CoThread:run(...)
if self:isDead() then
return
end
if self.sleepUntilTimeStamp ~= nil then
if _GetRunningTime < self.sleepUntilTimeStamp then
return
else
self.sleepUntilTimeStamp = nil
end
end
coroutine.resume(self.co, self, ...)
end
function CoThread:kill()
self.co = nil
self.sleepUntilTimeStamp = nil
end
function CoThread:yield()
coroutine.yield()
end
function CoThread:sleep(Milliseconds)
self.sleepUntilTimeStamp = _GetRunningTime + Milliseconds
coroutine.yield()
end
function CoThread:start()
self:recreate()
end
function CoThread:stop()
self:kill()
end
function CoThread:isFinished()
return self:isDead()
end