Цитата(DarkMaster @ 18.4.2024, 9:01)
without lua i dont know how you can to do it
With the help of chatGPT I did it as follows @DarkMaster, it could be simpler, but unfortunately my knowledge of Lua is extremely limited.
Код
--lua
local ffi = require "ffi"
ffi.cdef[[
int PostMessageA(int hWnd, int Msg, int wParam, int lParam);
]]
local function pasteText(handle)
handle = handle or workwindow()
return ffi.C.PostMessageA(handle, 0x302, 0, 0)
end
local function pasteTextAtCursorWindow()
local window_handle = windowfromcursor()
if window_handle then
pasteText(window_handle)
return true
else
return false
end
end
local function readTextFromFile(file_path)
local file = io.open(file_path, "r")
if file then
local content = file:read("*a")
file:close()
return content
else
return nil
end
end
local function convertEncoding(text)
local conversion_table = {
["á"] = "á",
["é"] = "é",
["Ã"] = "í",
["ó"] = "ó",
["ú"] = "ú",
["ã"] = "ã",
["õ"] = "õ",
["â"] = "â",
["ê"] = "ê",
["î"] = "î",
["ô"] = "ô",
["û"] = "û",
["Ã "] = "à",
["è"] = "è",
["ì"] = "ì",
["ò"] = "ò",
["ù"] = "ù",
["ç"] = "ç",
}
local result = text:gsub("[\195-\255][\128-\191]", conversion_table)
return result
end
local file_path = "C:\\Uopilot\\checkpoints\\item.txt"
local text = readTextFromFile(file_path)
if text then
local utf8_text = convertEncoding(text)
send(utf8_text)
log("Text sent.")
else
log("Can't read the file.")
end
The EAC blocked the use of the PostMessage function in the example code you sent me, I was able to paste the text in other windows such as Notepad, but not in the game window.
Now I just have to adjust the connection bridge between the main script and the text paste function, I'll probably pass it via text file! Thank you very much for your help, you and @Ciro are great teachers as always!