-
Notifications
You must be signed in to change notification settings - Fork 11
Tips & Tricks
Edison Hua edited this page May 31, 2022
·
37 revisions
- Create temporary instances of TextRender by setting the time.
TextRender("hello world!", "time:3000 color:MintCream")
- Use object notation when working with variables.
MyColor := "Blue"
TextRender("Alert!", {time:3000, color: MyColor})
- Object Notation extends to nested elements as well.
tr := TextRender("Und über uns ziehen lila Wolken in die Nacht"
, {color: "#F9E27E"}
, {font: "Century Gothic"
, size: 60
, color: "#F88958"
, outline: [5, "Indigo"]
, dropShadow: {horizontal: 5
, vertical: 5
, blur: 0
, color: "#009DA7"}})
- Methods can be chained, as in
tr.Draw("1").Draw("2").Render("3")
for short one liners. - Reduce memory usage by over 60% with
FreeMemory()
. Best if called after Render(). - Stop text from being cut off? Use
RenderOnScreen()
instead of Render(). - 2x Speed Up: Place
SetBatchLines -1
at the top of your script. (AutoHotkey v1 only)
- Setting the quality of the text to ClearType will improve the overall look of the text on mostly opaque backgrounds. By default, ClearType is only enabled when the background color is completely opaque. Example:
q:5
- Increase the readability without increasing font size, by setting the outline stroke to 1. This creates a pseudo-bold effect. For small font sizes, it will decrease the space between letters, saving you on-screen real estate! Example:
outline:(stroke:1px)
oro:(1px)
- Use an alternative rendering process by setting the outline stroke to 0 pixels. Whether this is an improvement depends on the font and font size used. Example:
outline:(stroke:0px)
oro:(0px)
- Speed up text rendering by setting the text quality to 0. This will disable anti-aliasing. Create a cool stencil effect with
quality:0 color:None outline:(stroke:1px color:Black)
! - Avoid using the glow parameter in outline. It's very slow and will delay your render time. If you must use it, choose an number less than 5px. Anything more will slow down your script exponentially.
- Create a interesting effect by making the text "eat" through the background. Use
color:Delete
orcolor:Erase
as the text color. - If the text color is omitted, it defaults to white or black depending on the background color!
- The text position can be independent of the background. Use x and y to position your text off the background box.
- If you want to set the background to be transparent, you can use
c:None
,c:Off
,c:Clear
, orc:Transparent
. Don't usew:0
orh:0
. Even though they work - they act weird changing your x and y positions. - A random color can help keep your background boxes fresh. Try
color:Random2
for a random solid color.
- Although text cannot be rendered off screen with
Render()
, the whole picture can be recovered withSave()
,RenderToBitmap()
, andRenderToHBitmap()
. -
RenderOnScreen()
will render the entire canvas. Although it preforms slower thanRender()
, it is optimized to fall back toRender()
when the entire object is in the visible screen area. It's the best of both worlds! - Using
RenderOnScreen()
may cause objects to be mispositioned. That's whyRender()
is the default. - Save() must be called after Render(), or subsequent drawing operations will have cleared what is being saved.
- The window handle can be retrieved with
tr.hwnd
. -
tr.x
,tr.y
, may be inaccurate when it comes to off screen coordinates. To retrieve the exact coordinates tryWindowLeft
,WindowTop
,WindowRight
,WindowBottom
,WindowWidth
, andWindowHeight
. If the user has moved the window you will have to use WinGetPos instead. - Use
Flush()
to finalize the graphics buffer without displaying to the screen. - You must clean up any pointers returned by
CopyToBitmap()
andRenderToBitmap()
withDllCall("gdiplus\GdipDisposeImage", "ptr", pBitmap)
. Likewise forCopyToHBitmap()
andRenderToHBitmap()
,DllCall("DeleteObject", "ptr", hbm)
must be called. - Use
tr.status
to check if the graphics buffer has changed. Usetr.Hash()
to check if two graphics buffer pixel data are identical.