Здравствуйте, гость ( Вход | Регистрация )

> Working with accentuation in characters
kaltorak
сообщение 17.4.2024, 23:04
Сообщение #1


**

Neophyte
Сообщений: 21
Регистрация: 12.10.2021
Группа: Пользователи
Наличность: 0
Пользователь №: 20.106
Возраст: 30



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!
Пользователь в офлайнеDelete PostОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения
 
Ответить в эту темуОткрыть новую тему
Ответов
DarkMaster
сообщение 18.4.2024, 9:01
Сообщение #2


***********

Модератор UOPilot
Сообщений: 9.476
Регистрация: 2.12.2008
Группа: Супермодераторы
Наличность: 27859
Пользователь №: 11.279



without lua i dont know how you can to do it


--------------------
Скрипты UOPilot под заказ.
Консультации по UOpilot 15$/час.
Услуги Lua разработчика (не пилот, проекты, постоянка)
Disсоrd:
Kov____
Пользователь в офлайнеDelete PostОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения
kaltorak
сообщение 19.4.2024, 16:50
Сообщение #3


**

Neophyte
Сообщений: 21
Регистрация: 12.10.2021
Группа: Пользователи
Наличность: 0
Пользователь №: 20.106
Возраст: 30



Цитата(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!
Пользователь в офлайнеDelete PostОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения



Ответить в эту темуОткрыть новую тему
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 

- Текстовая версия | Версия для КПК Сейчас: 18.5.2024, 2:07
Designed by Nickostyle