Hi,
I searched the forum and try to find a way to capture ansi color details by triggers.
My case it,when I look at a flag ,it will show a flag with colors. The text with white text color is what I want.
In zmud,it is like:
Yes,I want to get the background ANSI color code.
I find something here: http://www.gammon.com.au/scripts/doc.php?function=ANSI
But I don't know how to get the raw ANSI color code by trigger. And I get styles detail by the following code:
The questions is it represents color with RGB,not ANSI code.How can I translate it into ANSI code or what a table between them?
Also,I capture the debug packets at the end of the post.
Thanks.
---packets
[EDIT]Added code tags.
I searched the forum and try to find a way to capture ansi color details by triggers.
My case it,when I look at a flag ,it will show a flag with colors. The text with white text color is what I want.
In zmud,it is like:
#TRIGGER {*%e[1;4(%d)m(%s)(%s)(%s)*}
Yes,I want to get the background ANSI color code.
I find something here: http://www.gammon.com.au/scripts/doc.php?function=ANSI
But I don't know how to get the raw ANSI color code by trigger. And I get styles detail by the following code:
The questions is it represents color with RGB,not ANSI code.How can I translate it into ANSI code or what a table between them?
Also,I capture the debug packets at the end of the post.
Thanks.
function zzTestFlag()
wait.make(function()
Send("look qi")
local colorTable = {}
local start = true
while true do
local line,wildcards,styles = wait.regexp("(.*)")
local validLine = string.find(line,"~") or string.find(line,"˜")
if start then
if validLine then
start = false
end
end
if not line or (#line<2 and not start) then
break
end
if validLine then
print("AAA"..line.."BBB")
print("styles")
for k, v in ipairs (styles) do
if RGBColourToName(v.textcolour)== "white" then
local backcolour = RGBColourToName(v.backcolour)
if not colorTable[backcolour] then
colorTable[backcolour] = 0
end
colorTable[backcolour] = tonumber(colorTable[backcolour]) + string.len(v.text)
--print(backcolour,"XXX"..v.text.."YYY")
end
end -- for each style run
end
end
--
tprint(colorTable)
local flagColor = itemWithMaxCount(colorTable)
print(flagColor)
end)
end
---packets
4;1m .[42;1m.[46 34 3b 31 6d 20 1b 5b 34 32 3b 31 6d 1b 5b 34 36
;1m .[41;1m .[44 3b 31 6d 20 1b 5b 34 31 3b 31 6d 20 1b 5b 34 34
;1m .[44;1m .[45 3b 31 6d 20 1b 5b 34 34 3b 31 6d 20 1b 5b 34 35
;1m.[46;1m .[42; 3b 31 6d 1b 5b 34 36 3b 31 6d 20 1b 5b 34 32 3b
1m .[42;1m .[41; 31 6d 20 1b 5b 34 32 3b 31 6d 20 1b 5b 34 31 3b
1m .[47;1m.[46;1 31 6d 20 1b 5b 34 37 3b 31 6d 1b 5b 34 36 3b 31
m .[43;1m .[44;1 6d 20 1b 5b 34 33 3b 31 6d 20 1b 5b 34 34 3b 31
m .[45;1m .[41;1 6d 20 1b 5b 34 35 3b 31 6d 20 1b 5b 34 31 3b 31
m.[46;1m .[47;1m 6d 1b 5b 34 36 3b 31 6d 20 1b 5b 34 37 3b 31 6d
.[46;1m .[45;1m. 1b 5b 34 36 3b 31 6d 20 1b 5b 34 35 3b 31 6d 1b
[46;1m .[42;1m.[ 5b 34 36 3b 31 6d 20 1b 5b 34 32 3b 31 6d 1b 5b
46;1m .[45;1m.[4 34 36 3b 31 6d 20 1b 5b 34 35 3b 31 6d 1b 5b 34
6;1m .[41;1m.[46 36 3b 31 6d 20 1b 5b 34 31 3b 31 6d 1b 5b 34 36
;1m .[2;37;0m... 3b 31 6d 20 1b 5b 32 3b 33 37 3b 30 6d a1 ab 0d
....[42;1m .[42; 0a a1 d6 1b 5b 34 32 3b 31 6d 20 1b 5b 34 32 3b
1m .[41;1m.[46;1 31 6d 20 1b 5b 34 31 3b 31 6d 1b 5b 34 36 3b 31
m .[44;1m.[46;1m 6d 20 1b 5b 34 34 3b 31 6d 1b 5b 34 36 3b 31 6d
.[43;1m.[46;1m 20 1b 5b 34 33 3b 31 6d 1b 5b 34 36 3b 31 6d 20
.[45;1m.[46;1m . 1b 5b 34 35 3b 31 6d 1b 5b 34 36 3b 31 6d 20 1b
[45;1m.[46;1m .[ 5b 34 35 3b 31 6d 1b 5b 34 36 3b 31 6d 20 1b 5b
42;1m.[46;1m .[4 34 32 3b 31 6d 1b 5b 34 36 3b 31 6d 20 1b 5b 34
3;1m.[46;1m .[41 33 3b 31 6d 1b 5b 34 36 3b 31 6d 20 1b 5b 34 31
;1m.[46;1m .[44; 3b 31 6d 1b 5b 34 36 3b 31 6d 20 1b 5b 34 34 3b
1m.[46;1m .[47;1 31 6d 1b 5b 34 36 3b 31 6d 20 1b 5b 34 37 3b 31
m.[46;1m .[43;1m 6d 1b 5b 34 36 3b 31 6d 20 1b 5b 34 33 3b 31 6d
.[45;1m.[46;1m 20 1b 5b 34 35 3b 31 6d 1b 5b 34 36 3b 31 6d 20
.[44;1m.[46;1m . 1b 5b 34 34 3b 31 6d 1b 5b 34 36 3b 31 6d 20 1b
[43;1m.[46;1m .[ 5b 34 33 3b 31 6d 1b 5b 34 36 3b 31 6d 20 1b 5b
45;1m.[46;1m .[4 34 35 3b 31 6d 1b 5b 34 36 3b 31 6d 20 1b 5b 34
7;1m.[46;1m .[42 37 3b 31 6d 1b 5b 34 36 3b 31 6d 20 1b 5b 34 32
;1m.[46;1m .[44; 3b 31 6d 1b 5b 34 36 3b 31 6d 20 1b 5b 34 34 3b
1m.[46;1m .[47;1 31 6d 1b 5b 34 36 3b 31 6d 20 1b 5b 34 37 3b 31
m.[46;1m .[41;1m 6d 1b 5b 34 36 3b 31 6d 20 1b 5b 34 31 3b 31 6d
.[46;1m .[47;1m 1b 5b 34 36 3b 31 6d 20 1b 5b 34 37 3b 31 6d 20
.[44;1m .[45;1m 1b 5b 34 34 3b 31 6d 20 1b 5b 34 35 3b 31 6d 20
.[2;37;0m....... 1b 5b 32 3b 33 37 3b 30 6d a1 ab 0d 0a a1 d6 1b
[47;1m.[46;1m .[ 5b 34 37 3b 31 6d 1b 5b 34 36 3b 31 6d 20 1b 5b
41;1m.[46;1m .[4 34 31 3b 31 6d 1b 5b 34 36 3b 31 6d 20 1b 5b 34
1;1m .[47;1m.[46 31 3b 31 6d 20 1b 5b 34 37 3b 31 6d 1b 5b 34 36
;1m .[42;1m.[46; 3b 31 6d 20 1b 5b 34 32 3b 31 6d 1b 5b 34 36 3b
[EDIT]Added code tags.