Версия для печати темы

Нажмите сюда для просмотра этой темы в обычном формате

UoKit.com Форумы _ UO Pilot _ Working with accentuation in characters

Автор: kaltorak 17.4.2024, 23:04

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

or
Код
say Chapéu


uopilot writes it this way:
Код
Chapйu


It inserts a different character (й) that doesn't exist in my language. Is there anything I can do to resolve this? Because there are several accents
á é í ó ú ã â ê... etc...

Thanks!

Автор: DarkMaster 17.4.2024, 23:16

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.

Автор: kaltorak 18.4.2024, 0:27

Цитата(DarkMaster @ 17.4.2024, 23:16) *

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.


Here the problems begin...
I'm using it in a game that uses EAC
EAC prevents Uopilot from using keys such as CTRL, SHIFT, ALT
sendex doesn't work
If I use the clipboard command to get the text from the array within the document, it is already copied with the wrong modified character.

I'm researching to see if I can find any solution, perhaps changing the characters in the original text document from which it will form the word array.

Автор: DarkMaster 18.4.2024, 8:46

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

Автор: DarkMaster 18.4.2024, 9:01

without lua i dont know how you can to do it

Автор: kaltorak 19.4.2024, 15:13

Цитата(DarkMaster @ 18.4.2024, 8:46) *

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



This seems like a good option. I can leave the function that copies the text in another script tab, I pass the id of the word to be copied by the main script and call the script in lua to copy and paste the word.

Now I'm just going to try to understand how this Lua example that you sent works, because I have almost 0 knowledge of how to program in Lua.

I've already read some topics here on the forum and I'm convinced that I need to study lua because it will open up a much greater range of possibilities for working with uopilot, in addition to the speed of execution in some cases, just more time available to study.

Thanks!

Автор: kaltorak 19.4.2024, 16:50

Цитата(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!

Русская версия Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)