I did that long ago, too
1. as an compileable script (you can call the OnScreenDisplay.exe via shortcut):
/*
OnScreenDisplay.exe "text" [time=10 [x=0 [y=0 [opacity=50 [font-name=Tahoma [font-size=20 [font-color=red [font-format=600 [WndTitle]]]]]]]]]
Temporarily displays text on the screen.
Parameters:
text - Text to display.
time - Number of seconds to display the text.
x, y - Text coordinates in screen (0 0 = left top, -1 -1 = right bottom) or center.
opacity - Opacity of text in %. From invisible (0) to solid (100).
font name, font size, font color - Font name, size and color. Where color uses a RGB (red, green, and blue) value or color name.
font format - Can be: bold, italic, strike, underline, and norm. To use multiple values separate with space. You can also use boldness (has to be first parameter and a value between 1 and 1000 (400 is normal and 700 is bold) e.g. "350 italic underline").
WndTitle - Window title that identifies the osd window. If this osd window still exists close it before creating new one.
Better: If this osd window still exists, displays text in it instead of creating new window -> prevents flickering (especially if called frequently) and should be faster.
Requires Windows 2000 or higher.
Some color names: white, gray, black, red, green, blue, yellow, lime, purple, teal.
Examples:
- OnScreenDisplay.exe Text
- OnScreenDisplay.exe Text 15 center 100 100 Arial 20 lime "1000 strike"
- OnScreenDisplay.exe Text 5 -1 center 35 Verdana 15 0000ff "bold underline"
- OnScreenDisplay.exe Text 0 0 0 0 0 0 0 underline
Note:
- If you specify a parameter with spaces, enclose it in "". If a parameter is 0 the default value is taken.
- You may experience graphic errors when calling osd with WndTitle frequently (because window gets destroyed and not updated).
- You may experience difficulties in creating alot of (99+) osd windows.
by blk_panther (osd.20.blk_panther at spamgourmet dot com)
*/
#NoTrayIcon
#NoEnv
#SingleInstance off
If !1
ExitApp
text = %1%
time = %2%
x = %3%
y = %4%
opacity = %5%
fname = %6%
fsize = %7%
fcolor = %8%
fformat = %9%
WndTitle = %10%
If !time
time = 10
If !x
x = 0
If !y
y = 0
If !fname
fname = Tahoma
If !fsize
fsize = 20
If !fcolor
fcolor = red
If !fformat
fformat = 600
If !opacity
opacity = 50
If (WndTitle)
{
IfWinExist, %WndTitle%
WinClose
}
Gui, +LastFound +AlwaysOnTop +ToolWindow -Caption
Gui, Margin, 0, 0 ;pixels of space to leave at the left/right and top/bottom sides of the window when auto-positioning.
Gui, Color, ffffff ;changes background color
Gui, Font, c%fcolor% s%fsize% w%fformat%, %fname%
Gui, Add, Text, +0x80 vblkOsdCtrlName, %text% ;0x80 = SS_NOPREFIX -> Ampersand (&) is shown instead of underline one letter for Alt+letter navigation
WinSet, ExStyle, +0x20 ; WS_EX_TRANSPARENT -> mouse klickthrough
opacity := opacity * 255 / 100
WinSet, TransColor, ffffff %opacity%
If (x < 0)
{
Gui, Show, +NoActivate
gui_id := WinExist()
WinGetPos,,,w,, ahk_id %gui_id%
EnvAdd x, %A_ScreenWidth%
EnvSub x, %w%
}
If (y < 0)
{
Gui, Show, +NoActivate
gui_id := WinExist()
WinGetPos,,,,h, ahk_id %gui_id%
EnvAdd y, %A_ScreenHeight%
EnvSub y, %h%
}
Gui, Show, x%x% y%y% +NoActivate, %WndTitle%
time := time * 1000
Sleep, %time%
Gui, Destroy
ExitApp
2. as an function:
/*
Osd/OnScreenDisplay("text" [, time=10 [, x=0 [, y=0 [, opacity=50 [, font-name=Tahoma [, font-size=20 [, font-color=red [, font-format=600 [, WndTitle=blkOsdWnd]]]]]]]]]
Temporarily displays text on the screen.
Parameters:
text - Text to display, use `n for linebreak.
time - Number of seconds to display the text.
x, y - Text coordinates in screen (0 0 = left top, -1 -1 = right bottom) or center.
opacity - Opacity of text in %. From invisible (0) to solid (100).
font name, font size, font color - Font name, size and color. Where color uses a RGB (red, green, and blue) value or color name.
font format - Can be: bold, italic, strike, underline, and norm. To use multiple values separate with space. You can also use boldness (has to be first parameter and a value between 1 and 1000 (400 is normal and 700 is bold) e.g. "350 italic underline").
WndTitle - Window title that identifies the osd window. If this osd window still exists close it before creating new one.
Better: If this osd window still exists, displays text in it instead of creating new window -> prevents flickering (especially if called frequently) and should be faster.
Requires Windows 2000 or higher.
Some color names: white, gray, black, red, green, blue, yellow, lime, purple, teal.
Examples:
- OnScreenDisplay("Text")
- OnScreenDisplay("Text", 15, "center", 100, 100, "Arial", 20, "lime", "1000 strike")
- OnScreenDisplay("Multiline`nText", 5, -1, "center", 35, "Verdana", 15, "0000ff", "bold underline")
Note:
- If you specify a parameter with spaces, enclose it in "".
- You may experience graphic errors when calling osd with WndTitle frequently (because window gets destroyed and not updated).
- You may experience difficulties in creating alot of (99+) osd windows.
by blk_panther (osd.20.blk_panther at spamgourmet dot com)
*/
#NoTrayIcon
#NoEnv
#SingleInstance off
;^y::Osd("Text",10,"center","center","Arial",20,"lime","600",100)
;^s::Osd("Anderer Text",10,"center","center")
;return
Osd("Test`nTest",5,"center",100)
ExitApp
Osd(text,time=10,x=0,y=0,opacity=50,fname="Tahoma",fsize=20,fcolor="red",fformat="600",WndTitle="blkOsdWnd"){
OnScreenDisplay(text,time,x,y,opacity,fname,fsize,fcolor,fformat,WndTitle)
}
OnScreenDisplay(text,time=10,x=0,y=0,opacity=50,fname="Tahoma",fsize=20,fcolor="red",fformat="600",WndTitle="blkOsdWnd"){
If (WndTitle)
{
IfWinExist, %WndTitle%
WinClose
}
Gui, +LastFound +AlwaysOnTop +ToolWindow -Caption
Gui, Margin, 0, 0 ;pixels of space to leave at the left/right and top/bottom sides of the window when auto-positioning.
Gui, Color, ffffff ;changes background color
Gui, Font, c%fcolor% s%fsize% w%fformat%, %fname%
Gui, Add, Text, +0x80 v & "blkOsdCtrlName", %text% ;0x80 = SS_NOPREFIX -> Ampersand (&) is shown instead of underline one letter for Alt+letter navigation
WinSet, ExStyle, +0x20 ; WS_EX_TRANSPARENT -> mouse klickthrough
opacity := opacity * 255 / 100
WinSet, TransColor, ffffff %opacity%
If (x < 0)
{
Gui, Show, +NoActivate
gui_id := WinExist()
WinGetPos,,,w,, ahk_id %gui_id%
EnvAdd x, %A_ScreenWidth%
EnvSub x, %w%
}
If (y < 0)
{
Gui, Show, +NoActivate
gui_id := WinExist()
WinGetPos,,,,h, ahk_id %gui_id%
EnvAdd y, %A_ScreenHeight%
EnvSub y, %h%
}
Gui, Show, x%x% y%y% +NoActivate, %WndTitle%
time := time * 1000
Sleep, %time%
Gui, Destroy
}
use e.g. to call the OnScreenDisplay.exe everytime winamp changes titlebar (I think that's an au3 script from me), display reminder, show volume, …
ps: I think there are some debug-calls in it, you can take them to test, too