OSDTIP()

Post your working scripts, libraries and tools
User avatar
SKAN
Posts: 754
Joined: 29 Sep 2013, 16:58

OSDTIP_Alert()

27 Jul 2020, 17:27

OSDTIP_Alert(MainText, SubText, TimeOut, Options, FontName, Transparency)
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")
 
     Image
 
Use V0 in options for inverted color: OSDTIP_Alert("MainText", "SubText",, "V0")
 
     Image
 
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.
 
     Image  Image
     Image  Image
 
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.
 
     Image
 
 
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") 
}
 
     Image
User avatar
jNizM
Posts: 2661
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: OSDTIP()

28 Jul 2020, 01:13

For me it shows the Alertbox between Monitor 2 and 1 (half / half)
Image
[AHK] 1.1.32.00 x64 Unicode | [WIN] 10 Pro (Version 2004) x64 | [GitHub] Profile
Donations are appreciated if I could help you
ozzii
Posts: 369
Joined: 30 Oct 2013, 06:04

Re: OSDTIP()

28 Jul 2020, 04:40

SKAN ; I'm Okay will ALL your work ;)

I will test this.

Edit :
How can I do to not dismiss the windows but to close it after the timer/click?
User avatar
SKAN
Posts: 754
Joined: 29 Sep 2013, 16:58

OSDTIP() - Code updated v.0.51

28 Jul 2020, 05:16

jNizM wrote:For me it shows the Alertbox between Monitor 2 and 1 (half / half)
Thanks for testing/reporting. :thumbup:
I've fixed the math. Please test again.
User avatar
SKAN
Posts: 754
Joined: 29 Sep 2013, 16:58

Re: OSDTIP_Alert()

28 Jul 2020, 05:21

ozzii wrote: SKAN ; I'm Okay will ALL your work ;)
I will test this.
 
Please try the updated version.
 
ozzii wrote: How can I do to not dismiss the windows but to close it after the timer/click?
 
Can you rephrase the question, please?!
Maybe you're asking for something like this:

Code: Select all

OSDTIP_Alert("MainText", "SubText", 0) ; Click-to-close is disabled when TimeOut is zero
Sleep 3000
OSDTIP_Alert() ; Dismiss alert
User avatar
jNizM
Posts: 2661
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: OSDTIP() - Code updated v.0.51

28 Jul 2020, 06:51

SKAN wrote:
28 Jul 2020, 05:16
I've fixed the math. Please test again.
Works now :thumbup:
[AHK] 1.1.32.00 x64 Unicode | [WIN] 10 Pro (Version 2004) x64 | [GitHub] Profile
Donations are appreciated if I could help you
User avatar
jNizM
Posts: 2661
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: OSDTIP()

28 Jul 2020, 06:55

Now another OSDTIP_Banner (at the top or bottom of the screen) and I am happy for now. :D
Like a ticker / news banner with fixed or scrolling text.
[AHK] 1.1.32.00 x64 Unicode | [WIN] 10 Pro (Version 2004) x64 | [GitHub] Profile
Donations are appreciated if I could help you
User avatar
SKAN
Posts: 754
Joined: 29 Sep 2013, 16:58

OSDTIP_Alert()

28 Jul 2020, 13:00

jNizM wrote:
28 Jul 2020, 06:51
Works now :thumbup:
Thanks for all the help! :) :thumbup:
 
jNizM wrote:
28 Jul 2020, 06:55
Now another OSDTIP_Banner (at the top or bottom of the screen) and I am happy for now. :D
Like a ticker / news banner with fixed or scrolling text.
That wouldn't require a progress UI, I suppose.
I will try something with a regular GUI and let know.
Thanks @jNizM !
ozzii
Posts: 369
Joined: 30 Oct 2013, 06:04

Re: OSDTIP_Alert()

29 Jul 2020, 03:34

SKAN wrote:
28 Jul 2020, 05:21

Can you rephrase the question, please?!
Instead of dismiss the window how to close it automaticaly after the timer/click, like a regular progress window?
User avatar
SKAN
Posts: 754
Joined: 29 Sep 2013, 16:58

Re: OSDTIP_Alert()

29 Jul 2020, 04:56

ozzii wrote:
29 Jul 2020, 03:34
Instead of dismiss the window how to close it automaticaly after the timer/click, like a regular progress window?
Does the following work for you or not?
It should auto-dismiss after 3 seconds or with a click.

Code: Select all

#NoEnv
#SingleInstance, Force
#Persistent
OSDTIP_Alert("MainText", "SubText", -3000)
Or.. please post an example and explain.
ozzii
Posts: 369
Joined: 30 Oct 2013, 06:04

Re: OSDTIP()

29 Jul 2020, 12:04

I didn't explain myself well enough and didn't done some more tests.

It's OK.

I tought that the script will exit at the end.
I have tested also with the progress command and same, the script is not exited either.
So all good.

My mistake, sorry....

P.S.: Thank you again for this work ;)
User avatar
SKAN
Posts: 754
Joined: 29 Sep 2013, 16:58

Re: OSDTIP()

29 Jul 2020, 16:21

ozzii wrote:
29 Jul 2020, 12:04
P.S.: Thank you again for this work ;)
Do let me know if you have suggestions! :) :thumbup:
ozzii
Posts: 369
Joined: 30 Oct 2013, 06:04

Re: OSDTIP()

30 Jul 2020, 04:03

For now all good :bravo:

Just a thought out loud.....
For having like a real bootstrap (https://www.autohotkey.com/boards/posting.php?mode=quote&f=6&p=343660) notification but for windows, maybe something like a mix of this and the library Neutron (https://www.autohotkey.com/boards/viewtopic.php?f=6&t=76865).
But my code skills are not so good for doing that :headwall:
ozzii
Posts: 369
Joined: 30 Oct 2013, 06:04

Re: OSDTIP()

31 Jul 2020, 04:02

SKAN,

I have tried but with no luck.... :headwall:
How difficult it will be to put another vertical colored bar (maybe as an option) also on the right side of the progress?
Something like this
Image
tuzi
Posts: 44
Joined: 27 Apr 2016, 23:40

Re: OSDTIP()

31 Jul 2020, 23:41

wow ,that's what i just want to say. :bravo: :bravo:
tuzi
Posts: 44
Joined: 27 Apr 2016, 23:40

Re: OSDTIP()

01 Aug 2020, 01:18

@SKAN
OSDTIP_Alert(), There seems to be a little bug when I use Chinese strings.


this is work fine.
OSDTIP_Alert("MainText", "【丸美股份:拟在广州市海珠区投资建设“丸美总部” 项目总投资额约12亿元】丸美股份公告,公司董事会同意公司与广州市海珠区人民政府签署《项目投资意向书》,拟在海珠区投资建设“丸美总部”,项目总投资额约12亿元。")
Image


a little bug. the text is not fully displayed
OSDTIP_Alert("MainText", "【丸美股份:拟在广州市海珠区投资建设“丸美总部” 项目总投资额约12亿元】丸美股份公告,公司董事会同意公司与广州市海珠区人民政府签署《项目投资意向书》,拟在海珠区投资建设“丸美总部”,项目总投资额约12亿元。",, "CWFFEBFF CT654665 CB6C2085 ZH32 ZX12 ZY10")
Image


use of Chinese fonts should be able to solve the problem of incomplete display of the middle text, but the end is still incomplete.
OSDTIP_Alert("MainText", "【丸美股份:拟在广州市海珠区投资建设“丸美总部” 项目总投资额约12亿元】丸美股份公告,公司董事会同意公司与广州市海珠区人民政府签署《项目投资意向书》,拟在海珠区投资建设“丸美总部”,项目总投资额约12亿元。",, "CWFFEBFF CT654665 CB6C2085 ZH32 ZX12 ZY10", "微软雅黑")
Image
Last edited by tuzi on 01 Aug 2020, 02:52, edited 1 time in total.
tuzi
Posts: 44
Joined: 27 Apr 2016, 23:40

Re: OSDTIP()

01 Aug 2020, 01:43

I've collected some beautiful color schemes. Is it possible to theme them?

Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
ozzii
Posts: 369
Joined: 30 Oct 2013, 06:04

Re: OSDTIP()

01 Aug 2020, 05:10

SKAN,

a little research for the problem of tuzi

If you do this it's working
OSDTIP_Alert("MainText", "【丸美股份:拟在广州市海珠区投资建设“丸美总部” 项目总投资额约12亿元】丸美股份公告,公司董事会同意公司与广州市海珠区人民政府签署《项目投资意向书》,拟在海珠区投资建设“丸美总部”,项目总投资额约12亿元。",, "CWFFEBFF CT654665 CB6C2085")

So the problem is something with the added spaces. If you use just one, the error is present
ZH32 ZX12 ZY10

If you put the text into the MainText zone, it's working.

Just saw something also. When you don't put any MainText, the colored bar is not with full height
Image
User avatar
SKAN
Posts: 754
Joined: 29 Sep 2013, 16:58

OSDTIP_Alert()

02 Aug 2020, 22:05

Hi @ozzii
You wrote:
31 Jul 2020, 04:02
How difficult it will be to put another vertical colored bar (maybe as an option) also on the right side of the progress?
Something like this
Image
 
It will be difficult. The vertical colored bar is a progress and only one is available in Progress UI.
I will give it a try later.. For now I'm concentrating on fixing bugs.
 
You wrote:
01 Aug 2020, 05:10
Just saw something also. When you don't put any MainText, the colored bar is not with full height
Image
Thanks for reporting.. I've fixed the bar height.
MainText shouldn't be omitted. If you need only single line omit SubText instead.

Thanks :)
User avatar
SKAN
Posts: 754
Joined: 29 Sep 2013, 16:58

OSDTIP_Alert() : Code updated

02 Aug 2020, 22:11

Hi @tuzi
 
You wrote:
01 Aug 2020, 01:18
a little bug. the text is not fully displayed
OSDTIP_Alert("MainText", "【丸美股份:拟在广州市海珠区投资建设“丸美总部” 项目总投资额约12亿元】丸美股份公告,公司董事会同意公司与广州市海珠区人民政府签署《项目投资意向书》,拟在海珠区投资建设“丸美总部”,项目总投资额约12亿元。",, "CWFFEBFF CT654665 CB6C2085 ZH32 ZX12 ZY10")
Image
 
I've updated the function. Please try again.
 
You wrote:
01 Aug 2020, 01:18
use of Chinese fonts should be able to solve the problem of incomplete display of the middle text, but the end is still incomplete.
OSDTIP_Alert("MainText", "【丸美股份:拟在广州市海珠区投资建设“丸美总部” 项目总投资额约12亿元】丸美股份公告,公司董事会同意公司与广州市海珠区人民政府签署《项目投资意向书》,拟在海珠区投资建设“丸美总部”,项目总投资额约12亿元。",, "CWFFEBFF CT654665 CB6C2085 ZH32 ZX12 ZY10", "微软雅黑")
Image
 
I don't have this font: 微软雅黑 :(
If UI incorrectly displayed with this font, please post a screenshot.

Thanks. :)

Return to “Scripts and Functions”

Who is online

Users browsing this forum: bril and 29 guests