I'm working with UoPilot Scripting (no lua)
And I came across the following problem.
I'm Brazilian, and some letters of some words in Portuguese have accents. For example:
Chpéu = Hat (Hat in English)
When I use the command
send Chapéu
say Chapéu
Chapйu
If it possible i recommend to put data to clipboard and paste it. If your application cant receive data from clipboard, you can use sendex. Sendex will send same symbol like on your keyboard, but app window must be active and layout must be changed to target language.
https://forum.uokit.com/index.php?s=&showtopic=71205&view=findpost&p=444003
i recommend to start from that.
For paste:
local ffi=require "ffi"
ffi.cdef[[
int PostMessageA(int hWnd, int Msg, int wParam, int lParam);
]]
local ext = {}
-- Вставить буфер обмена
ext.paste = function(handle)
handle = handle or workwindow()
return ffi.C.PostMessageA(handle, 0x302, 0, 0)
end
ext.send_clipboard = function(text)
text = text or ext.clipboard()
if text then
ext.clipboard(text)
ext.paste()
end
end
without lua i dont know how you can to do it
local ffi=require "ffi"
ffi.cdef[[
int PostMessageA(int hWnd, int Msg, int wParam, int lParam);
]]
local ext = {}
-- Вставить буфер обмена
ext.paste = function(handle)
handle = handle or workwindow()
return ffi.C.PostMessageA(handle, 0x302, 0, 0)
end
ext.send_clipboard = function(text)
text = text or ext.clipboard()
if text then
ext.clipboard(text)
ext.paste()
end
end
--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
Русская версия Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)