FanaticGuru wrote:
You just need to change all characters except for the words (and vertical tabs) you want in the colored layers to spaces.
It's exactly what I was looking for. Thank you.
I made a function with it.
SliceWord(text, words) It works well but it still relies on the Space() function. Can you merge the 2 functions ?
Here is a working example script
Code: Select all
string=
(
Here is a little song I wrote
You might want to sing it note for note
Don't worry be happy
In every life we have some trouble
When you worry you make it double
Don't worry, be happy
Ain't got no place to lay your head
Somebody came and took your bed
Don't worry, be happy
The land lord say your rent is late
He may have to litigate
Don't worry, be happy
Look at me I am happy
Don't worry, be happy
Here I give you my phone number
When you worry call me
I make you happy
Don't worry, be happy
Ain't got no cash, ain't got no style
Ain't got not girl to make you smile
But don't worry be happy
Cause when you worry
Your face will frown
And that will bring everybody down
So don't worry, be happy (now)
There is this little song I wrote
I hope you learn it note for note
Like good little children
Don't worry, be happy
Listen to what I say
In your life expect some trouble
But when you worry
You make it double
Don't worry, be happy
Don't worry don't do it, be happy
Put a smile on your face
Don't bring everybody down like this
Don't worry, it will soon past
Whatever it is
Don't worry, be happy
lyric: Bob MARLEY
)
msgbox, slice : "note" "is" "style" "trouble"
msgbox, % sliceword(string, "note|is|style|trouble")
msgbox, slice : letter "n"
msgbox, % sliceword(string, "n")
msgbox, slice : "But"
msgbox, % sliceword(string, "But")
msgbox, slice : Empty
msgbox, % sliceword(string, "")
SliceWord(text, words) {
X:=1, output := ""
if (text) && (!words)
return regexreplace(text, "(?!\n).", " ")
while (X := RegExMatch(text, "(.*?)(" words "|\v)", M, X+StrLen(M)))
output .= Spaces(StrLen(M1)) M2
return output
}
Spaces(x)
{
Loop %x%
Result .= " "
return Result
}
I'm also looking for a line slicing function
sliceLine(text, Lines) or a function that allow two operations at same time
slice(text, words, lines) Any idea on how to do that ?
Merging back two sliced sentences would be also great.
FanaticGuru wrote: You might look at just using an ActiveX control that then allows you to use HTML, which gives you much easier control over appearance.
Thank you for your suggestion and interesting example. How to change the background color to black in the html file?
I'm trying to simulate a fake colored console with a dynamic response using only gui controls. I doubt I can do it in html.
Here is an example of what I'm trying to achieve:
(Any suggestions on how to improve this code are welcome)
Code: Select all
#SingleInstance, force
Menu=
(
Use the arrow keys to select a fruit
Fruits Menu:
************
Apple
Pear
Banana
Orange
)
j1=Jake came rushing in to see his Dad. `n"Dad!" he puffed, "is it true that an apple a day keeps the doctor away?" `n"That s what they say", said his Dad. `n"Well, give me an apple quick ?" `n"I have just broken the doctor's window!"
j2=Why can't you connect 2 speakers at the same time to an apple device? `n`nThey work in pears.
j3:="What do you say if someone steps on a banana peel?`nWell I guess he didn't find that appealing!"
j4:="Why did the blonde girl stare at the carton of orange juice? `n`nIt said concentrate."
fruits:=["Apple", "Pear", "Banana", "Orange"]
jokes:=[j1,j2,j3,j4]
colors:=["red", "green", "yellow", "F9812A"]
gui, font, s18 cwhite, terminal
gui, add,text, W500 H500 backgroundtrans vlayer0, % strreplace(Menu, "_", " ") ; white layer
gui, font, s18 cred, terminal
gui, add,text, xp yp Wp Hp backgroundtrans -hidden vlayer1,
gui, font, s18 clime, terminal
gui, add,text, xp yp Wp Hp backgroundtrans vlayer2,
gui, color, black
gui, +resize
gui, show
drawtext("layer1", SliceWord(menu, fruits[1]), "red")
i:=1
up::
(i>1) ? --i
drawtext("layer2")
drawtext("layer1", SliceWord(menu, fruits[i]), "red")
return
down::
(i<fruits.maxindex()) ? ++i ;: (i:=1)
drawtext("layer2")
drawtext("layer1", SliceWord(menu, fruits[i]), "red")
return
~enter::
drawtext("layer1", sliceword(menu, fruits[i]), "fuchsia")
;drawtext("layer2", sliceword(menu,"") "`nYou selected " fruits[i], colors[i])
drawtext("layer2", sliceword(menu,"") "`n" jokes[i], colors[i])
return
SliceWord(text, words) {
X:=1, output := ""
if (text) && (!words)
return regexreplace(text, "(?!\v).", " ")
while (X := RegExMatch(text, "(.*?)(" words "|\v)", M, X+StrLen(M)))
output .= Spaces(StrLen(M1)) M2
return output
}
Spaces(x)
{
Loop %x%
Result .= " "
return Result
}
drawtext(varname, texttodraw:="", color:="")
{
global
guicontrol,, %varname%, %texttodraw%
if (color)
ColorText(varname, color)
}
ColorText(cell_to_paint, color:="red")
{
GuiControl, +c%color% , %cell_to_paint%
GuiControl, MoveDraw, % cell_to_paint
}
guiclose:
esc::
exitapp
return
Cheers