I am trying to make a way to show text on the computer without having to use msgbox, since this sleeps the script until I press ok.
Splashtext needs me to set size dimentions...
Various Gui Scripts like PleasantNotify can show text and fade well but also need to resize.
What would be the best way to display messages from 5 letters to say 200 letters? consistently without pausing the script.
Showing Text without msgbox or splashtext.
Re: Showing Text without msgbox or splashtext.
The simplest way, I think, is to create a dynamic SplashText. If your screen is 1920 x 1080, try this function:fenchai wrote: ↑17 Oct 2018, 23:37I am trying to make a way to show text on the computer without having to use msgbox, since this sleeps the script until I press ok.
Splashtext needs me to set size dimentions...
Various Gui Scripts like PleasantNotify can show text and fade well but also need to resize.
What would be the best way to display messages from 5 letters to say 200 letters? consistently without pausing the script.
Code: Select all
text(a,t:="",x:="",y:="") {
c:=d:=e:=0, strReplace(a,"`n",,b), g:=strSplit(a,"`n","`r")[1], strReplace(g," ",,h)
While !(f="" && a_index<>1) {
f := subStr(g,a_index,1)
(regExMatch(f, "[a-z]") ? c++ : f="@" ? e++ : d++)
} SplashTextOn, % 8 + c*6.5 + d*12 + e*13 - h*8, % 23 + b*20, ::*::, % a
If (x<>"" || y<>"")
WinMove, ::*::,, x, y
If (t<>"") {
Sleep, t*1000
WinClose, ::*::
}}
Code: Select all
text("this is a single line example for 2 seconds",2)
text("this is a three line `nexample `nfor 3 seconds",3)
text("the next will show at the TOP LEFT",2)
text("this text at the beggining of the screen",2,0,0)
text("the next will show at the TOP CENTER",2)
text("this text at the top center of the screen",2,a_screenwidth/2,0)
text("the next will show 200 characters",4)
a=
(
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ornare a lectus at volutpat.
Nunc a tempus metus, et venenatis turpis. Mauris lobortis semper risus.
Fusce vel elementum nibh. Donec sed.
)
text(a,2)
text(a,t:="",x:="",y:="") {
c:=d:=e:=0, strReplace(a,"`n",,b), g:=strSplit(a,"`n","`r")[1], strReplace(g," ",,h)
While !(f="" && a_index<>1) {
f := subStr(g,a_index,1)
(regExMatch(f, "[a-z]") ? c++ : f="@" ? e++ : d++)
} SplashTextOn, % 8 + c*6.5 + d*12 + e*13 - h*8, % 23 + b*20, ::*::, % a
If (x<>"" || y<>"")
WinMove, ::*::,, x, y
If (t<>"") {
Sleep, t*1000
WinClose, ::*::
}}
• AutoSize.
• Delay after showing in seconds, then close (see examples). Omit for no delay, and no close.
• Move around the screen (x,y coordinates). Omit for default center screen.
Cons:
• Takes 31ms to run (due to regExMatch).
• The "width" is in function of the first line.
• 1920 x 1080 screen.
→ to change it, you need to manually modify the pixel size per character at this line:
Code: Select all
} SplashTextOn, % 8 + c*6.5 + d*12 + e*13 - h*8, % 23 + b*20, ::*::, % a
https://autohotkey.com/boards/viewtopic.php?t=13180
Last edited by eqv on 18 Oct 2018, 14:51, edited 2 times in total.
Re: Showing Text without msgbox or splashtext.
Really great function! how do I know which pixel size per character fits my screen? is there a converter or I need to brute test it?
- SpeedMaster
- Posts: 494
- Joined: 12 Nov 2016, 16:09
Re: Showing Text without msgbox or splashtext.
You may also try Subtitle.Render() (by iseahound)
topic: https://autohotkey.com/boards/viewtopic.php?f=6&t=36384
download: https://github.com/iseahound/Subtitle
topic: https://autohotkey.com/boards/viewtopic.php?f=6&t=36384
download: https://github.com/iseahound/Subtitle
Re: Showing Text without msgbox or splashtext.
I personally brute force it because I find it easier. You could try creating a function, according to the screen size (A_ScreenWidth, A_ScreenHeight are built-in variables).
Code: Select all
} SplashTextOn, % 8 + c*6.5 + d*12 + e*13 - h*8, % 23 + b*20, ::*::, % a
• e = big characters [13 pxiels]. • d = the rest [12 pixels].
• h = Spaces (reduce, because they are really small) [8 pixels].
Cheers,
(also check SpeedMaster suggestion for more advance features)
Re: Showing Text without msgbox or splashtext.
Here's a simpler and 'prettier' approach...
Check my sig, if your' looking for approaches that retain previous output.... Cheers.
Code: Select all
; if overwritePrevious param is true, then subsequent calls will now wait for previous notification to fade out,else they will as subsequent examples below show
GuiSplash("I am the long lost and Userper..........................................feed me!", 1,,"fast", 1,"Terminal") ;renews gui for new text
GuiSplash("I am the long lost and Userper..........................................feed me more!", 1,,"fast", 1,"Terminal") ;renews gui for new text
GuiSplash("I am the long lost and Userper..........................................i said more!!!!!!!!!", 1,,"fast", 1,"Terminal") ;renews gui for new text
GuiSplash("I am the long lost and Userper..........................................now fear me!", 1,,"fast", 1,"Terminal") ;renews gui for new text
While !GetKeyState("LCtrl")
GuiSplash("Press and Hold Left Control to Skip This fast Notification", 1,,"fast",,"Terminal")
While !GetKeyState("RCtrl")
GuiSplash("Press and Hold Right Control to Skip This slow Notification", 1,,,,"Terminal")
GuiSplash("I'm really super fast!", 2, ,"fast")
GuiSplash("I am the long lost and Userper..........................................fear me!", 1,,"fast", 1,"Terminal") ;renews gui for new text
GuiSplash("I go nice and slow")
GuiSplash("I am the Userper", , , , 1) ;renews gui for new text
GuiSplash(guiText, guiTimeOutSec:=5, maxTransparency:=200,fadeSpeed:="", overwritePrevious:="", font:="Verdana"){ ;
Static
guiTitle:="thisGUI"
If !overwritePrevious ;a gui with overwritePrevious set to 1 will update gui text instead of waiting for previous gui to timeout
While WinExist(guiTitle) ;if another gui is active wait until it's destroyed
Sleep 10
Else ;destroying gui instead of using control text,as that would require gui be resized to accommodate larger text blocks...
GoSub, guiDestroy
Gui, Color, 000000
Gui, +ToolWindow -Caption +AlwaysOnTop
Gui, Font, S15 w700, %font%
Gui, Add, Text, cWhite vText1, %guiText%
;create gui offscreen to hide flash
yOffscreen := 100000 ;way off screen
Gui, Show,Hide x0 y%yOffscreen% NA, %guiTitle%
WinSet, TransColor, 000000, %guiTitle%
WinSet, Transparent, 0, %guiTitle%
Gui, Show,x0 y400 NA, %guiTitle% ;redraw gui
Loop, %maxTransparency% ;fade in
{
WinSet, Transparent, %A_Index%, %guiTitle%
IfNotEqual, fadeSpeed, fast
Sleep 10
}
;for fade out
Static staticGuiTitle,staticMaxTransparency,staticFadeSpeed
staticGuiTitle := guiTitle
staticMaxTransparency := maxTransparency
staticFadeSpeed := fadeSpeed
SetTimer, guiDestroy, % guiTimeOutSec * 1000
Return
guiDestroy:
Loop, %staticMaxTransparency% ;fade out
{
WinSet, Transparent, % staticMaxTransparency - A_Index , %staticGuiTitle%
IfNotEqual, staticFadeSpeed, fast
Sleep 10
}
Gui, Destroy
SetTimer, guiDestroy, off
Return
}
Check my sig, if your' looking for approaches that retain previous output.... Cheers.
live ? long & prosper : regards