赞 | 274 |
VIP | 0 |
好人卡 | 3 |
积分 | 496 |
经验 | 40966 |
最后登录 | 2024-9-22 |
在线时间 | 1920 小时 |
Lv5.捕梦者
- 梦石
- 10
- 星屑
- 39597
- 在线时间
- 1920 小时
- 注册时间
- 2010-11-14
- 帖子
- 3320
|
本帖最后由 KB.Driver 于 2023-1-31 20:52 编辑
(1)这两段插入脚本编辑器
class String CP_ACP = 0 CP_UTF8 = 65001 MultiByteToWideChar = Win32API.new(*%w[kernel32 MultiByteToWideChar ilpipi i]) WideCharToMultiByte = Win32API.new(*%w[kernel32 WideCharToMultiByte ilpipipp i]) def utf8_to_gb2312 n = 0 i = MultiByteToWideChar.call(CP_UTF8, 0, self, -1, nil, 0) buffer = "\0" * (i * 2) MultiByteToWideChar.call(CP_UTF8, 0, self, -1, buffer, i) i = WideCharToMultiByte.call(CP_ACP, 0, buffer, -1, nil, 0, nil, nil) result = "\0" * i WideCharToMultiByte.call(CP_ACP, 0, buffer, -1, result, i, nil, nil) result.chop! return result end def gb2312_to_utf8 n = self.size i = MultiByteToWideChar.call(CP_ACP, 0, self, n+1, nil, 0) buffer = "\0" * (i*2) i = MultiByteToWideChar.call(CP_ACP, 0, self, n+1, buffer, i) i = WideCharToMultiByte.call(CP_UTF8, 0, buffer, -1, nil, 0, nil, nil) result = "\0" * i WideCharToMultiByte.call(CP_UTF8, 0, buffer, -1, result, i, nil, nil) result.chop! return result end end
class String
CP_ACP = 0
CP_UTF8 = 65001
MultiByteToWideChar = Win32API.new(*%w[kernel32 MultiByteToWideChar ilpipi i])
WideCharToMultiByte = Win32API.new(*%w[kernel32 WideCharToMultiByte ilpipipp i])
def utf8_to_gb2312
n = 0
i = MultiByteToWideChar.call(CP_UTF8, 0, self, -1, nil, 0)
buffer = "\0" * (i * 2)
MultiByteToWideChar.call(CP_UTF8, 0, self, -1, buffer, i)
i = WideCharToMultiByte.call(CP_ACP, 0, buffer, -1, nil, 0, nil, nil)
result = "\0" * i
WideCharToMultiByte.call(CP_ACP, 0, buffer, -1, result, i, nil, nil)
result.chop!
return result
end
def gb2312_to_utf8
n = self.size
i = MultiByteToWideChar.call(CP_ACP, 0, self, n+1, nil, 0)
buffer = "\0" * (i*2)
i = MultiByteToWideChar.call(CP_ACP, 0, self, n+1, buffer, i)
i = WideCharToMultiByte.call(CP_UTF8, 0, buffer, -1, nil, 0, nil, nil)
result = "\0" * i
WideCharToMultiByte.call(CP_UTF8, 0, buffer, -1, result, i, nil, nil)
result.chop!
return result
end
end
GetForegroundWindow = Win32API.new(*%W[user32.dll GetForegroundWindow v l]) MessageBox = Win32API.new(*%W[user32.dll MessageBox lppl l]) Hwnd = GetForegroundWindow.call
GetForegroundWindow = Win32API.new(*%W[user32.dll GetForegroundWindow v l])
MessageBox = Win32API.new(*%W[user32.dll MessageBox lppl l])
Hwnd = GetForegroundWindow.call
(2)事件脚本用这个
text = "测试文本\n\n这是第二行" title = "测试标题" MessageBox.call(Hwnd, text.utf8_to_gb2312, title.utf8_to_gb2312, 48)
text = "测试文本\n\n这是第二行"
title = "测试标题"
MessageBox.call(Hwnd, text.utf8_to_gb2312, title.utf8_to_gb2312, 48)
(3)效果参考
RM自身的报错
使用脚本的效果,是不是一模一样?
可以用事件脚本触发,编辑文字显示不同内容
|
|