Kategori arşivi: Bilgisayar Programlama

Logitech G300S Sürekli Ses Artırma/Azaltma Lua Scripti

Yeni aldığım logitech g300s mouseumda macro özelliğini kullanarak G tuşlarına ses açma ve kısma tuşları atamak istediğimde önceki a4 tech x7 gaming mouseumun yazılımında olan fakat ilginç bir şekilde logitech yazılımında olmayan bir özelliğe rastladım.

A4 tech in sağladığı yazılımda basılı tutarak ses açma ve kısma özellikleri bulunurken logitech yazılımında ses açıp kısmak için her seferinde tuşa basmak zorunda kalıyorsunuz, her basmada 2 şer kez artırıp azalttığına göre sesi 0 dan 100 e çıkarmak için tuşa 50 kez basmanız gerekiyor, saçma bir mekanik.

İngilizce kaynaklarda biraz araştırdıktan sonra bir arkadaşın lua scripti kullanarak bu soruna çözüm bulduğunu gördüm. tabi ki paylaştığı kod direk kopyala yapıştır ile çalışmadı, ufak tefek düzenleme, temizleme yapmak gerekti, lua dilini bilmediğim için biraz üşendim açıkcası, mouseı aldıktan bir kaç hafta sonra kodla uğraşabildim, biraz düzenleyip aşağıdaki şekilde çalıştırmayı başardım.

Aşağıdaki kodu direk olarak kod ekranındaki kodla değiştirip kaydet (ctrl+s) yaptığınızda logitech g300s mouseunuzun sağda bulunan 2 tuşuna yani g7 ve g6 tuşlarına ses açıp kısma özelliği kazandıracaktır. atama işlemi kodla yapılacağından bu tuşlarda herhangi bir komut varsa atamasını kaldırın, yoksa hem ses açma/kısmaya çalışıp hem de atanan komutu uygulamaya çalışıp buglu çalışacaktır.

Kod ekranını açmak için logitech gaming software üzerinde uygulamak istediğiniz profile sağ tıklayıp komut düzenleyicisini göster diyin, açılan ekrandaki kodları silip paylaştığım kodları yapıştırın ve kaydedin. ayrıca bu ekranı açmak için genel modu değil, oyun algılama modunu kullanarak ayar yapmanız gerekiyor, sadece bu şekilde kod yazılabiliyor. oyun dışında da çalışsın istiyorsanız varsayılan profin üzerinde kodu kullanabiliyorsunuz.

Kodla ilgili ufak bir hata var, bu kodları kullandığınızda mod değiştirme işlemi yapamıyorsunuz, her zaman seçili üst moddan en üsttekine dönüyor. Ben zaten tek mod kullandığım için bu hataya fazla takılmadım, fakat uğraşmak isteyen varsa çözebileceğini düşünüyorum, sanırım her profil için ayrı ayrı tanımlama yapılmadığından sürekli ilk profili seçiyor.

Altta paylaştığım kodu oluşturmak için buradaki yazıdan faydalandım (i used this post at the link to generate this piece of code, i thank the person who wrote it) https://forums.logitech.com/t5/Scripting-and-SDK/Volume-Up-Down-in-Lua/m-p/1278108#M470

function fn_Rep(event, num, family, delay, ...)
local t = "Rep" .. family .. num
if event == "G_PRESSED" or event == "MOUSE_BUTTON_PRESSED" then
if TaskRunning(t) then AbortTask(t) end
RunTask(t, t_Rep, delay, ...)
elseif event == "G_RELEASED" or event == "MOUSE_BUTTON_RELEASED" then
StopTask(t)
end
end

function t_Rep(delay, ...)
local t1, t2 = 20, delay - 20
if t2 < 0 then t1, t2 = delay / 2, delay - delay / 2 end local f = true while f do PressKey(...) f = TaskSleep(t1) ReleaseKey(...) f = f and TaskSleep(t2) end return -1 end -- G300S Mouse Bindings G300S = {[0] = {}} G300S[1] = { --[1] = nil, -- left button --[2] = nil, -- right button --[3] = "mb2", -- middle (wheel) button --[4] = "mb4", -- G4 --[5] = "mb5", -- G5 [6] = {fn_Rep, 50, 0x12e}, [7] = {fn_Rep, 50, 0x130}, } Map = { ["mouse"] = G300S, } -- everything below this line is "framework" code and shouldn't normally be changed function OnEvent(event, arg, family) local st = StateTimer if event == "G_PRESSED" or event == "MOUSE_BUTTON_PRESSED" then local mode = GetMKeyState(family) local map = Map[family][mode] or {} local action = map[arg] local t = type(action) if t == "function" then action(event, arg, family) elseif t == "table" then local f = action[1] if type(f) == "function" then f(event, arg, family, unpack(action, 2)) else PressKey(unpack(action)) end elseif t == "string" or t == "number" then PressKey(action) end Map[family][0][arg] = action elseif event == "G_RELEASED" or event == "MOUSE_BUTTON_RELEASED" then local map = Map[family][0] local action = map[arg] local t = type(action) if t == "function" then action(event, arg, family) elseif t == "table" then local f = action[1] if type(f) == "function" then f(event, arg, family, unpack(action, 2)) else ReleaseKey(unpack(action)) end elseif t == "string" or t == "number" then ReleaseKey(action) end map[arg] = nil elseif event == "PROFILE_ACTIVATED" then EnablePrimaryMouseButtonEvents(true) InitPolling() elseif event == "PROFILE_DEACTIVATED" then ReleaseAllKeys() end DoTasks() Poll(event, arg, family, st) end POLL_FAMILY = "mouse" -- current mice don't have M-states, so this is a good choice POLL_INTERVAL = 10 -- delay (in milliseconds) before next loop, used to throttle polling rate POLL_DEADTIME = 100 -- settling time (in milliseconds) during which old poll events are drained function InitPolling() ActiveState = GetMKeyState_Hook(POLL_FAMILY) SetMKeyState_Hook(ActiveState, POLL_FAMILY) end function Poll(event, arg, family, st) if st == nil and StateTimer ~= nil then return end local t = GetRunningTime() if family == POLL_FAMILY then if event == "M_PRESSED" and arg ~= ActiveState then if StateTimer ~= nil and t >= StateTimer then StateTimer = nil end
if StateTimer == nil then ActiveState = arg end
StateTimer = t + POLL_DEADTIME
elseif event == "M_RELEASED" and arg == ActiveState then
Sleep(POLL_INTERVAL)
SetMKeyState_Hook(ActiveState, POLL_FAMILY)
end
end
end

GetMKeyState_Hook = GetMKeyState
GetMKeyState = function(family)
family = family or "kb"
if family == POLL_FAMILY then
return ActiveState
else
return GetMKeyState_Hook(family)
end
end

SetMKeyState_Hook = SetMKeyState
SetMKeyState = function(mkey, family)
family = family or "kb"
if family == POLL_FAMILY then
if mkey == ActiveState then return end
ActiveState = mkey
StateTimer = GetRunningTime() + POLL_DEADTIME
end
return SetMKeyState_Hook(mkey, family)
end

-- Task Management functions

TaskList = {}

function DoTasks()
local t = GetRunningTime()
for key, task in pairs(TaskList) do
if t >= task.time then
local s, d = coroutine.resume(task.task, task.run)
if (not s) or ((d or -1) < 0) then TaskList[key] = nil else task.time = task.time + d end end end end function RunTask(key, func, ...) AbortTask(key) local task = {} task.time = GetRunningTime() task.task = coroutine.create(func) task.run = true local s, d = coroutine.resume(task.task, ...) if (s) and ((d or -1) >= 0) then
task.time = task.time + d
TaskList[key] = task
end
end

function StopTask(key)
local task = TaskList[key]
if task ~= nil then task.run = false end
end

function AbortTask(key)
local task = TaskList[key]
if task == nil then return end
while true do
local s, d = coroutine.resume(task.task, false)
if (not s) or ((d or -1) < 0) then
TaskList[key] = nil
return
end
end
end

function TaskRunning(key)
local task = TaskList[key]
if task == nil then return false end
return task.run
end

function TaskSleep(delay)
return coroutine.yield(delay)
end

-- PressKey / ReleaseKey enhancements
-- if PressKey is called n times for a key, don't release until ReleaseKey has been called n times
-- allow arguments to be tables
-- release keys in reverse order of how they were pressed
-- allow "_", "^" and "@" prefixes for key-specific Shift, Ctrl and Alt modifiers
-- allow "mb1" through "mb5" for mouse buttons

MODIFIER_PREDELAY = 20 -- 20ms delay to allow Shift, Ctrl or Alt to register
MODIFIER_POSTDELAY = 10 -- 10ms delay before releasing Shift, Ctrl or Alt

KeyCounts = {}

PressKey_Hook = PressKey
PressKey = function(...)
local n = select("#", ...)
for i = 1, n do
local arg = select(i, ...)
if type(arg) == "table" then
PressKey(unpack(arg))
elseif arg ~= nil then
local fShift, fCtrl, fAlt
local c = string.sub(arg, 1, 1)
while c == "_" or c == "^" or c == "@" do
if c == "_" then
fShift = true
elseif c == "^" then
fCtrl = true
else
fAlt = true
end
arg = string.sub(arg, 2)
c = string.sub(arg, 1, 1)
end
c = KeyCounts[arg] or 0
c = c + 1
if c == 1 then
if fShift then PressKey_Hook("lshift") end
if fCtrl then PressKey_Hook("lctrl") end
if fAlt then PressKey_Hook("lalt") end
if fShift or fCtrl or fAlt then Sleep(MODIFIER_PREDELAY) end
if string.sub(arg, 1, 2) == "mb" then
PressMouseButton(string.sub(arg, 3))
else
PressKey_Hook(arg)
end
if fShift or fCtrl or fAlt then Sleep(MODIFIER_POSTDELAY) end
if fAlt then ReleaseKey_Hook("lalt") end
if fCtrl then ReleaseKey_Hook("lctrl") end
if fShift then ReleaseKey_Hook("lshift") end
end
KeyCounts[arg] = c
end
end
end

ReleaseKey_Hook = ReleaseKey
ReleaseKey = function(...)
local n = select("#", ...)
for i = n, 1, -1 do
local arg = select(i, ...)
if type(arg) == "table" then
ReleaseKey(unpack(arg))
elseif arg ~= nil then
local c = string.sub(arg, 1, 1)
while c == "_" or c == "^" or c == "@" do
arg = string.sub(arg, 2)
c = string.sub(arg, 1, 1)
end
c = KeyCounts[arg] or 1
c = c - 1
if c == 0 then
c = nil
if string.sub(arg, 1, 2) == "mb" then
ReleaseMouseButton(string.sub(arg, 3))
else
ReleaseKey_Hook(arg)
end
end
KeyCounts[arg] = c
end
end
end

function ReleaseAllKeys()
for arg, _ in pairs(KeyCounts) do
KeyCounts[arg] = nil
if string.sub(arg, 1, 2) == "mb" then
ReleaseMouseButton(string.sub(arg, 3))
else
ReleaseKey_Hook(arg)
end
end
end

Eclipse javaw.exe Hatası ve Çözüm Yolu

Eclipse IDE’yi yükledikten sonra, bilgisayarda java yüklü olsa bile “A Java Runtime Enviroment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse …” javaw.exe in your current PATH” şeklinde bir hata ile karşılaşabilirsiniz.
javaw.exe hatası

javaw.exe hatası

Hatanın çözümü için sırasıyla aşağıdakileri uygulamak gerekir;
1.) Bilgisayarda javaw.exe‘nin yüklü olduğu klasörü tespit edip not ediyoruz. Genellikle “C:\Program Files\Java\jre7\bin” klasöründedir.
2.) Bilgisayar ikonuna sağ tıklayıp “Özellikler” bölümüne giriyoruz
3.) Sol tarafta bulunan “Gelişmiş sistem ayarları” bölümüne geçiyoruz
4.) “Ortam Değişkenleri…” butonuna tıklıyoruz
5.) “Sistem değişkenleri” bölümünde “Path” değişkenini düzenle diyerek, “Değişken değeri:” bölümünde bulunan değerlerin en sonuna gelerek 1. madde de not ettiğimiz klasör yolunu başına ; koyarak ekliyoruz. ;C:\Program Files\Java\jre7\bin

Artık eclipse’i hatasız bir şekilde çalıştırabilirsiniz.