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

 
Ответить в эту темуОткрыть новую тему
> 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
сообщение 17.4.2024, 23:16
Сообщение #2


***********

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



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.


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


**

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



Цитата(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.
Пользователь в офлайнеDelete PostОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения
DarkMaster
сообщение 18.4.2024, 8:46
Сообщение #4


***********

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



https://forum.uokit.com/index.php?s=&sh...st&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, 14:22


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


***********

Модератор UOPilot
Сообщений: 9.468
Регистрация: 2.12.2008
Группа: Супермодераторы
Наличность: 27739
Пользователь №: 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, 15:13
Сообщение #6


**

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



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

https://forum.uokit.com/index.php?s=&sh...st&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!
Пользователь в офлайнеDelete PostОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения
kaltorak
сообщение 19.4.2024, 16:50
Сообщение #7


**

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Отправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения

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

 

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