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

Post your working scripts, libraries and tools
iseahound
Posts: 239
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

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

17 Apr 2018, 13:07

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.
iseahound
Posts: 239
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

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

06 May 2018, 21:24

Updated RegEx to be much more efficient. Also Subtitles can be made draggable like this:

Code: [Select all] [Download] GeSHi © Codebox Plus

#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.
guest592018

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

09 May 2018, 20:03

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.
iseahound
Posts: 239
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

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

10 May 2018, 17:41

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.
rhinox202
Posts: 9
Joined: 30 Sep 2015, 10:22

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

10 May 2018, 20:38

That works. That wasn't in the documentation... should have looked in the code. Thank you!
iseahound
Posts: 239
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

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

11 May 2018, 02:51

Yeah, it's badly documented... .AlwaysOnTop() is a toggle. .ClickThrough() to make the window clickthrough is a toggle as well. To toggle visibility .ToggleVisible()
kunkel321
Posts: 162
Joined: 30 Nov 2015, 21:19
Facebook: https://www.facebook.com/kunkel321
Google: kunkel321

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

11 May 2018, 16:57

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] [Expand] [Download] (Untitled.ahk)GeSHi © Codebox Plus



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] [Download] (Untitled.ahk)GeSHi © Codebox Plus

#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:
iseahound
Posts: 239
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

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

11 May 2018, 17:20

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()
iseahound
Posts: 239
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

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

11 May 2018, 17:59

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
iseahound
Posts: 239
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

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

15 May 2018, 00:57

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] [Download] GeSHi © Codebox Plus

#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] [Download] GeSHi © Codebox Plus

#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)")
kunkel321
Posts: 162
Joined: 30 Nov 2015, 21:19
Facebook: https://www.facebook.com/kunkel321
Google: kunkel321

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

15 May 2018, 08:22

Oh wow! Thanks so much for adding this Iseahound! I will definitely try this.
Warning: Newbie questions coming ;)
Guest_5162018

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

16 May 2018, 19:33

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.
kunkel321
Posts: 162
Joined: 30 Nov 2015, 21:19
Facebook: https://www.facebook.com/kunkel321
Google: kunkel321

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

17 May 2018, 13:32

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!
kunkel321
Posts: 162
Joined: 30 Nov 2015, 21:19
Facebook: https://www.facebook.com/kunkel321
Google: kunkel321

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

17 May 2018, 14:24

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] [Expand] [Download] (Untitled.ahk)GeSHi © Codebox Plus



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] [Download] (Untitled.ahk)GeSHi © Codebox Plus

#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?
iseahound
Posts: 239
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

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

17 May 2018, 22:37

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Remove the percent signs and use the colon equal :=. Regular equal is deprecated for assignment.
kunkel321
Posts: 162
Joined: 30 Nov 2015, 21:19
Facebook: https://www.facebook.com/kunkel321
Google: kunkel321

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

18 May 2018, 16:38

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.
Last edited by kunkel321 on 19 May 2018, 11:12, edited 1 time in total.
burque505
Posts: 516
Joined: 22 Jan 2017, 19:37

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

18 May 2018, 16:44

Thanks, kunkel321, that's a very handy link. Straight to Evernote :)
Regards,
burque505
kunkel321
Posts: 162
Joined: 30 Nov 2015, 21:19
Facebook: https://www.facebook.com/kunkel321
Google: kunkel321

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

18 May 2018, 17:13

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] [Expand] [Download] (Untitled.ahk)GeSHi © Codebox Plus

iseahound
Posts: 239
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

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

18 May 2018, 21:29

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



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.
kunkel321
Posts: 162
Joined: 30 Nov 2015, 21:19
Facebook: https://www.facebook.com/kunkel321
Google: kunkel321

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

19 May 2018, 09:46

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] [Expand] [Download] (Untitled.ahk)GeSHi © Codebox Plus



I tried inserting

Code: [Select all] [Download] (Untitled.ahk)GeSHi © Codebox Plus

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] [Expand] [Download] (Untitled.ahk)GeSHi © Codebox Plus


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

Return to “Scripts and Functions”

Who is online

Users browsing this forum: arcticir and 9 guests