#!/usr/bin/lua local input = "mypassword\nlogin: foobarbaz\nsomevalue: cruz\nautotype: {PASSWORD}{TAB}{login}{DELAY 1000}{TAB}{OTP}{RETURN}{somevalue}{RETURN}\notpauth:234234" local lines = {} local autotype = {} for line in string.gmatch(input, "([^\n]+)") do table.insert(lines, line) if string.match(line, "^autotype:%s") then for str in string.gmatch(line, "[^{}]+") do table.insert(autotype, str) end end end function findLine(name) for _, line in ipairs(lines) do if string.match(line, "^(" .. name .. "):") == name then return string.match(line, "^" .. name .. ":%s*([^(\n)]+)") end end return "" end for idx, at in ipairs(autotype) do if at:match("^DELAY") then os.execute("sleep " .. tonumber(at:gsub("%D", "") * 0.001)) elseif at == "TAB" or at == "RETURN" then os.execute("wtype -P " .. at) elseif at == "OTP" then os.execute("wtype " .. tonumber(findLine("otpauth"))) -- use otp script here elseif at == "PASSWORD" then os.execute("wtype " .. lines[1]) elseif string.sub(at, 1, 8) ~= "autotype" then print(at) os.execute("wtype " .. findLine(at)) end end