Note: Total parameters are variadic. This function uses Progress UI to display the notification. You need to be well versed with its options.
Simple usage call: OSDTIP_Alert("MainText", "SubText")
Use V0 in options for inverted color: OSDTIP_Alert("MainText", "SubText",, "V0")
Use V1, V2, V3, V4 to display themed alert. These four Vn options (Remember it as W.I.S.E) may be used to display
Warning, Info, Success, Error messages.
Customised UI: OSDTIP_Alert("MainText", "SubText",, "CWFFEBFF CT654665 CB6C2085 ZH32 ZX12 ZY10")
Use CW and CT to specify window/text color. CB for bar color. ZH for bar width. ZX and ZY for X/Y margins.
Parameters explained:
- MainText : Main text will be BOLD by default. Pass WM400 in options to normalize it. Default font size is 11pt. Use FM option, like FM14 to make it bigger.
- SubText : Displayed in normal font weight. Pass WS600 in options for BOLD text. Default font size is 10pt. . Use FS option, like FS14 to make it bigger.
By default, both MainText and SubText are left aligned. In options, pass C01 to display MainText centered or C10 to center SubText or C11 to display both centered. - TimeOut :
Pass number of milliseconds expressed as a negative number. For eg. -3000 will auto-dismiss the alert in 3 seconds.
If this parameter is omitted, the alert wil stay on until OSDTIP_Alert() (without any parameters) is called. If a positive value is passed, eg.3000, it will be ignored.
When the parameter is either omitted or is a negative number, the alert can be dismissed with a mouse left click.
If this parameter is 0, mouse left click will not work and OSDTIP_Alert() has to be called to dismiss UI. - Options : See Progress command for available options. B1 M is forced.. Other options can be overridden.
To control the width and height of UI specify it like W200 H100. This will create a 201x101 UI as the window will have 1px border around it. - FontName : Default is Segoe UI. You may use a monospaced font like Consolas to display tab-formatted text.
- Transparency : This OSDTIP uses transparency level: 240 by default. You may pass a custom value or 255 to make the window opaque.
- XOffset, YOffset, MonitorNumber : By default the alert will be centered on primary monitor. You may use these to parameters to place the alert at a different corner of any monitor
Positive value pairs like 10,10 will place the alert on the Left-Top corner of the Desktop, while negative values like -10,-10 will position it at Right-Bottom corner.
You may refer the image posted at WinPos_ for a better understanding.
Usage example:
The following code will display UI 20 pixels away from the right-bottom corner of primary display. Click on the alert to dismiss it.
Code: Select all
#NoEnv
#SingleInstance, Force
#Persistent
DskSts := "", FBA := 0, TNB := 0
DriveGet, List, List
Loop, Parse, List
If DllCall( "GetDiskFreeSpaceEx", "Str",A_LoopField ":\", "Int64P",FBA, "Int64P",TNB, "Ptr",0 )
DskSts .= A_LoopField . ":\`t" FormatBytes( FBA ) . "`t(" FormatBytes( TNB ) . ")`n"
OSDTIP_Alert("Drive free space", RTrim(DskSts,"`n"),, "FM14 FS11 ZX20 ZH32", "Consolas",, -20, -20)
Return
FormatBytes(N) { ; By SKAN on CT5H/D351 @ tiny.cc/formatbytes
Return DllCall("Shlwapi\StrFormatByteSize64A", "Int64",N, "Str",Format("{:16}",N), "Int",16, "AStr")
}