Page 3 of 4

Re: Subtitle.Render() - Beautiful Text on Screen

Posted: 17 Apr 2018, 13:07
by iseahound
I'm hoping someone will find this useful. I don't even use any of the fancy options. Prefer to stick to Arial font on a simple black background. Additional pictures of anyone's rendered text are appreciated.

Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen

Posted: 06 May 2018, 21:24
by iseahound
Updated RegEx to be much more efficient. Also Subtitles can be made draggable like this:

Code: Select all

#b::
a := new Vis2.Graphics.Subtitle()
a.allowDrag := true
a.Render("✿ ", "x:center y:center c:Off", "s:52.7 f:(Segoe UI Emoji) color:F9B0DE outline:(stroke:5 color:922F43 glow:5px tint:White)")
return
This feature is experimental and will change at any time. When it is finalized, I'll add a new tutorial.

Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen

Posted: 09 May 2018, 20:03
by guest592018
Currently text is always on top, is it possible to draw on the Desktop? That is, have windowed/fullscreen programs cover what's drawn? I couldn't seem to find this.

Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen

Posted: 10 May 2018, 17:41
by iseahound
Not sure. Using DllCall("SetParent", "uint", a.hwnd, "uint", WinExist("Program Manager")) doesn't work. In the meantime you can just call .AlwaysOnTop() to make it not always on top.

Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen

Posted: 10 May 2018, 20:38
by rhinox202
That works. That wasn't in the documentation... should have looked in the code. Thank you!

Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen

Posted: 11 May 2018, 02:51
by iseahound
Yeah, it's badly documented... .AlwaysOnTop() is a toggle. .ClickThrough() to make the window clickthrough is a toggle as well. To toggle visibility .ToggleVisible()

Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen

Posted: 11 May 2018, 16:57
by kunkel321
This is very cool Iseahound! Thanks for sharing it. I definitely want to integrate this into my tool that prints text onto my wallpaper. (Technically I believe it's a transparent GUI that is pinned to the desktop.)

I thought I'd tweak your first example and try to pin it to the desktop. I copy-n-pasted a chunk from my working code, but it doesn't seem to have the desired effect.

Code: Select all

#include <Subtitle>

a := new Subtitle()
a.Render("Steve's important stuff goes here.", "x:center y:83% c:Off", "s:52.7 f:(Garamond) color:White outline:(stroke:1 glow:4 tint:Black) dropShadow:(blur:5px color:White opacity:0.5 size:15)")
;a.Screenshot("MyFile.png")

; stuff I pasted is here
winget, hw_gui, ID, ahk_pid %pid%   ; These lines dock it to desktop.
winget, hw_desktop, ID, ahk_class Progman
DllCall("SetParent", "int*", hw_gui, "int*", hw_desktop)

return
Any thoughts about why it doesn't work?

I'll paste my working code, in case that helps. As you might guess, my scripting abilities are quite limited. I was able to come up with the below code with A LOT of help from people here on the forum. It accesses some .INI files (actually TXT files) and checks on my wifi address, then changes my default printer... Then puts some stuff on my Desktop.
Working code that I'd like to Sylize with Subtitle
Thoughts, anyone?


EDIT: Actually, I did get this to go to the bottom:

Code: Select all

#include <Subtitle>
a := new Subtitle()
a.Render("Steve's important stuff goes here.", "x:center y:83% c:Off", "s:52.7 f:(Garamond) color:White outline:(stroke:1 glow:4 tint:Black) dropShadow:(blur:5px color:White opacity:0.5 size:15)")
;a.Screenshot("MyFile.png")
process, exist
pid = %errorlevel%
WinSet, Bottom,, ahk_pid %pid%
winget, hw_gui, ID, ahk_pid %pid%   ; These lines dock it to desktop.
winget, hw_desktop, ID, ahk_class Progman
DllCall("SetParent", "int*", hw_gui, "int*", hw_desktop)
return
But am I using the parts of code correctly?

ALSO! I just realized that there are two pages of replies that I didn't notice before... They might already answer my question. I will read them now! :facepalm:

Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen

Posted: 11 May 2018, 17:20
by iseahound
Hmm... Everyone wants Rainmeter ported to AutoHotkey... (Rainmeter can do what you want!)

When you're calling process, Exist, you're making that specific AHK process a child of the Desktop. The thing is, Subtitle can generate many GUI's so all of them will be docked to the desktop. Still I'm confused myself as to why I can't dock an individual GUI to the desktop. Don't bother reading the past replies, they aren't relevant as I've updated Subtitle.Render() multiple times.

EDIT: Your code is correct btw.

EDIT2: Use a one-liner like this: a := Subtitle.Render("some text") to avoid calling a := new Subtitle()

Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen

Posted: 11 May 2018, 17:59
by iseahound
I found the reason why DllCall("SetParent", "uint", a.hwnd, "uint", WinExist("Program Manager")) doesn't work. Child windows cannot be transparent. This is a limitation of windows.

/autohotkey.com/board/topic/51221-windows-7-problem-gui-disappears-after-setparent/?p=320318

Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen

Posted: 15 May 2018, 00:57
by iseahound
rhinox202 wrote:.
kunkel321 wrote:.
UPDATE: I added a Desktop() function that will draw behind the Desktop icons, effectively on your desktop wallpaper. I believe this only works on windows 8 and windows 10. However, this is very hacky code, since it uses undocumented windows functions. I'd like confirmation if anyone tests the .Desktop() function. What version of windows does it work on? If you want to clear drawings on the desktop, you'll have to call .Destroy() or it will persist until you sign out. It goes without saying that .Desktop() must be called before .Render(). I also noticed that the text disappears when Winows + Tab is pressed...
Additional stuff I added: .Normal() - this disables AlwaysONTop and .Bottom() which send the window to the bottom of the z-order or beneath all other windows.

Code: Select all

#include <Subtitle>

a := new Subtitle().Desktop()
a.Render("While I stood in the heavy, never-ending rain, I forgot how to smile...", "x:center y:83% c:Off", "s:52.7 f:(Garamond) color:White outline:(stroke:1 glow:4 tint:Black) dropShadow:(blur:5px color:White opacity:0.5 size:15)")
return
or in one giant line:

Code: Select all

#include <Subtitle>
(new Subtitle()).Desktop().Render("While I stood in the heavy, never-ending rain, I forgot how to smile...", "x:center y:83% c:Off", "s:52.7 f:(Garamond) color:White outline:(stroke:1 glow:4 tint:Black) dropShadow:(blur:5px color:White opacity:0.5 size:15)")

Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen

Posted: 15 May 2018, 08:22
by kunkel321
Oh wow! Thanks so much for adding this Iseahound! I will definitely try this.
Warning: Newbie questions coming ;)

Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen

Posted: 16 May 2018, 19:33
by Guest_5162018
The Desktop() function doesn't seem to work for me. It appears that nothing is rendered. Running Windows 10 v1709 (16299.402). The Bottom() function however works great. Thanks for the update.

Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen

Posted: 17 May 2018, 13:32
by kunkel321
It does seem to work for me on Windows 10.
First I had to remember to update the Subtitle.ahk file in my /lib/ folder though :)

And yes--it's all the way at the bottom... Even below my other text that is pinned to the Desktop!

Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen

Posted: 17 May 2018, 14:24
by kunkel321
Question: Is it possible to have separate bits of text drawn to the Desktop?

Ah ha. I see now that it was the second "new" command that was easing the first part... Which seems like a no-brainer to me now. :mrgreen:

The second question is still open though...
Bigger Top Line.
Smaller, second line...

Code: Select all

#NoEnv
#SingleInstance force
#include <Subtitle>

a := new Subtitle().Desktop()
a.Draw("Bigger, Top Line.", "x:50 y:10% c:Off", "s:52.7 f:(Calibri) color:White outline:(stroke:1 glow:4 tint:Black) dropShadow:(blur:5px color:White opacity:0.5 size:15)")
;a.Save()
;a := new Subtitle().Desktop()
a.Draw("Smaller, second line...", "x:50 y:20% c:Off", "s:24 f:(Calibri) color:White outline:(stroke:1 glow:4 tint:Black) dropShadow:(blur:5px color:White opacity:0.5 size:15)")
a.Render()

return
As you might guess, it draws the first part, then replaces it with the second. I'd like them both to stay. Thoughts?

EDIT: Actually, I might be using the wrong setup altogether...
I expect this to work:

Code: Select all

#NoEnv
#SingleInstance force
#include <Subtitle>

myVar = "This is my content"
a := new Subtitle().Desktop()
a.Draw(%myVar%, "x:50 y:10% c:Off", "s:52.7 f:(Calibri) color:White outline:(stroke:1 glow:4 tint:Black) dropShadow:(blur:5px color:White opacity:0.5 size:15)")
a.Render()

return
...but it does not. This tells me I need to re-read the AHK documentation about using custom Functions(). Correct?

Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen

Posted: 17 May 2018, 22:37
by iseahound

Code: Select all

#NoEnv
#SingleInstance force
#include <Subtitle>

myVar := "This is my content"
a := new Subtitle().Desktop()
a.Draw(myVar, "x:50 y:10% c:Off", "s:52.7 f:(Calibri) color:White outline:(stroke:1 glow:4 tint:Black) dropShadow:(blur:5px color:White opacity:0.5 size:15)")
a.Render()

return
Remove the percent signs and use the colon equal :=. Regular equal is deprecated for assignment.

Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen

Posted: 18 May 2018, 16:38
by kunkel321
Thanks Iseahound!
I thought I had tried that permutation--but I guess not.

Tip for anyone using different font colors:
Iseahound seems to have made subtitle.ahk observant of all the CSS colors, by common name. They are listed here, if you're not sure what colors the names correspond to.
Inconspicuous edit: I don't want to highjack iseahound's thread, so I'll put this as an edit here: ColorWarlock is a cool freebie by DonationCoder member Carroll. It also lists the names of those colors. Pretty cool tool. Probably overkill for a lot of people though.

Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen

Posted: 18 May 2018, 16:44
by burque505
Thanks, kunkel321, that's a very handy link. Straight to Evernote :)
Regards,
burque505

Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen

Posted: 18 May 2018, 17:13
by kunkel321
burque505 wrote:Straight to Evernote :)
:thumbup:

New question:
What is the proper syntax for using a variable in place of the font color?
You can see here, where I've tried a couple of different things that don't work.

Code: Select all

#NoEnv ;NOT WORKING
#SingleInstance force
#include <Subtitle>

varTop := "Top line here"
varBot := "Bottom line here"
varColor := "Green"
;fontColor := "s:50 f:(Calibri) color:" . varColor . "outline:(stroke:1 glow:2 tint:Black) dropShadow:(blur:5px color:White opacity:0.5 size:8)"

a := new Subtitle().Desktop()
;a.Draw(varTop, "x:1100 y:100 c:Off", fontColor)
a.Draw(varBot, "x:1150 y200 c:Off", "s:50 f:(Calibri) color:%varColor% outline:(stroke:1 glow:2 tint:Black) dropShadow:(blur:5px color:White opacity:0.5 size:8)")
;a.Draw(varBot, "x:1150 y200 c:Off", "s:50 f:(Calibri) color:Cyan outline:(stroke:1 glow:2 tint:Black) dropShadow:(blur:5px color:White opacity:0.5 size:8)")

a.Render()

return
; https://css-tricks.com/snippets/css/named-colors-and-hex-equivalents/

Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen

Posted: 18 May 2018, 21:29
by iseahound

Code: Select all

#include <Subtitle>

varBot := "Bottom line here"
varColor := "Green"

; String Notation
;a := new Subtitle().Desktop()
;a.Draw(varBot, "x:1150 y200 c:Off", "s:50 f:(Calibri) color:" varColor " outline:(stroke:1 glow:2 tint:Black) dropShadow:(blur:5px color:White opacity:0.5 size:8)")
;a.Render()

; Preferred Object Notation
a := new Subtitle().Desktop()
backgroundstyle := {"x":1150, "y":200, "c":"Off"}
textstyle := {"size":50, "font":"Calibri", "color":varColor, "outline":{"stroke":1, "glow":2, "tint":"Black"}, "dropShadow":{"blur":"5px", "color":"White", "opacity":0.5, "size":8}}
a.Render(varBot, backgroundstyle, textstyle)

; Change the Text color after 3 seconds
Sleep 3000
a.Destroy()                                        ; Desktop() is buggy so you need these two lines :(
a := new Subtitle().Desktop()             ; Make new one
textstyle.color := "Cyan"
a.Render(varBot, backgroundstyle, textstyle)
return
Take a look at Tutorial 2 which shows how to use Object notation. https://github.com/iseahound/Subtitle/b ... tation.ahk If you are confused as to why there are two types of notation it's because String notation is used when the styles are static and unchanging. If values are changing over time, it's best to use Object Notation.

EDIT: Also you're probably right that I need to update the tutorials to reflect this distinction. I should make tutorial #2 have a rainbow glowing effect over time. If you're up to the challenge you can set up a pull request on Github, or just give it a try and post it here.

EDIT2: Eh, the Desktop() function is really buggy. It's not consistent on all versions of Windows and disappears after Win + Tab is pressed. Still experimental, not sure if it should be removed or kept.

Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen

Posted: 19 May 2018, 09:46
by kunkel321
iseahound wrote:EDIT2: Eh, the Desktop() function is really buggy. It's not consistent on all versions of Windows and disappears after Win + Tab is pressed. Still experimental, not sure if it should be removed or kept.
Kept please! :D

Thanks for the tips! Yes, I had noticed that there are fundamentally different ways to use external functions, so it's good to note the difference between Object Notation and the other.

I did try to tweak Tutorial #2, but I've not done it correctly.

Code: Select all

#NoEnv 
#SingleInstance force
#include <Subtitle>
; BELOW CODE NOT WORKING
text := {}
text.font := "Gill Sans MT Condensed"
text.size := "6vh"
text.outline := {}
text.outline.stroke := "1 px"
text.outline.color := "Black"
text.outline.glow := "5px"
text.outline.tint := "FF6347"  ;red
text.color := "White"

background := {}
background.color := "Transparent"
background.x := "center"
background.y := "40vh"

Subtitle.Render("ta mère est une fleure rare que t'abreuve par ton amour", background, text)

Sleep 1000
text.outline.tint := "F4A460"  ;orange
Subtitle.Render("ta mère est une fleure rare que t'abreuve par ton amour", background, text)

Sleep 1000
text.outline.tint := "F0E68C" ;yellow
Subtitle.Render("ta mère est une fleure rare que t'abreuve par ton amour", background, text)

Sleep 1000
text.outline.tint := "F0E68C" ;green
Subtitle.Render("ta mère est une fleure rare que t'abreuve par ton amour", background, text)

Sleep 1000
text.outline.tint := "AFEEEE" ;blue
Subtitle.Render("ta mère est une fleure rare que t'abreuve par ton amour", background, text)

Sleep 1000
text.outline.tint := "D8BFD8" ;purple
Subtitle.Render("ta mère est une fleure rare que t'abreuve par ton amour", background, text)

return
I tried inserting

Code: Select all

a.Destroy()                                
a := new Subtitle()
after each sleep command, but that was not right either.

Note: Another glitchy thing with the .Desktop() feature is that after the sleep, the second .Render causes my desktop wallpaper image to get painted over with black. Win+Tab restores the picture though. For my own purposes, I'll have a single render onto my desktop, then it won't get changed unless I re-start the script. Also, I don't typically use Win+Tab, so none of the glitches effect me.

EDIT: Actually this version of Tutorial 2 does work!
I have a strong suspicion that is it unnecessarily kludgy though! :mrgreen:

Code: Select all

#NoEnv
#SingleInstance force
#include <Subtitle>

text := {}
text.font := "Gill Sans MT Condensed"
text.size := "6vh"
text.outline := {}
text.outline.stroke := "1 px"
text.outline.color := "Black"
text.outline.glow := "5px"
text.outline.tint := "FF6347"  ;Red
text.color := "White"
text.time := "1500"

background := {}
background.color := "Transparent"
background.x := "center"
background.y := "40vh"

Subtitle.Render("Ta mère est belle comme l'arc-en-ciel.", background, text)
Sleep, 1500

text := {}
text.font := "Gill Sans MT Condensed"
text.size := "6vh"
text.outline := {}
text.outline.stroke := "1 px"
text.outline.color := "Black"
text.outline.glow := "5px"
text.outline.tint := "FFA500"  ;Orange
text.color := "White"
text.time := "1500"

background := {}
background.color := "Transparent"
background.x := "center"
background.y := "40vh"

Subtitle.Render("Ta mère est belle comme l'arc-en-ciel.", background, text)
Sleep, 1500

text := {}
text.font := "Gill Sans MT Condensed"
text.size := "6vh"
text.outline := {}
text.outline.stroke := "1 px"
text.outline.color := "Black"
text.outline.glow := "5px"
text.outline.tint := "FFFF00"  ;Yellow
text.color := "White"
text.time := "1500"

background := {}
background.color := "Transparent"
background.x := "center"
background.y := "40vh"

Subtitle.Render("Ta mère est belle comme l'arc-en-ciel.", background, text)
Sleep, 1500
text := {}
text.font := "Gill Sans MT Condensed"
text.size := "6vh"
text.outline := {}
text.outline.stroke := "1 px"
text.outline.color := "Black"
text.outline.glow := "5px"
text.outline.tint := "008000"  ;Green
text.color := "White"
text.time := "1500"

background := {}
background.color := "Transparent"
background.x := "center"
background.y := "40vh"

Subtitle.Render("Ta mère est belle comme l'arc-en-ciel.", background, text)
Sleep, 1500
text := {}
text.font := "Gill Sans MT Condensed"
text.size := "6vh"
text.outline := {}
text.outline.stroke := "1 px"
text.outline.color := "Black"
text.outline.glow := "5px"
text.outline.tint := "0000FF"  ;Blue
text.color := "White"
text.time := "1500"

background := {}
background.color := "Transparent"
background.x := "center"
background.y := "40vh"

Subtitle.Render("Ta mère est belle comme l'arc-en-ciel.", background, text)
Sleep, 1500
text := {}
text.font := "Gill Sans MT Condensed"
text.size := "6vh"
text.outline := {}
text.outline.stroke := "1 px"
text.outline.color := "Black"
text.outline.glow := "5px"
text.outline.tint := "8A2BE2"  ;BlueViolet
text.color := "White"
text.time := "1500"

background := {}
background.color := "Transparent"
background.x := "center"
background.y := "40vh"

Subtitle.Render("Ta mère est belle comme l'arc-en-ciel.", background, text)
Sleep, 1500

return
Also it "flashes" between displaying the different colors, which might be due to my kludginess....

Attempting to post gif:
Image
may need to refresh browser
https://content.screencast.com/users/st ... -14.33.gif

EDIT 2: It's supposed to say, "Your mother is a beautiful rainbow." Hopefully this doesn't translate to an insult in French. :rainbow:

EDIT 3: I think that I have my wallpaper display tool set the way I like it. :D
Weekday, date, default Windows printer, then the content from a text file.
Image