How to display a pop-up number on the screen Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
songdg
Posts: 561
Joined: 04 Oct 2017, 20:04

How to display a pop-up number on the screen

Post by songdg » 14 Jun 2020, 06:00

draw a circle around the number would be better like ③

Rohwedder
Posts: 7625
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to display a pop-up number on the screen

Post by Rohwedder » 14 Jun 2020, 08:10

Hallo,
perhaps:

Code: Select all

q::
Gui, Font, s200 cRed
Gui, add, text,, ③
Gui, -Caption +LastFound +ToolWindow +AlwaysOnTop
WinSet, TransColor, F0F0F0
Gui, show, Center
Return
Or would you like to vary this countdown?:

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
}

User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: How to display a pop-up number on the screen

Post by Hellbent » 14 Jun 2020, 13:05

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

songdg
Posts: 561
Joined: 04 Oct 2017, 20:04

Re: How to display a pop-up number on the screen

Post by songdg » 14 Jun 2020, 22:08

Rohwedder wrote:
14 Jun 2020, 08:10
Hallo,
perhaps:

Code: Select all

q::
Gui, Font, s200 cRed
Gui, add, text,, ③
Gui, -Caption +LastFound +ToolWindow +AlwaysOnTop
WinSet, TransColor, F0F0F0
Gui, show, Center
Return
Or would you like to vary this countdown?:

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
}
some questions about the CountDown function, how to change the number range (when the number greater than 1000 it does work) and size.

songdg
Posts: 561
Joined: 04 Oct 2017, 20:04

Re: How to display a pop-up number on the screen

Post by songdg » 14 Jun 2020, 22:31

Hellbent wrote:
14 Jun 2020, 13:05
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
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.

User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: How to display a pop-up number on the screen  Topic is solved

Post by Hellbent » 14 Jun 2020, 22:57

songdg wrote:
14 Jun 2020, 22:31
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.
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
}


If you have anymore questions about it just ask.

Rohwedder
Posts: 7625
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to display a pop-up number on the screen

Post by Rohwedder » 15 Jun 2020, 03:13

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
}

MancioDellaVega
Posts: 83
Joined: 16 May 2020, 12:27
Location: Italy

Re: How to display a pop-up number on the screen

Post by MancioDellaVega » 15 Jun 2020, 07:04

Rohwedder wrote:
15 Jun 2020, 03:13
I have extended the function for numbers up to 9999. The size of the numbers changes with the Diameter.
Thanks. Very cool function with nice visual effect
Courses on AutoHotkey

songdg
Posts: 561
Joined: 04 Oct 2017, 20:04

Re: How to display a pop-up number on the screen

Post by songdg » 25 Aug 2020, 03:38

Hellbent wrote:
14 Jun 2020, 22:57
songdg wrote:
14 Jun 2020, 22:31
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.
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
}


If you have anymore questions about it just ask.
If I want to display a rectangle with a name and a phone number below the name.

User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: How to display a pop-up number on the screen

Post by Hellbent » 11 Jan 2021, 09:08

songdg wrote:
25 Aug 2020, 03:38
If I want to display a rectangle with a name and a phone number below the name.
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

.
20210111085930.png
20210111085930.png (20.14 KiB) Viewed 499 times

Post Reply

Return to “Ask for Help (v1)”