What an upgrade from the old Notify, so slick to use....
BUT!!!! Has anybody had any trouble using the Destroy:"slide" command or any other destroy setting, it always seems to go to bottom right hand corner as it collapses, i cannot for the life of me get it to do what it is commanded to do, when Destroy used.
new Notify class leveraging Window's Animations from Maestrith
- Trubbleguy
- Posts: 18
- Joined: 11 Jul 2014, 03:00
-
- Posts: 12
- Joined: 14 Jul 2018, 18:55
- Contact:
Re: new Notify class leveraging Window's Animations from Maestrith
Hi,
In my version of the Notify class there seems to be an error. In the class, in the add window method you'll see the following lines (right above the Click method.
Change both Obj.Destroy to Info.Destroy. So this line will be like
Then, what you set the destroy options to be will react.
In my version of the Notify class there seems to be an error. In the class, in the add window method you'll see the following lines (right above the Click method.
Code: Select all
Obj := this.SetPos()
Flags := 0
for a,b in StrSplit(Info.Animate,",")
Flags|=Round(this.Animation[b])
DllCall("AnimateWindow","UInt",Main,"Int",(Info.ShowDelay?Info.ShowDelay:this.ShowDelay),"UInt",(Flags?Flags:0x00000008|0x00000004|0x00040000|0x00000002))
for a,b in StrSplit((Obj.Destroy?Obj.Destroy:"Top,Left,Slide"),",") ;*[notify_destroy]
Flags|=Round(this.Animation[b])
Flags|=0x00010000,NotifyClass.Windows[ID].Flags:=Flags
DetectHiddenWindows,%Hidden%
return ID
}
Code: Select all
for a,b in StrSplit((Info.Destroy?Info.Destroy:"Top,Left,Slide"),",") ;*[notify_destroy]
Sweet Alert 2 for AHK - A Beautiful JS Popup MSG & Toast Notifications
https://github.com/DMDComposer/SweetAlert2-AHK
Master Search Box aka Master Script Commands v1 - AHK Gui for user commands
https://github.com/DMDComposer/MasterSearchBox
Master Script Commands v2 - AHK Gui using G33kdude's neutron for user commands
https://github.com/DMDComposer/MasterScriptCommands
https://github.com/DMDComposer/SweetAlert2-AHK
Master Search Box aka Master Script Commands v1 - AHK Gui for user commands
https://github.com/DMDComposer/MasterSearchBox
Master Script Commands v2 - AHK Gui using G33kdude's neutron for user commands
https://github.com/DMDComposer/MasterScriptCommands
- sharonhuston
- Posts: 15
- Joined: 15 Nov 2019, 10:51
Re: new Notify class leveraging Window's Animations from Maestrith
Love the Notify class! Almost every macro I write uses this class.
I want to make one small adaptation . . . my office uses laptops paired with multiple monitors, and often the messages don't appear on whichever monitor users are paying attention to. I thought maybe I could add a WinTitle as an optional param, then have the message appear on the monitor that holds the bulk of the application users are working with. It kind of works -- the message appears on the appropriate screen, but it doesn't appear in the correct location. This seems like it would be a simple fix, but I've reached this point:
This code uses the MDMF functions in Gdip_All, which is in my library.
I want to make one small adaptation . . . my office uses laptops paired with multiple monitors, and often the messages don't appear on whichever monitor users are paying attention to. I thought maybe I could add a WinTitle as an optional param, then have the message appear on the monitor that holds the bulk of the application users are working with. It kind of works -- the message appears on the appropriate screen, but it doesn't appear in the correct location. This seems like it would be a simple fix, but I've reached this point:
![Hit my head against the wall. :headwall:](./images/smilies/headwall.gif)
This code uses the MDMF functions in Gdip_All, which is in my library.
Code: Select all
#SingleInstance,Force
; Count:=0
; Notify:=Notify(20)
/*
Usage:
Notify:=Notify()
Window:=Notify.AddWindow("Your Text Here",{Icon:4,Background:"0xAA00AA"})
|---Window ID |--------Options
Options:
Window ID will be used when making calls to Notify.SetProgress(Window,ProgressValue)
Animate: Ways that the window will animate in eg. {Animate:""} Can be Bottom, Top, Left, Right, Slide, Center, or Blend (Some work together, and some override others)
Background: Color value in quotes eg. {Background:"0xAA00AA"}
Buttons: Comma Delimited list of names for buttons eg. {Buttons:"One,Two,Three"}
Color: Font color eg.{Color:"0xAAAAAA"}
Destroy: Comma Delimited list of Bottom, Top, Left, Right, Slide, Center, or Blend
Flash: Flashes the background of the notification every X ms eg. {Flash:1000}
FlashColor: Sets the second color that your notification will change to when flashing eg. {FlashColor:"0xFF00FF"}
Font: Face of the message font eg. {Font:"Consolas"}
Icon: Can be either an Integer to pull an icon from Shell32.dll or a full path to an EXE or full path to a dll. You can add a comma and an integer to select an icon from within that file eg. {Icon:"C:\Windows\HelpPane.exe,2"}
IconSize: Width and Height of the Icon eg. {IconSize:20}
Hide: Comma Separated List of Directions to Hide the Notification eg. {Hide:"Left,Top"}
Progress: Adds a progress bar eg. {Progress:10} ;Starts with the progress set to 10%
Radius: Size of the border radius eg. {Radius:10}
Size: Size of the message text eg {Size:20}
ShowDelay: Time in MS of how long it takes to show the notification
Sound: Plays either a beep if the item is an integer or the sound file if it exists eg. {Sound:500}
Time: Sets the amount of time that the notification will be visible eg. {Time:2000}
Title: Sets the title of the notification eg. {Title:"This is my title"}
TitleColor: Title font color eg. {TitleColor:"0xAAAAAA"}
TitleFont: Face of the title font eg. {TitleFont:"Consolas"}
TitleSize: Size of the title text eg. {TitleSize:12}
*/
;Actual code starts here
Notify(Margin:=5){
static Notify:=New NotifyClass()
Notify.Margin:=Margin
return Notify
}
Class NotifyClass{
__New(Margin:=10){
this.ShowDelay:=40,this.ID:=0,this.Margin:=Margin,this.Animation:={Bottom:0x00000008,Top:0x00000004,Left:0x00000001,Right:0x00000002,Slide:0x00040000,Center:0x00000010,Blend:0x00080000}
if(!this.Init)
OnMessage(0x201,NotifyClass.Click.Bind(this)),this.Init:=1
; -------------------- new param winTitle added ------------------------------------------
}AddWindow(Text,winTitle:="",Info:=""){
(Info?Info:Info:=[])
for a,b in {Background:0,Color:"0xAAAAAA",TitleColor:"0xAAAAAA",Font:"Consolas",TitleSize:12,TitleFont:"Consolas",Size:20,Font:"Consolas",IconSize:20}
if(Info[a]="")
Info[a]:=b
if(!IsObject(Win:=NotifyClass.Windows))
Win:=NotifyClass.Windows:=[]
Hide:=0
for a,b in StrSplit(Info.Hide,",")
if(Val:=this.Animation[b])
Hide|=Val
Info.Hide:=Hide
DetectHiddenWindows,On
this.Hidden:=Hidden:=A_DetectHiddenWindows,this.Current:=ID:=++this.ID,Owner:=WinActive("A")
Gui,Win%ID%:Default
if(Info.Radius)
Gui,Margin,% Floor(Info.Radius/3),% Floor(Info.Radius/3)
Gui,-Caption +HWNDMain +AlwaysOnTop +Owner%Owner%
Gui,Color,% Info.Background,% Info.Background
NotifyClass.Windows[ID]:={ID:"ahk_id" Main,HWND:Main,Win:"Win" ID,Text:Text,Background:Info.Background,FlashColor:Info.FlashColor,Title:Info.Title,ShowDelay:Info.ShowDelay,Destroy:Info.Destroy}
for a,b in Info
NotifyClass.Windows[ID,a]:=b
if((Ico:=StrSplit(Info.Icon,",")).1)
Gui,Add,Picture,% (Info.IconSize?"w" Info.IconSize " h" Info.IconSize:""),% "HBITMAP:" LoadPicture(Foo:=(Ico.1+0?"Shell32.dll":Ico.1),Foo1:="Icon" (Ico.2!=""?Ico.2:Info.Icon),2)
if(Info.Title){
Gui,Font,% "s" Info.TitleSize " c" Info.TitleColor,% Info.TitleFont
Gui,Add,Text,x+m,% Info.Title
}Gui,Font,% "s" Info.Size " c" Info.Color,% Info.Font
Gui,Add,Text,HWNDText,%Text%
; modified code ----------------------------------------------
if (winTitle != "") {
WinGet, winID, ID, %winTitle%
targetMon := MDMF_FromHWND(winID)
Monitors := MDMF_Enum()
For HMON, M In Monitors
{
If (IsObject(M)) {
if (HMON = targetMon) {
myMon := M.Num -1
}
}
}
}
SysGet,Mon,MonitorWorkArea,%myMon%
; end modified code ----------------------------------------------
if(Info.Sound+0)
SoundBeep,% Info.Sound
if(FileExist(Info.Sound))
SoundPlay,% Info.Sound
this.MonBottom:=MonBottom,this.MonTop:=MonTop,this.MonLeft:=MonLeft,this.MonRight:=MonRight
if(Info.Time){
TT:=this.Dismiss.Bind({this:this,ID:ID})
SetTimer,%TT%,% "-" Info.Time
}if(Info.Flash){
TT:=this.Flash.Bind({this:this,ID:ID})
SetTimer,%TT%,% Info.Flash
NotifyClass.Windows[ID].Timer:=TT
}
for a,b in StrSplit(Info.Buttons,","){
Gui,Margin,% Info.Radius?Info.Radius/2:5,5
Gui,Font,s10
Gui,Add,Button,% (a=1?"xm":"x+m"),%b%
}
if(Info.Progress!=""){
Gui,Win%ID%:Font,s4
ControlGetPos,x,y,w,h,,ahk_id%Text%
Gui,Add,Progress,w%w% HWNDProgress,% Info.Progress
NotifyClass.Windows[ID].Progress:=Progress
}Gui,Win%ID%:Show,Hide
WinGetPos,x,y,w,h,ahk_id%Main%
if(Info.Radius)
WinSet, Region, % "0-0 w" W " h" H " R" Info.Radius "-" Info.Radius,ahk_id%Main%
Obj:=this.SetPos(),Flags:=0
for a,b in StrSplit(Info.Animate,",")
Flags|=Round(this.Animation[b])
DllCall("AnimateWindow","UInt",Main,"Int",(Info.ShowDelay?Info.ShowDelay:this.ShowDelay),"UInt",(Flags?Flags:0x00000008|0x00000004|0x00040000|0x00000002))
for a,b in StrSplit((Obj.Destroy?Obj.Destroy:"Top,Left,Slide"),",")
Flags|=Round(this.Animation[b])
Flags|=0x00010000,NotifyClass.Windows[ID].Flags:=Flags
DetectHiddenWindows,%Hidden%
return ID
}Click(){
Obj:=NotifyClass.Windows[RegExReplace(A_Gui,"\D")],Obj.Button:=A_GuiControl,(Fun:=Func("Click"))?Fun.Call(Obj):"",this.Delete(A_Gui)
}Delete(Win){
Win:=RegExReplace(Win,"\D"),Obj:=NotifyClass.Windows[Win],NotifyClass.Windows.Delete(Win)
if(WinExist("ahk_id" Obj.HWND)){
DllCall("AnimateWindow","UInt",Obj.HWND,"Int",Obj.ShowDelay,"UInt",Obj.Flags)
Gui,% Obj.Win ":Destroy"
}if(TT:=Obj.Timer)
SetTimer,%TT%,Off
this.SetPos()
}Dismiss(){
this.this.Delete(this.ID)
}Flash(){
Obj:=NotifyClass.Windows[this.ID]
Obj.Bright:=!Obj.Bright
Color:=Obj.Bright?(Obj.FlashColor!=""?Obj.FlashColor:Format("{:06x}",Obj.Background+800)):Obj.Background
if(WinExist(Obj.ID))
Gui,% Obj.Win ":Color",%Color%,%Color%
}SetPos(){
Width:=this.MonRight-this.MonLeft,MH:=this.MonBottom-this.MonTop,MinX:=[],MinY:=[],Obj:=[],Height:=0,Sub:=0,MY:=MH,MaxW:={0:1},Delay:=A_WinDelay,Hidden:=A_DetectHiddenWindows
DetectHiddenWindows,On
SetWinDelay,-1
for a,b in NotifyClass.Windows{
WinGetPos,x,y,w,h,% b.ID
Height+=h+this.Margin
if(MH<=Height)
Sub:=Width-MinX.MinIndex()+this.Margin,MY:=MH,MinY:=[],MinX:=[],Height:=h,MaxW:={0:1},Reset:=1
MaxW[w]:=1,MinX[Width-w-Sub]:=1,MinY[MY:=MY-h-this.Margin]:=y,XPos:=MinX.MinIndex()+(Reset?0:MaxW.MaxIndex()-w)
WinMove,% b.ID,,%XPos%,MinY.MinIndex()
Obj[a]:={x:x,y:y,w:w,h:h},Reset:=0
}DetectHiddenWindows,%Hidden%
SetWinDelay,%Delay%
}SetProgress(ID,Progress){
GuiControl,,% NotifyClass.Windows[ID].Progress,%Progress%
}
}
Re: new Notify class leveraging Window's Animations from Maestrith
Is there any chance to in-/decrease the boxes corner radius* on the fly ie. with using an additional parameter? A similar effect like the option/feature that is used for button creation here: https://www.clickminded.com/button-generator
* and to smoothen them (anti-aliasing?) if possible??![Thinking :think:](./images/smilies/icon_think.gif)
* and to smoothen them (anti-aliasing?) if possible??
![Thinking :think:](./images/smilies/icon_think.gif)
-
- Posts: 12
- Joined: 14 Jul 2018, 18:55
- Contact:
Re: new Notify class leveraging Window's Animations from Maestrith
Hi,BoBo wrote: ↑03 Jun 2022, 14:33Is there any chance to in-/decrease the boxes corner radius* on the fly ie. with using an additional parameter? A similar effect like the option/feature that is used for button creation here: https://www.clickminded.com/button-generator
* and to smoothen them (anti-aliasing?) if possible??![]()
If I'm not misreading your question, the option is Radius in the notify class.
Code: Select all
Notify().AddWindow("No Radius", {Title:"Title", Radius: 0})
Notify().AddWindow("With Radius", {Title:"Title", Radius: 50})
Sleep, 2000
Sleep, 2000
ExitApp
DMDComposer
Sweet Alert 2 for AHK - A Beautiful JS Popup MSG & Toast Notifications
https://github.com/DMDComposer/SweetAlert2-AHK
Master Search Box aka Master Script Commands v1 - AHK Gui for user commands
https://github.com/DMDComposer/MasterSearchBox
Master Script Commands v2 - AHK Gui using G33kdude's neutron for user commands
https://github.com/DMDComposer/MasterScriptCommands
https://github.com/DMDComposer/SweetAlert2-AHK
Master Search Box aka Master Script Commands v1 - AHK Gui for user commands
https://github.com/DMDComposer/MasterSearchBox
Master Script Commands v2 - AHK Gui using G33kdude's neutron for user commands
https://github.com/DMDComposer/MasterScriptCommands
Re: new Notify class leveraging Window's Animations from Maestrith
@DMDComposer - Hell, you got it! Thx a lot
(reminder to myself: "... stay focused!")
![Silent :silent:](./images/smilies/icon_silent.gif)
![Thumbup :thumbup:](./images/smilies/icon_thumbup.gif)
![Rolling Eyes :roll:](./images/smilies/icon_rolleyes.gif)
![Silent :silent:](./images/smilies/icon_silent.gif)
Re: new Notify class leveraging Window's Animations from Maestrith
Is there any way to make the backgrounds transparent?
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: No registered users and 213 guests