How to display a pop-up number on the screen Topic is solved
How to display a pop-up number on the screen
draw a circle around the number would be better like ③
Re: How to display a pop-up number on the screen
Hallo,
perhaps:
Or would you like to vary this countdown?:
perhaps:
Code: Select all
q::
Gui, Font, s200 cRed
Gui, add, text,, ③
Gui, -Caption +LastFound +ToolWindow +AlwaysOnTop
WinSet, TransColor, F0F0F0
Gui, show, Center
Return
Code: Select all
q::CountDown(9,200,200,400,2000)
Return
CountDown(No,X:=0,Y:=0,Dia:=100,Time_No:=1000)
{ ; StartNumber(<1000), Position X,Y, Diameter, Time(>300)/(ms Number)
Static N, Colors:=["Blue","Yellow"], SF:= [.60,.44,.31], YF:= [-.06,.08,.22]
NL := StrLen(N:=Round(No)), Rad := Dia//2, V := 3*Time_No//100
dP := 8*Atan(1)/V++, Gui := 1, T := A_TickCount + Time_No*N
Loop, 2
{
Gui, %A_Index%CD:New, -DPIScale +LastFound -Caption -SysMenu
Gui, Margin, 0, 0
Gui, Font,% "s" Dia*SF[NL] " c" Colors[A_Index]
Gui, Add, Text,% "Center X0 Y" Dia*YF[NL] " w" Dia " h" 2*Dia " vN",% N
Gui, Color,% Colors[3-A_Index]
WinSet, Region,% "2-2 W" Dia-4 " H" Dia-4 " E"
Gui, Show, NA w%Dia% h%Dia% x%X% y%Y%
}
While, N
{
Gui,% (Gui^=3) "CD: +AlwaysOnTop +LastFound"
Edge:= Rad "-" Rad, P:= -dP
Loop,% V
{
WinSet, Region,% Edge.=" " Rad*(1+sin(P+=dP)) "-" Rad*(1-cos(P))
Sleep,% (T-A_TickCount)//(1+N*V-A_Index)
}
GuiControl, 1CD: Text, N,% --N
GuiControl, 2CD: Text, N,% N
IF StrLen(N) < NL
{
Gui, 1CD:Font,% "s" Dia*SF[--NL]
GuiControl, 1CD: Font, N
GuiControl, 1CD: Move, N ,% "y" Dia*YF[NL]
Gui, 2CD:Font,% "s" Dia*SF[NL]
GuiControl, 2CD: Font, N
GuiControl, 2CD: Move, N ,% "y" Dia*YF[NL]
}
}
Gui, 1CD: Destroy
Gui, 2CD: Destroy
Return
}
Re: How to display a pop-up number on the screen
Gdip is good for this type of thing.
Code: Select all
;***************************************************************************************************
;***************************************************************************************************
#Include <My Altered Gdip Lib> ;<------ Replace with your copy of GDIP
#Include <LayeredWindow Class> ;<----- https://www.autohotkey.com/boards/viewtopic.php?f=6&t=72588
;***************************************************************************************************
;***************************************************************************************************
#SingleInstance,Force
OnExit,*ESC
Gosub,Numpad1
return
Numpad1::
(MyWindow)?(MyWindow.DeleteWindow(1),MyWindow := "")
MyWindow := New LayeredWindow( "", "", 100, 100, 1, " ", 2, "+AlwaysOnTop -DPISCale +toolWindow", 1, 1, {x:0,y:0,w:100,h:100})
Pen1 := Gdip_CreatePen(0xFF000000, 2),Brush1 := Gdip_BrushCreateSolid(0xff0088AA),Brush2 := Gdip_BrushCreateSolid(0xFFFFFFFF),Brush3 := Gdip_BrushCreateSolid(0xFF000000)
Gdip_FillEllipse( MyWindow.G, Brush1, 0, 0, 98, 98)
Gdip_DrawEllipse( MyWindow.G, Pen1, 0, 0, 98, 98)
Gdip_TextToGraphics( MyWindow.G , "3" , "s72 Center vCenter Bold c" Brush3 " x-2 y2", "Arial" , 98 , 98 )
Gdip_TextToGraphics( MyWindow.G , "3" , "s72 Center vCenter Bold c" Brush2 " x0 y4", "Arial" , 98 , 98 )
Gdip_DeletePen(Pen1),Gdip_DeleteBrush(Brush1),Gdip_DeleteBrush(Brush2),Gdip_DeleteBrush(Brush3)
MyWindow.UpdateWindow()
return
*ESC::
MyWindow.DeleteWindow(1)
ExitApp
Re: How to display a pop-up number on the screen
some questions about the CountDown function, how to change the number range (when the number greater than 1000 it does work) and size.Rohwedder wrote: ↑14 Jun 2020, 08:10Hallo,
perhaps:Or would you like to vary this countdown?:Code: Select all
q:: Gui, Font, s200 cRed Gui, add, text,, ③ Gui, -Caption +LastFound +ToolWindow +AlwaysOnTop WinSet, TransColor, F0F0F0 Gui, show, Center Return
Code: Select all
q::CountDown(9,200,200,400,2000) Return CountDown(No,X:=0,Y:=0,Dia:=100,Time_No:=1000) { ; StartNumber(<1000), Position X,Y, Diameter, Time(>300)/(ms Number) Static N, Colors:=["Blue","Yellow"], SF:= [.60,.44,.31], YF:= [-.06,.08,.22] NL := StrLen(N:=Round(No)), Rad := Dia//2, V := 3*Time_No//100 dP := 8*Atan(1)/V++, Gui := 1, T := A_TickCount + Time_No*N Loop, 2 { Gui, %A_Index%CD:New, -DPIScale +LastFound -Caption -SysMenu Gui, Margin, 0, 0 Gui, Font,% "s" Dia*SF[NL] " c" Colors[A_Index] Gui, Add, Text,% "Center X0 Y" Dia*YF[NL] " w" Dia " h" 2*Dia " vN",% N Gui, Color,% Colors[3-A_Index] WinSet, Region,% "2-2 W" Dia-4 " H" Dia-4 " E" Gui, Show, NA w%Dia% h%Dia% x%X% y%Y% } While, N { Gui,% (Gui^=3) "CD: +AlwaysOnTop +LastFound" Edge:= Rad "-" Rad, P:= -dP Loop,% V { WinSet, Region,% Edge.=" " Rad*(1+sin(P+=dP)) "-" Rad*(1-cos(P)) Sleep,% (T-A_TickCount)//(1+N*V-A_Index) } GuiControl, 1CD: Text, N,% --N GuiControl, 2CD: Text, N,% N IF StrLen(N) < NL { Gui, 1CD:Font,% "s" Dia*SF[--NL] GuiControl, 1CD: Font, N GuiControl, 1CD: Move, N ,% "y" Dia*YF[NL] Gui, 2CD:Font,% "s" Dia*SF[NL] GuiControl, 2CD: Font, N GuiControl, 2CD: Move, N ,% "y" Dia*YF[NL] } } Gui, 1CD: Destroy Gui, 2CD: Destroy Return }
Re: How to display a pop-up number on the screen
How to change the position and colour of the popup window. My number range is greater than 1000, when I change the number that greater than 10 it just show the first digit, also I want to pass the number as a parameter.Hellbent wrote: ↑14 Jun 2020, 13:05Gdip is good for this type of thing.
Code: Select all
;*************************************************************************************************** ;*************************************************************************************************** #Include <My Altered Gdip Lib> ;<------ Replace with your copy of GDIP #Include <LayeredWindow Class> ;<----- https://www.autohotkey.com/boards/viewtopic.php?f=6&t=72588 ;*************************************************************************************************** ;*************************************************************************************************** #SingleInstance,Force OnExit,*ESC Gosub,Numpad1 return Numpad1:: (MyWindow)?(MyWindow.DeleteWindow(1),MyWindow := "") MyWindow := New LayeredWindow( "", "", 100, 100, 1, " ", 2, "+AlwaysOnTop -DPISCale +toolWindow", 1, 1, {x:0,y:0,w:100,h:100}) Pen1 := Gdip_CreatePen(0xFF000000, 2),Brush1 := Gdip_BrushCreateSolid(0xff0088AA),Brush2 := Gdip_BrushCreateSolid(0xFFFFFFFF),Brush3 := Gdip_BrushCreateSolid(0xFF000000) Gdip_FillEllipse( MyWindow.G, Brush1, 0, 0, 98, 98) Gdip_DrawEllipse( MyWindow.G, Pen1, 0, 0, 98, 98) Gdip_TextToGraphics( MyWindow.G , "3" , "s72 Center vCenter Bold c" Brush3 " x-2 y2", "Arial" , 98 , 98 ) Gdip_TextToGraphics( MyWindow.G , "3" , "s72 Center vCenter Bold c" Brush2 " x0 y4", "Arial" , 98 , 98 ) Gdip_DeletePen(Pen1),Gdip_DeleteBrush(Brush1),Gdip_DeleteBrush(Brush2),Gdip_DeleteBrush(Brush3) MyWindow.UpdateWindow() return *ESC:: MyWindow.DeleteWindow(1) ExitApp
Re: How to display a pop-up number on the screen Topic is solved
I have moved the code to a function and you can pass the position, number, background color etc.
I also made the font size change based on the length of the number you pass it (alternatively you can just find the size that fits any number in your range and then just use that one for every number).
Code: Select all
;***************************************************************************************************
;***************************************************************************************************
#Include <My Altered Gdip Lib> ;<------ Replace with your copy of GDIP
#Include <LayeredWindow Class> ;<----- https://www.autohotkey.com/boards/viewtopic.php?f=6&t=72588
;***************************************************************************************************
;***************************************************************************************************
#SingleInstance,Force
OnExit,*ESC
global MyWindow
Gosub,Numpad1
return
Numpad1::
PopUpNumbers(100, 100, Ran(1,99999), "0xFF880000")
return
*ESC::
MyWindow.DeleteWindow(1)
ExitApp
PopUpNumbers(Posx := "" , Posy := "" , DisplayNumber := 1000, BackgroundColor := "0xFF336699", BorderColor := "0xFF000000", TextColorTop := "0xFFFFFFFF", TextColorBottom := "0xFF000000"){
(Strlen(DisplayNumber)=1)?(FS := 72):(Strlen(DisplayNumber)=2)?(FS := 48):(Strlen(DisplayNumber)=3)?(FS := 36):(Strlen(DisplayNumber)=4)?(FS := 28):(Strlen(DisplayNumber)=5)?(FS := 26)
(MyWindow)?(MyWindow.DeleteWindow(1),MyWindow := "")
MyWindow := New LayeredWindow( posx, posy, 100, 100, 1, " ", 2, "+AlwaysOnTop -DPISCale +toolWindow", 1, 1, {x:0,y:0,w:100,h:100})
Pen1 := Gdip_CreatePen(BorderColor, 2),Brush1 := Gdip_BrushCreateSolid(BackgroundColor),Brush2 := Gdip_BrushCreateSolid(TextColorTop),Brush3 := Gdip_BrushCreateSolid(TextColorBottom)
Gdip_FillEllipse( MyWindow.G, Brush1, 1, 1, 97, 97)
Gdip_DrawEllipse( MyWindow.G, Pen1, 1, 1, 97, 97)
Gdip_TextToGraphics( MyWindow.G , DisplayNumber , "s" FS " Center vCenter Bold c" Brush3 " x-2 y2", "Arial" , 98 , 98 )
Gdip_TextToGraphics( MyWindow.G , DisplayNumber , "s" FS " Center vCenter Bold c" Brush2 " x0 y4", "Arial" , 98 , 98 )
Gdip_DeletePen(Pen1),Gdip_DeleteBrush(Brush1),Gdip_DeleteBrush(Brush2),Gdip_DeleteBrush(Brush3)
MyWindow.UpdateWindow()
}
Ran(Min,Max){
Random, Out, Min, Max
return Out
}
Re: How to display a pop-up number on the screen
I have extended the function for numbers up to 9999. The size of the numbers changes with the Diameter.
Code: Select all
q::CountDown(1002,100,100,800,2000)
Return
CountDown(No,X:=0,Y:=0,Dia:=100,Time_No:=1000)
{ ; StartNumber(<10000), Position X,Y, Diameter, Time(>300)/(ms Number)
Static N, Colors:=["Blue","Yellow"], SF:= [.60,.44,.31,.25], YF:= [-.06,.08,.22,.27]
NL := StrLen(N:=Round(No)), Rad := Dia//2, V := 3*Time_No//100
dP := 8*Atan(1)/V++, Gui := 1, T := A_TickCount + Time_No*N
Loop, 2
{
Gui, %A_Index%CD:New, -DPIScale +LastFound -Caption -SysMenu
Gui, Margin, 0, 0
Gui, Font,% "s" Dia*SF[NL] " c" Colors[A_Index]
Gui, Add, Text,% "Center X0 Y" Dia*YF[NL] " w" Dia " h" 2*Dia " vN",% N
Gui, Color,% Colors[3-A_Index]
WinSet, Region,% "2-2 W" Dia-4 " H" Dia-4 " E"
Gui, Show, NA w%Dia% h%Dia% x%X% y%Y%
}
While, N
{
Gui,% (Gui^=3) "CD: +AlwaysOnTop +LastFound"
Edge:= Rad "-" Rad, P:= -dP
Loop,% V
{
WinSet, Region,% Edge.=" " Rad*(1+sin(P+=dP)) "-" Rad*(1-cos(P))
Sleep,% (T-A_TickCount)//(1+N*V-A_Index)
}
GuiControl, 1CD: Text, N,% --N
GuiControl, 2CD: Text, N,% N
IF StrLen(N) < NL
{
Gui, 1CD:Font,% "s" Dia*SF[--NL]
GuiControl, 1CD: Font, N
GuiControl, 1CD: Move, N ,% "y" Dia*YF[NL]
Gui, 2CD:Font,% "s" Dia*SF[NL]
GuiControl, 2CD: Font, N
GuiControl, 2CD: Move, N ,% "y" Dia*YF[NL]
}
}
Gui, 1CD: Destroy
Gui, 2CD: Destroy
Return
}
-
- Posts: 83
- Joined: 16 May 2020, 12:27
- Location: Italy
Re: How to display a pop-up number on the screen
Thanks. Very cool function with nice visual effect
Courses on AutoHotkey
Re: How to display a pop-up number on the screen
If I want to display a rectangle with a name and a phone number below the name.Hellbent wrote: ↑14 Jun 2020, 22:57I have moved the code to a function and you can pass the position, number, background color etc.
I also made the font size change based on the length of the number you pass it (alternatively you can just find the size that fits any number in your range and then just use that one for every number).
If you have anymore questions about it just ask.Code: Select all
;*************************************************************************************************** ;*************************************************************************************************** #Include <My Altered Gdip Lib> ;<------ Replace with your copy of GDIP #Include <LayeredWindow Class> ;<----- https://www.autohotkey.com/boards/viewtopic.php?f=6&t=72588 ;*************************************************************************************************** ;*************************************************************************************************** #SingleInstance,Force OnExit,*ESC global MyWindow Gosub,Numpad1 return Numpad1:: PopUpNumbers(100, 100, Ran(1,99999), "0xFF880000") return *ESC:: MyWindow.DeleteWindow(1) ExitApp PopUpNumbers(Posx := "" , Posy := "" , DisplayNumber := 1000, BackgroundColor := "0xFF336699", BorderColor := "0xFF000000", TextColorTop := "0xFFFFFFFF", TextColorBottom := "0xFF000000"){ (Strlen(DisplayNumber)=1)?(FS := 72):(Strlen(DisplayNumber)=2)?(FS := 48):(Strlen(DisplayNumber)=3)?(FS := 36):(Strlen(DisplayNumber)=4)?(FS := 28):(Strlen(DisplayNumber)=5)?(FS := 26) (MyWindow)?(MyWindow.DeleteWindow(1),MyWindow := "") MyWindow := New LayeredWindow( posx, posy, 100, 100, 1, " ", 2, "+AlwaysOnTop -DPISCale +toolWindow", 1, 1, {x:0,y:0,w:100,h:100}) Pen1 := Gdip_CreatePen(BorderColor, 2),Brush1 := Gdip_BrushCreateSolid(BackgroundColor),Brush2 := Gdip_BrushCreateSolid(TextColorTop),Brush3 := Gdip_BrushCreateSolid(TextColorBottom) Gdip_FillEllipse( MyWindow.G, Brush1, 1, 1, 97, 97) Gdip_DrawEllipse( MyWindow.G, Pen1, 1, 1, 97, 97) Gdip_TextToGraphics( MyWindow.G , DisplayNumber , "s" FS " Center vCenter Bold c" Brush3 " x-2 y2", "Arial" , 98 , 98 ) Gdip_TextToGraphics( MyWindow.G , DisplayNumber , "s" FS " Center vCenter Bold c" Brush2 " x0 y4", "Arial" , 98 , 98 ) Gdip_DeletePen(Pen1),Gdip_DeleteBrush(Brush1),Gdip_DeleteBrush(Brush2),Gdip_DeleteBrush(Brush3) MyWindow.UpdateWindow() } Ran(Min,Max){ Random, Out, Min, Max return Out }
Re: How to display a pop-up number on the screen
Was looking for a old post and saw this, I guess I didn't notice the notification at the time.
Not sure if you are still looking for this, but give this a try
Code: Select all
;***************************************************************************************************
#Include <My Altered Gdip Lib> ;<------ Replace with your copy of GDIP ; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=6517
;***************************************************************************************************
#Include <ColorTip> ; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=85417
;***************************************************************************************************
#SingleInstance,Force
SetBatchLines, -1
OnExit, *ESC
pToken := GDIP_Startup()
Needle := {"Phone":0xFFFFFF00,"Number:":0xFFFFFF00,"Name:":0xFF00FF00,"(666)":0xFFFF0000,6969:0xFF00FFFF}
PhoneTips := New ColorTip(Text := "No Text Added Yet", Needle , Font := "Segoe UI", FontColor := "0xFFFFFFFF", FontOptions := "s12 Bold", BackgroundColor := "0xFF232527", Roundness := 10, X_Position := 100, Y_Position := 100, MarginX := 30, MarginY := 10)
PersonsName := "songdg"
PersonsPhoneNumber := "(123) - 555 - 1234"
PhoneTips.Update("Name: " PersonsName " `n Phone Number: " PersonsPhoneNumber)
sleep, 3000
PersonsName := "Hellbent"
PersonsPhoneNumber := "(666) - 555 - 6969"
PhoneTips.Update("Name: " PersonsName " `n Phone Number: " PersonsPhoneNumber)
sleep, 5000
PhoneTips := ""
goto, *ESC
return
*ESC::
GDIP_ShutDown(pToken)
ExitApp
.