[GDI+ Object] Subtitle.Render() - Beautiful Text on Screen
Re: Subtitle.Render() - Beautiful Text on Screen
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
Updated RegEx to be much more efficient. Also Subtitles can be made draggable like this:
This feature is experimental and will change at any time. When it is finalized, I'll add a new tutorial.
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
Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen
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
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
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
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
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.
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.
EDIT: Actually, I did get this to go to the bottom:
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!
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
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
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!
ste(phen|ve) kunkel
Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen
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()
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
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
/autohotkey.com/board/topic/51221-windows-7-problem-gui-disappears-after-setparent/?p=320318
Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen
rhinox202 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...kunkel321 wrote:.
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
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
Oh wow! Thanks so much for adding this Iseahound! I will definitely try this.
Warning: Newbie questions coming
Warning: Newbie questions coming
ste(phen|ve) kunkel
Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen
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
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!
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!
ste(phen|ve) kunkel
Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen
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.
The second question is still open though...
Bigger Top Line.
Smaller, second line...
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:
...but it does not. This tells me I need to re-read the AHK documentation about using custom Functions(). Correct?
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.
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
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
ste(phen|ve) kunkel
Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen
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
Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen
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.
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.
ste(phen|ve) kunkel
Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen
Thanks, kunkel321, that's a very handy link. Straight to Evernote
Regards,
burque505
Regards,
burque505
Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen
burque505 wrote:Straight to Evernote
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/
ste(phen|ve) kunkel
Re: [GDI+ Object] Subtitle.Render() - Beautiful Text on Screen
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
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
Kept please!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.
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
Code: Select all
a.Destroy()
a := new Subtitle()
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!
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
Attempting to post gif:
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.
EDIT 3: I think that I have my wallpaper display tool set the way I like it.
Weekday, date, default Windows printer, then the content from a text file.
ste(phen|ve) kunkel
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: No registered users and 66 guests