im trying to simulate a sequence of keypresses in lua, i already have it working with another program but im limited to it being always on or off instead of being able to toggle it with capslock. but im getting the error "[string "LuaVM"]:8: attempt to call a nil value (global 'Keypress') Line Number:1"
this is my current code which i copied the base from another known working macro without errors. not really sure where to go from here or how to debug it, ive already tried searching the error in google but cant find anything useful
function OnEvent(event, arg)
if (event == "PROFILE_ACTIVATED") then
EnablePrimaryMouseButtonEvents(true)
end
if IsKeyLockOn("capslock")then
if (event == "MOUSE_BUTTON_PRESSED") then
Sleep(50)
Keypress(114)
Sleep(250)
Keypress(50)
Sleep(50)
Keypress(49)
end
end
end
this is the original donor code i tried to use
function OnEvent(event, arg)
if (event == "PROFILE_ACTIVATED") then
EnablePrimaryMouseButtonEvents(true)
end
if IsKeyLockOn("capslock")then
if (event == "MOUSE_BUTTON_PRESSED" and arg == 1)then
if IsMouseButtonPressed(3)then
repeat
MoveMouseRelative(-10, 10)
Sleep(10)
MoveMouseRelative(10, -10)
Sleep(10)
until not IsMouseButtonPressed(1)
end
end
end
end
final code
function OnEvent(event, arg)
if (event == "PROFILE_ACTIVATED") then
EnablePrimaryMouseButtonEvents(true)
end
if IsKeyLockOn("capslock")then
if IsMouseButtonPressed(1) then
Sleep(10)
PressAndReleaseKey("R")
Sleep(95)
PressAndReleaseKey("2")
Sleep(10)
PressAndReleaseKey("1")
end
end
end