Keyboard-1 Lua
Keyboard-1 Lua
script_translator = "Jamelia"
script_author = "CaJlaT"
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
sampAddChatMessage(script_name.."{FFFFFF} By {FF0404}" ..script_author.."
{FFFFFF}Translated by {FF0404}" ..script_translator.. "{FFFFFF}. " , 0xFF0404)
sampRegisterChatCommand('key', function() settings.v = not settings.v end)
while true do
wait(0)
imgui.Process = settings.v or keyboard.v or mouse.v
imgui.ShowCursor = settings.v
delta = getMousewheelDelta()
if delta ~= 0 then table.insert(wheel, {delta, os.clock()+0.05}) end --
���� ���������� �������� ������
end
end
function imgui.OnDrawFrame()
local X, Y = getScreenResolution()
if settings.v then
imgui.SetNextWindowSize(imgui.ImVec2(194, 120),
imgui.Cond.FirstUseEver)
imgui.SetNextWindowPos(imgui.ImVec2(X / 2, Y / 2),
imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.Begin('Keyboard and Mouse', settings, imgui.WindowFlags.NoResize
+ imgui.WindowFlags.AlwaysAutoResize)
imgui.PushItemWidth(140)
imgui.Combo('Keyboard type', keyboard_type, {'Whole Keyboard',
'No Numpad', 'Only Numbers', 'Compact Numbers', u8'Control Buttons'})
imgui.PopItemWidth()
imgui.Checkbox('Enable Keyboard', keyboard)
imgui.Checkbox('Enable mouse', mouse)
imgui.Checkbox('Keyboard and Mouse Movement', move)
imgui.PushItemWidth(140)
if imgui.Combo('Theme', theme, {'Green', 'Red', 'Light Purple',
'Dark Purple', 'Cherry', 'Yellow'}) then styles[theme.v]() end
imgui.PopItemWidth()
imgui.SetCursorPosX((imgui.GetWindowWidth()-
imgui.CalcTextSize('by CaJlaT').x)/2)
imgui.End()
end
if keyboard.v then
imgui.PushStyleVar(imgui.StyleVar.WindowPadding, imgui.ImVec2(5.0,
2.4))
imgui.PushStyleColor(imgui.Col.WindowBg, imgui.ImVec4(0,0,0,0))
imgui.SetNextWindowPos(keyboard_pos, imgui.Cond.FirstUseEver,
imgui.ImVec2(0, 0))
imgui.Begin('##keyboard', _, imgui.WindowFlags.NoResize +
imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.AlwaysAutoResize + (move.v and 0
or imgui.WindowFlags.NoMove) )
keyboard_pos = imgui.GetWindowPos()
for i, line in ipairs(keyboards[keyboard_type.v+1]) do
if (keyboard_type.v == 0 or keyboard_type.v == 1) and i ==
4 then
imgui.SetCursorPosY(68) -- fix
elseif (keyboard_type.v == 0 or keyboard_type.v == 1) and i
== 6 then
imgui.SetCursorPosY(112) -- fix
end
for key, v in ipairs(line) do
local size = imgui.CalcTextSize(v[1])
if isKeyDown(v[2]) then
imgui.PushStyleColor(imgui.Col.ChildWindowBg,
imgui.GetStyle().Colors[imgui.Col.ButtonActive])
else
imgui.PushStyleColor(imgui.Col.ChildWindowBg,
imgui.ImVec4(0,0,0,0.4))
end
imgui.BeginChild('##'..i..key,
imgui.ImVec2(size.x+11, (v[1] == '\n+' or v[1] == '\nE') and size.y + 14 or size.y
+ 5), true)
imgui.Text(v[1])
imgui.EndChild()
imgui.PopStyleColor()
if key ~= #line then
imgui.SameLine()
if v[3] then
imgui.SameLine(imgui.GetCursorPosX()+v[3]) end
end
end
end
imgui.End()
imgui.PopStyleColor()
imgui.PopStyleVar()
end
if mouse.v then
imgui.PushStyleVar(imgui.StyleVar.WindowPadding, imgui.ImVec2(5.0,
2.4))
imgui.PushStyleColor(imgui.Col.WindowBg, imgui.ImVec4(0,0,0,0))
imgui.SetNextWindowPos(mouse_pos, imgui.Cond.FirstUseEver,
imgui.ImVec2(0, 0))
imgui.Begin('##mouse', _, imgui.WindowFlags.NoResize +
imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.AlwaysAutoResize + (move.v and 0
or imgui.WindowFlags.NoMove) )
mouse_pos = imgui.GetWindowPos()
for key, v in ipairs(mouse_keys) do
if key == 2 then renderWheel() imgui.SetCursorPosY(18)
elseif key == 3 then imgui.SetCursorPosY(2) end
local size = imgui.CalcTextSize(v[1])
if isKeyDown(v[2]) then
imgui.PushStyleColor(imgui.Col.ChildWindowBg,
imgui.GetStyle().Colors[imgui.Col.ButtonActive])
else
imgui.PushStyleColor(imgui.Col.ChildWindowBg,
imgui.ImVec4(0,0,0,0.4))
end
imgui.BeginChild('##'..key, imgui.ImVec2(v[4] and v[4] or
size.x+11, v[3] and v[3] or size.y+5), true)
if v[3] then imgui.SetCursorPosY((v[3]-size.y)/2) end
imgui.SetCursorPosX((imgui.GetWindowWidth()-size.x)/2)
imgui.Text(v[1])
imgui.EndChild()
imgui.PopStyleColor()
if key ~= 3 then imgui.SameLine() end
end
imgui.End()
imgui.PopStyleColor()
imgui.PopStyleVar()
end
end
function renderWheel()
if #wheel > 0 then
local p = imgui.GetCursorScreenPos()
local c = imgui.GetCursorPos()
local draw_list = imgui.GetWindowDrawList()
draw_list:AddRectFilled(imgui.ImVec2(p.x, p.y), imgui.ImVec2(p.x+36,
p.y+34), imgui.GetColorU32(wheel[1][1] > 0 and
imgui.GetStyle().Colors[imgui.Col.ButtonActive] or imgui.ImVec4(0,0,0,0)), 10)
draw_list:AddRectFilled(imgui.ImVec2(p.x, p.y+16), imgui.ImVec2(p.x+36,
p.y+49), imgui.GetColorU32(wheel[1][1] < 0 and
imgui.GetStyle().Colors[imgui.Col.ButtonActive] or imgui.ImVec4(0,0,0,0)), 10)
if wheel[1][2] < os.clock() then
table.remove(wheel, 1)
end
end
end
function onScriptTerminate(s)
if s == thisScript() then
ini.config.active = keyboard.v
ini.mouse.active = mouse.v
ini.config.mode = keyboard_type.v
ini.config.move = move.v
ini.config.theme = theme.v
ini.pos.x, ini.pos.y = keyboard_pos.x, keyboard_pos.y
ini.mouse.x, ini.mouse.y = mouse_pos.x, mouse_pos.y
inicfg.save(ini, iniFile)
end
end
keyboards = {
{ -- Whole Keyboard
{ -- Line 1
-- {Name, code, indent}
{'Esc', 0x1B},
{'F1', 0x70},
{'F2', 0x71},
{'F3', 0x72},
{'F4', 0x73},
{'F5', 0x74},
{'F6', 0x75},
{'F7', 0x76},
{'F8', 0x77},
{'F9', 0x78},
{'F10', 0x79},
{'F11', 0x7A},
{'F12', 0x7B, 23},
{'PS', 0x2C},
{'SL', 0x91},
{'P', 0x13},
},
{ -- Line 2
-- {Name, code, indent}
{'`', 0xC0},
{'1', 0x31},
{'2', 0x32},
{'3', 0x33},
{'4', 0x34},
{'5', 0x35},
{'6', 0x36},
{'7', 0x37},
{'8', 0x38},
{'9', 0x39},
{'0', 0x30},
{'-', 0xBD},
{'+', 0xBB},
{'<-', 0x08},
{'Ins', 0x2D},
{'Home', 0x24},
{'PgUp', 0x21},
{'NL', 0x90},
{'/', 0x6F},
{'*', 0x6A},
{'-', 0x6D},
},
{ -- Line 3
-- {Name, code, indent}
{'Tab', 0x09},
{'Q', 0x51},
{'W', 0x57},
{'E', 0x45},
{'R', 0x52},
{'T', 0x54},
{'Y', 0x59},
{'U', 0x55},
{'I', 0x49},
{'O', 0x4F},
{'P', 0x50},
{'[', 0xDB},
{']', 0xDD},
{'\\', 0xDC},
{'Del', 0x2E},
{'End', 0x23},
{'PgDn', 0x22, 6},
{'7', 0x67},
{'8', 0x68},
{'9', 0x69},
{'\n+', 0x6B},
},
{ -- Line 4
-- {Name, code, indent}
{'Caps ', 0x14},
{'A', 0x41},
{'S', 0x53},
{'D', 0x44},
{'F', 0x46},
{'G', 0x47},
{'H', 0x48},
{'J', 0x4A},
{'K', 0x4B},
{'L', 0x4C},
{';', 0xBA},
{'\'', 0xDE},
{' Enter ', 0x0D, 96},
{'4', 0x64},
{'5', 0x65},
{'6', 0x66},
},
{ -- Line 5
-- {Name, code, indent}
{' LShift ', 0xA0},
{'Z', 0x5A},
{'X', 0x58},
{'C', 0x43},
{'V', 0x56},
{'B', 0x42},
{'N', 0x4E},
{'M', 0x4D},
{',', 0xBC},
{'.', 0xBE},
{'/', 0xBF},
{' RShift ', 0xA1, 37},
{'/\\', 0x26, 37},
{'1', 0x61},
{'2', 0x62},
{'3', 0x63},
{'\nE', 0x0D},
},
{ -- Line 6
-- {Name, code, indent}
{'Ctrl', 0xA2},
{'Win', 0x5B},
{'Alt', 0xA4},
{' ', 0x20},
{'Alt', 0xA5},
{'Win', 0x5C},
{'Ctrl', 0xA3, 17},
{'<', 0x25},
{'\\/', 0x28},
{'>', 0x27, 16},
{'0 ', 0x60},
{'.', 0x6E},
}
},
{ -- No Numpad
{
{'Esc', 0x1B},
{'F1', 0x70},
{'F2', 0x71},
{'F3', 0x72},
{'F4', 0x73},
{'F5', 0x74},
{'F6', 0x75},
{'F7', 0x76},
{'F8', 0x77},
{'F9', 0x78},
{'F10', 0x79},
{'F11', 0x7A},
{'F12', 0x7B},
},
{
{'`', 0xC0},
{'1', 0x31},
{'2', 0x32},
{'3', 0x33},
{'4', 0x34},
{'5', 0x35},
{'6', 0x36},
{'7', 0x37},
{'8', 0x38},
{'9', 0x39},
{'0', 0x30},
{'-', 0xBD},
{'+', 0xBB},
{'<-', 0x08},
{'Ins', 0x2D},
{'Home', 0x24},
{'PU', 0x21},
},
{
{'Tab', 0x09},
{'Q', 0x51},
{'W', 0x57},
{'E', 0x45},
{'R', 0x52},
{'T', 0x54},
{'Y', 0x59},
{'U', 0x55},
{'I', 0x49},
{'O', 0x4F},
{'P', 0x50},
{'[', 0xDB},
{']', 0xDD},
{'\\', 0xDC},
{'Del', 0x2E},
{'End', 0x23},
{'PD', 0x22},
},
{
{'Caps ', 0x14},
{'A', 0x41},
{'S', 0x53},
{'D', 0x44},
{'F', 0x46},
{'G', 0x47},
{'H', 0x48},
{'J', 0x4A},
{'K', 0x4B},
{'L', 0x4C},
{';', 0xBA},
{'\'', 0xDE},
{' Enter ', 0x0D},
},
{
{' LShift ', 0xA0},
{'Z', 0x5A},
{'X', 0x58},
{'C', 0x43},
{'V', 0x56},
{'B', 0x42},
{'N', 0x4E},
{'M', 0x4D},
{',', 0xBC},
{'.', 0xBE},
{'/', 0xBF},
{' RShift ', 0xA1, 33},
{'/\\', 0x26},
},
{
{'Ctrl', 0xA2},
{'Win', 0x5B},
{'Alt', 0xA4},
{' ', 0x20},
{'Alt', 0xA5},
{'Win', 0x5C},
{'Ctrl', 0xA3, 10},
{'<', 0x25},
{'\\/', 0x28},
{'>', 0x27},
}
},
{ -- Only Numbers
{
{'1', 0x31},
{'2', 0x32},
{'3', 0x33},
{'4', 0x34},
{'5', 0x35},
{'6', 0x36},
{'7', 0x37},
{'8', 0x38},
{'9', 0x39},
{'0', 0x30},
},
{
{'N', 0x4E},
{' Enter ', 0x0D},
}
},
{ -- Compact Numbers
{
{'1', 0x31},
{'2', 0x32},
{'3', 0x33},
},
{
{'4', 0x34},
{'5', 0x35},
{'6', 0x36},
},
{
{'7', 0x37},
{'8', 0x38},
{'9', 0x39},
},
{
{'0', 0x30},
{'N', 0x4E},
},
{
{' Enter ', 0x0D},
}
},
{ -- Control Buttons
{
{'Tab', 0x09},
{'Q', 0x51},
{'W', 0x57},
{'E', 0x45},
},
{
{'Shift', 0x10},
{'A', 0x41},
{'S', 0x53},
{'D', 0x44},
{'C', 0x43},
},
{
{'Ctrl', 0xA2},
{'Alt', 0xA4},
{' ', 0x20},
}
}
}
mouse_keys = {
{'LMB', 0x01, 50},
{'MMB', 0x04},
{'RMB', 0x02, 50},
{'FWD', 0x06, _, 53},
{'BWD', 0x05, _, 53},
}
styles = {
[0] = function()
imgui.SwitchContext()
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4
style.WindowRounding = 10
style.ChildWindowRounding = 10
style.FrameRounding = 6.0