 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
aaffe
Joined: 17 May 2007 Posts: 1002 Location: Germany - Deutschland
|
Posted: Wed Nov 04, 2009 7:37 am Post subject: |
|
|
| I just wanted to say THANKS again for this great great function! |
|
| Back to top |
|
 |
gwarble
Joined: 23 May 2009 Posts: 234 Location: north bay, california
|
Posted: Wed Nov 04, 2009 8:40 am Post subject: |
|
|
aaffe: thanks, i'm glad you like it...
doyle: sorry i missed your first post, regarding dual monitors... this was another thing i thought about as well, related to the docking/arbitrary positioning... it should be easy enough to add (you can probably edit it in quickly by replacing the A_ScreenHeight and Width lines with values retrieved using sysget for the second monitor...
the real solution for the function is a question of syntax... making it happen is the easy part...
we could add a 6th optional parameter, say Position, and have the option for default (tray area), x y (w h), docked to window, screen edge and direction (if not bottom-right-up)... or if its syntax is tightly defined, a new option in the 4th param, something like NotificationPosition[NP=]:
| Quote: | NP=[ScreenEdge][Direction] ie:
NP=RU (current default, right edge, direction up)
NP=LD would be left edge going down, so the first would be top left corner
NP=TR would also start top left corner but move right, make sense?
NP=X100Y100 would be absolute positioning
NP=RUD#### could be right up (like above) docked to ###=hWnd
or something...
NP=LUM2 could be left edge, up direction, monitor2 |
if it was in there, how would you want to use it? (no guarantees i'll be adding it anytime soon, especially the dock() part as i've never used it)
- gwarble
ps to all: another common way i use it, especially when i'm in "code-cleanup-mode" is to throw this line at the top of a subroutine (or function) so i can see when/how often it is called | Quote: | | Notify(A_ThisLabel) |
|
|
| Back to top |
|
 |
doyle
Joined: 14 Nov 2007 Posts: 325 Location: London, England
|
Posted: Wed Nov 04, 2009 9:15 am Post subject: |
|
|
Thanks gwarble. I willl have a play around and report back on what has worked.
From using Notify() for the past few days, it has already been an incredibly productive, and elegant way of adding functionality to a script.
You have earnt an honorable mention in my code.  |
|
| Back to top |
|
 |
gwarble
Joined: 23 May 2009 Posts: 234 Location: north bay, california
|
Posted: Tue Nov 10, 2009 4:46 am Post subject: |
|
|
i put up a quick working example of this in an app on the Compile() thread here:
Compile() - 0.2 - a simple function to auto-compile scripts
or just download this:
http://shop.omwcorp.com/Compile/Min2Tray.ahk - a quick mod of Sean's nice WinTrayMin script utillitizing compile() and notify()...
| Quote: | ; name some icon the same as this script extension [.ico]
; or name some customized AutoHotkeySC.bin the same as this script, extension [.AHK.bin]
; (this file includes Compile() and Notify(), but you should download the latest from their
; respective threads and put them in the stdLib folder...) |
- gwarble |
|
| Back to top |
|
 |
Tom Guest
|
Posted: Thu Dec 03, 2009 3:01 pm Post subject: |
|
|
Anyway using this to make 2 lines of text appear differently ?
eg:
Top Line of Text
Second Line
and have the text centred, with have both lines running the same subroutine click if the popup is clicked ??
Thanks |
|
| Back to top |
|
 |
Tom Guest
|
Posted: Thu Dec 03, 2009 3:37 pm Post subject: |
|
|
| Tom wrote: | Anyway using this to make 2 lines of text appear differently ?
eg:
Top Line of Text
Second Line
and have the text centred, with have both lines running the same subroutine click if the popup is clicked ??
Thanks |
Sorted this
I've set a 10 second time out.. any way to add a cancel 'X' button on the popup ? |
|
| Back to top |
|
 |
gwarble
Joined: 23 May 2009 Posts: 234 Location: north bay, california
|
Posted: Thu Dec 03, 2009 5:47 pm Post subject: |
|
|
hey tom...
so you can get the lines colored differently by using the options, so a call would look something like:
Notify("Top Line","Second Line",10,"TC=Blue MC=Red AC=ClickLabel")
TC is title color and MC is message color
AC is the label name to be run when the notification is clicked anywhere (either line, or the background)
centering text is currently not possible (though could pad with spacing as you see fit (" Message")
there is no option for an "X" close button, though that is planned cuz i'd find it useful... for now i use a timeout and just don't click it...
hope you find it useful
- gwarble |
|
| Back to top |
|
 |
Tom Guest
|
Posted: Thu Dec 03, 2009 8:04 pm Post subject: |
|
|
Thanks gwarble
That's pretty much what I'd got to
Cheers |
|
| Back to top |
|
 |
Tom Guest
|
Posted: Thu Dec 03, 2009 8:37 pm Post subject: |
|
|
hmm..
Just added the notify to one of scripts and got:
| Quote: | Error in #include file notify.ahk: A Goto/Gosub must not jump into a block that doesn't enclose it.
Line 181: Gosub, %_Notify_Action% |
Eh !! what ??
Can anyone help ? |
|
| Back to top |
|
 |
gwarble
Joined: 23 May 2009 Posts: 234 Location: north bay, california
|
Posted: Fri Dec 04, 2009 12:07 am Post subject: |
|
|
double check your AC= option, i havent seen that error before.. or post your code so i can test it
- gwarble
edit: copy and paste this into a new empty .ahk file and run it
| Code: | #SingleInstance, Force
#NoEnv
Notify("Test notification", "with clicking action", 10, "TC=Red MC=Blue AC=Clicked",9)
Return ;= end of auto-execute section
Clicked:
Notify("You clicked it!")
Return
;;;;;;;
;;;;; Notify() 0.44 made by gwarble - sept 09
;;; multiple tray area notifications
; thanks to Rhys/engunneer/HugoV/Forum Posters
;
; Notify([Title,Message,Duration,Options,Image])
;
; Title [!!!] "" to omit title line
; Message [] "" to omit message line
; Duration [15] seconds to show notification
; 0 to flash until clicked
; <0 to ExitApp on click/timeout
; -0 not yet implemented (perm/exit)
; Options string of options... see function
; [SI=999 GC=Blue...] most options are remembered (static)
; "Reset" to restore default options
; if you want to show as well, use NO=Reset
; "Wait" to wait for a notification ***
; Image [] Image file name/library or
; number of icon in shell32.dll
; Gui Number to "Wait" for ***
;
; Return Gui Number used ***
; 0 if failed (too many)
;
Notify(Title="!!!",Message="",Duration=30,Options="",Image="")
{
Static ;Options string: "TS=12 GC=Blue..."
static GF := 50 ; Gui First Number ;= override Gui: # used
static GL := 74 ; Gui Last Number ;= between GF and GL
static GC := "FFFFAA" ; Gui Color ; ie: don't use GF<=Gui#<=GL
static GR := 9 ; Gui Radius ; elsewhere in your script
static GT := "Off" ; Gui Transparency
static TS := 8 ; Title Font Size
static TW := 625 ; Title Font Weight
static TC := "Black" ; Title Font Color
static TF := "Arial" ; Title Font Face
static MS := 8 ;Message Font Size
static MW := 550 ;Message Font Weight
static MC := "Black" ;Message Font Color
static MF := "Arial" ;Message Font Face
static BC := "Black" ; Border Colors
static BW := 2 ; Border Width/Thickness
static BR := 13 ; Border Radius
static BT := 105 ; Border Transpacency
static BF := 150 ; Border Flash Speed
static SI := 350 ; Speed In (AnimateWindow)
static SC := 100 ; Speed Clicked (AnimateWindow)
static ST := 450 ; Speed TimeOut (AnimateWindow)
static IW := 32 ; Image Width
static IH := 32 ; Image Height
static IN := 0 ; Image Icon Number (from Image)
local AC, AT ;Actions Clicked/Timeout
local _Notify_Action, ImageOptions, GY, OtherY
_Notify_:
local NO := 0 ;NO is Notify Option [NO=Reset] ;local
If (Options)
{
IfInString, Options, =
{
Loop,Parse,Options,%A_Space%
If (Option:= SubStr(A_LoopField,1,2))
%Option%:= SubStr(A_LoopField,4)
If NO = Reset
{
Options := "GF=50 GL=74 GC=FFFFAA GR=9 GT=Off TS=8 TW=625 TC=Black TF=Arial MS=8 MW=550 MC=Black MF=Arial BC=Black BW=2 BR=9 BT=105 BF=150 SC=300 SI=250 ST=100 IW=32 IH=32 IN=0"
Goto, _Notify_
}
}
Else If Options = Wait
Goto, _Notify_Wait_
}
GN := GF
Loop
IfNotInString, NotifyList, % "|" GN
Break
Else
If (++GN > GL)
Return 0 ;=== too many notifications open!
NotifyList .= "|" GN
GN2 := GN + GL - GF + 1
If AC <>
ActionList .= "|" GN "=" AC
Prev_DetectHiddenWindows := A_DetectHiddenWindows
Prev_TitleMatchMode := A_TitleMatchMode
DetectHiddenWindows On
SetTitleMatchMode 1
If (WinExist("NotifyGui")) ;=== find all Notifications from ALL scripts, for placement
WinGetPos, OtherX, OtherY ;=== change this to a loop for all open notifications?
DetectHiddenWindows %Prev_DetectHiddenWindows%
SetTitleMatchMode %Prev_TitleMatchMode%
Gui, %GN%:-Caption +ToolWindow +AlwaysOnTop -Border
Gui, %GN%:Color, %GC%
Gui, %GN%:Font, w%TW% s%TS% c%TC%, %TF%
If (Image)
{
If FileExist(Image)
Gui, %GN%:Add, Picture, w%IW% h%IH% Icon%IN%, % Image
Else
Gui, %GN%:Add, Picture, w%IW% h%IH% Icon%Image%, c:\windows\system32\shell32.dll
ImageOptions = x+10
}
If Title <>
Gui, %GN%:Add, Text, % ImageOptions, % Title
Gui, %GN%:Font, w%MW% s%MS% c%MC%, %MF%
If ((Title) && (Message))
Gui, %GN%:Margin, , -5
If Message <>
Gui, %GN%:Add, Text,, % Message
If ((Title) && (Message))
Gui, %GN%:Margin, , 8
Gui, %GN%:Show, Hide, NotifyGui
Gui %GN%:+LastFound
WinGetPos, GX, GY, GW, GH
Gui, %GN%:Add, Text, x0 y0 w%GW% h%GH% g_Notify_Action BackgroundTrans
If (GR)
WinSet, Region, % "0-0 w" GW " h" GH " R" GR "-" GR
If (GT)
WinSet, Transparent, % GT
SysGet, Workspace, MonitorWorkArea
NewX := WorkSpaceRight-GW-5
If (OtherY)
NewY := OtherY-GH-5
Else
NewY := WorkspaceBottom-GH-5
If NewY < % WorkspaceTop
NewY := WorkspaceBottom-GH-5
Gui, %GN2%:-Caption +ToolWindow +AlwaysOnTop -Border +E0x20
Gui, %GN2%:Color, %BC%
Gui %GN2%:+LastFound
If (BR)
WinSet, Region, % "0-0 w" GW+(BW*2) " h" GH+(BW*2) " R" BR "-" BR
If (BT)
WinSet, Transparent, % BT
Gui, %GN2%:Show, % "Hide x" NewX-BW " y" NewY-BW " w" GW+(BW*2) " h" GH+(BW*2)
Gui, %GN%:Show, % "Hide x" NewX " y" NewY, NotifyGui
Gui %GN%:+LastFound
If SI
DllCall("AnimateWindow","UInt",WinExist(),"Int",SI,"UInt","0x00040008")
Else
Gui, %GN%:Show, NA, NotifyGui
Gui, %GN2%:Show, NA
WinSet, AlwaysOnTop, On
If Duration < 0
Exit := GN
If (Duration)
SetTimer, % "_Notify_Kill_" GN - GF + 1, % - Abs(Duration) * 1000
Else
SetTimer, % "_Notify_Flash_" GN - GF + 1, % BF
Return % GN
;==========================================================================
;========================================== when a notification is clicked:
_Notify_Action:
;Critical
SetTimer, % "_Notify_Kill_" A_Gui - GF + 1, Off
Gui, % A_Gui + GL - GF + 1 ":Destroy"
Gui %A_Gui%:+LastFound
If SC
DllCall("AnimateWindow","UInt",WinExist(),"Int",SC,"UInt", "0x00050001")
Gui, %A_Gui%:Destroy
If (ActionList)
Loop,Parse,ActionList,|
If ((Action := SubStr(A_LoopField,1,2)) = A_Gui)
{
Temp_Notify_Action:= SubStr(A_LoopField,4)
StringReplace, ActionList, ActionList, % "|" A_Gui "=" Temp_Notify_Action, , All
If IsLabel(_Notify_Action := Temp_Notify_Action)
Gosub, %_Notify_Action%
_Notify_Action =
Break
}
StringReplace, NotifyList, NotifyList, % "|" GN, , All
SetTimer, % "_Notify_Flash_" A_Gui - GF + 1, Off
If (Exit = A_Gui)
ExitApp
Return
;==========================================================================
;=========================================== when a notification times out:
_Notify_Kill_1:
_Notify_Kill_2:
_Notify_Kill_3:
_Notify_Kill_4:
_Notify_Kill_5:
_Notify_Kill_6:
_Notify_Kill_7:
_Notify_Kill_8:
_Notify_Kill_9:
_Notify_Kill_10:
_Notify_Kill_11:
_Notify_Kill_12:
_Notify_Kill_13:
_Notify_Kill_14:
_Notify_Kill_15:
_Notify_Kill_16:
_Notify_Kill_17:
_Notify_Kill_18:
_Notify_Kill_19:
_Notify_Kill_20:
_Notify_Kill_21:
_Notify_Kill_22:
_Notify_Kill_23:
_Notify_Kill_24:
_Notify_Kill_25:
;Critical
StringReplace, GK, A_ThisLabel, _Notify_Kill_
SetTimer, _Notify_Flash_%GK%, Off
GK += GF - 1
Gui, % GK + GL - GF + 1 ":Destroy"
Gui %GK%:+LastFound
If ST
DllCall("AnimateWindow","UInt",WinExist(),"Int",ST,"UInt", "0x00050001")
Gui, %GK%:Destroy
StringReplace, NotifyList, NotifyList, % "|" GK
If (Exit = GK)
ExitApp
Return
;==========================================================================
;======================================== flashes a permanent notification:
_Notify_Flash_1:
_Notify_Flash_2:
_Notify_Flash_3:
_Notify_Flash_4:
_Notify_Flash_5:
_Notify_Flash_6:
_Notify_Flash_7:
_Notify_Flash_8:
_Notify_Flash_9:
_Notify_Flash_10:
_Notify_Flash_11:
_Notify_Flash_12:
_Notify_Flash_13:
_Notify_Flash_14:
_Notify_Flash_15:
_Notify_Flash_16:
_Notify_Flash_17:
_Notify_Flash_18:
_Notify_Flash_19:
_Notify_Flash_20:
_Notify_Flash_21:
_Notify_Flash_22:
_Notify_Flash_23:
_Notify_Flash_24:
_Notify_Flash_25:
StringReplace, FlashGN, A_ThisLabel, _Notify_Flash_
FlashGN += GF - 1
FlashGN2 := FlashGN + GL - GF + 1
If Flashed%FlashGN2% := !Flashed%FlashGN2%
Gui, %FlashGN2%:Color, Silver
Else
Gui, %FlashGN2%:Color, Black
Return
;==========================================================================
;============================= wait (or force) for a notification to close:
_Notify_Wait_:
;Critical
If (Image)
{
Gui %Image%:+LastFound
If NotifyGuiID := WinExist()
{
WinWaitClose, , , % Abs(Duration)
If (ErrorLevel && Duration < 1)
{
Gui, % Image + GL - GF + 1 ":Destroy"
DllCall("AnimateWindow","UInt",NotifyGuiID,"Int",ST,"UInt", "0x00050001")
Gui, %Image%:Destroy
}
}
}
Else
Notify("No Notification specified to wait for!","waiting for all notifications is not yet implemented",10,"IN=8",A_WinDir "\explorer.exe")
Return
} |
seems to be working fine for me, which i copied right from the first post and added the top few lines
- gwarble |
|
| Back to top |
|
 |
gwarble
Joined: 23 May 2009 Posts: 234 Location: north bay, california
|
Posted: Fri Dec 04, 2009 5:20 am Post subject: |
|
|
also by reading your error, i'd say your label used in AC= may be at fault, possibly a label name after a {, before its "}"
make sure your requested label functions as expected outside of notify (ie:
^1::GoSub, YourLabel
) |
|
| Back to top |
|
 |
gwarble
Joined: 23 May 2009 Posts: 234 Location: north bay, california
|
Posted: Fri Dec 04, 2009 6:56 am Post subject: |
|
|
new version with optional "X" close button added (crudely)... i'll update the first post after testing, making labels work, and cleaning up code...
v0.45 - new option, AX
include "AX" in your options string... adds an x button to the corner that will not perform AC or AT... planned implementation: call another label similar to AC and AT
to turn it back off for further notifys (its static for now) use "AX=anything"
| Code: | ;;;;;;;
;;;;; Notify() 0.45 made by gwarble - sept 09
;;; multiple tray area notifications
; thanks to Rhys/engunneer/HugoV/Forum Posters
;
; Notify([Title,Message,Duration,Options,Image])
;
; Title [!!!] "" to omit title line
; Message [] "" to omit message line
; Duration [15] seconds to show notification
; 0 to flash until clicked
; <0 to ExitApp on click/timeout
; -0 not yet implemented (perm/exit)
; Options string of options... see function
; [SI=999 GC=Blue...] most options are remembered (static)
; "Reset" to restore default options
; if you want to show as well, use NO=Reset
; "Wait" to wait for a notification ***
; Image [] Image file name/library or
; number of icon in shell32.dll
; Gui Number to "Wait" for ***
;
; Return Gui Number used ***
; 0 if failed (too many)
;
Notify(Title="!!!",Message="",Duration=30,Options="",Image="")
{
Static ;Options string: "TS=12 GC=Blue..."
static GF := 50 ; Gui First Number ;= override Gui: # used
static GL := 74 ; Gui Last Number ;= between GF and GL
static GC := "FFFFAA" ; Gui Color ; ie: don't use GF<=Gui#<=GL
static GR := 9 ; Gui Radius ; elsewhere in your script
static GT := "Off" ; Gui Transparency
static TS := 8 ; Title Font Size
static TW := 625 ; Title Font Weight
static TC := "Black" ; Title Font Color
static TF := "Arial" ; Title Font Face
static MS := 8 ;Message Font Size
static MW := 550 ;Message Font Weight
static MC := "Black" ;Message Font Color
static MF := "Arial" ;Message Font Face
static BC := "Black" ; Border Colors
static BW := 2 ; Border Width/Thickness
static BR := 13 ; Border Radius
static BT := 105 ; Border Transpacency
static BF := 150 ; Border Flash Speed
static SI := 350 ; Speed In (AnimateWindow)
static SC := 100 ; Speed Clicked (AnimateWindow)
static ST := 450 ; Speed TimeOut (AnimateWindow)
static IW := 32 ; Image Width
static IH := 32 ; Image Height
static IN := 0 ; Image Icon Number (from Image)
static AX := 0 ; Action X Close Button (maybe add yes/no ok/cancel, etc...)
local AC, AT ;Actions Clicked/Timeout
local _Notify_Action, ImageOptions, GY, OtherY
_Notify_:
local NO := 0 ;NO is Notify Option [NO=Reset]
If (Options)
{
IfInString, Options, =
{
Loop,Parse,Options,%A_Space%
If (Option:= SubStr(A_LoopField,1,2))
%Option%:= SubStr(A_LoopField,4)
If NO = Reset
{
Options := "GF=50 GL=74 GC=FFFFAA GR=9 GT=Off "
. "TS=8 TW=625 TC=Black TF=Arial MS=8 MW=550 MC=Black MF=Arial "
. "BC=Black BW=2 BR=9 BT=105 BF=150 SC=300 SI=250 ST=100 "
. "IW=32 IH=32 IN=0"
Goto, _Notify_
}
}
Else If Options = Wait
Goto, _Notify_Wait_
}
GN := GF
Loop
IfNotInString, NotifyList, % "|" GN
Break
Else
If (++GN > GL)
Return 0 ;=== too many notifications open!
NotifyList .= "|" GN
GN2 := GN + GL - GF + 1
If AC <>
ActionList .= "|" GN "=" AC
Prev_DetectHiddenWindows := A_DetectHiddenWindows
Prev_TitleMatchMode := A_TitleMatchMode
DetectHiddenWindows On
SetTitleMatchMode 1
If (WinExist("NotifyGui")) ;=== find all Notifications from ALL scripts, for placement
WinGetPos, OtherX, OtherY ;=== change this to a loop for all open notifications?
DetectHiddenWindows %Prev_DetectHiddenWindows%
SetTitleMatchMode %Prev_TitleMatchMode%
Gui, %GN%:-Caption +ToolWindow +AlwaysOnTop -Border
Gui, %GN%:Color, %GC%
Gui, %GN%:Font, w%TW% s%TS% c%TC%, %TF%
If (Image)
{
If FileExist(Image)
Gui, %GN%:Add, Picture, w%IW% h%IH% Icon%IN%, % Image
Else
Gui, %GN%:Add, Picture, w%IW% h%IH% Icon%Image%, c:\windows\system32\shell32.dll
ImageOptions = x+10
}
If Title <>
Gui, %GN%:Add, Text, % ImageOptions, % Title
Gui, %GN%:Font, w%MW% s%MS% c%MC%, %MF%
If ((Title) && (Message))
Gui, %GN%:Margin, , -5
If Message <>
Gui, %GN%:Add, Text,, % Message
If ((Title) && (Message))
Gui, %GN%:Margin, , 8
Gui, %GN%:Show, Hide, NotifyGui
Gui %GN%:+LastFound
WinGetPos, GX, GY, GW, GH
If AX =
{
GW += 10
Gui, %GN%:Font, w800 s6 c%MC%
Gui, %GN%:Add, Text, % "x" GW-11 " y-1 Border Center w12 h12 g_Notify_Kill_" GN - GF + 1, X
}
Gui, %GN%:Add, Text, x0 y0 w%GW% h%GH% g_Notify_Action BackgroundTrans
If (GR)
WinSet, Region, % "0-0 w" GW " h" GH " R" GR "-" GR
If (GT)
WinSet, Transparent, % GT
SysGet, Workspace, MonitorWorkArea
NewX := WorkSpaceRight-GW-5
If (OtherY)
NewY := OtherY-GH-5
Else
NewY := WorkspaceBottom-GH-5
If NewY < % WorkspaceTop
NewY := WorkspaceBottom-GH-5
Gui, %GN2%:-Caption +ToolWindow +AlwaysOnTop -Border +E0x20
Gui, %GN2%:Color, %BC%
Gui %GN2%:+LastFound
If (BR)
WinSet, Region, % "0-0 w" GW+(BW*2) " h" GH+(BW*2) " R" BR "-" BR
If (BT)
WinSet, Transparent, % BT
Gui, %GN2%:Show, % "Hide x" NewX-BW " y" NewY-BW " w" GW+(BW*2) " h" GH+(BW*2)
Gui, %GN%:Show, % "Hide x" NewX " y" NewY " w" GW, NotifyGui
Gui %GN%:+LastFound
If SI
DllCall("AnimateWindow","UInt",WinExist(),"Int",SI,"UInt","0x00040008")
Else
Gui, %GN%:Show, NA, NotifyGui
Gui, %GN2%:Show, NA
WinSet, AlwaysOnTop, On
If Duration < 0
Exit := GN
If (Duration)
SetTimer, % "_Notify_Kill_" GN - GF + 1, % - Abs(Duration) * 1000
Else
SetTimer, % "_Notify_Flash_" GN - GF + 1, % BF
Return % GN
Hi:
MsgBox, Hi
Return
;==========================================================================
;========================================== when a notification is clicked:
_Notify_Action:
;Critical
SetTimer, % "_Notify_Kill_" A_Gui - GF + 1, Off
Gui, % A_Gui + GL - GF + 1 ":Destroy"
Gui %A_Gui%:+LastFound
If SC
DllCall("AnimateWindow","UInt",WinExist(),"Int",SC,"UInt", "0x00050001")
Gui, %A_Gui%:Destroy
If (ActionList)
Loop,Parse,ActionList,|
If ((Action := SubStr(A_LoopField,1,2)) = A_Gui)
{
Temp_Notify_Action:= SubStr(A_LoopField,4)
StringReplace, ActionList, ActionList, % "|" A_Gui "=" Temp_Notify_Action, , All
If IsLabel(_Notify_Action := Temp_Notify_Action)
Gosub, %_Notify_Action%
_Notify_Action =
Break
}
StringReplace, NotifyList, NotifyList, % "|" GN, , All
SetTimer, % "_Notify_Flash_" A_Gui - GF + 1, Off
If (Exit = A_Gui)
ExitApp
Return
;==========================================================================
;=========================================== when a notification times out:
_Notify_Kill_1:
_Notify_Kill_2:
_Notify_Kill_3:
_Notify_Kill_4:
_Notify_Kill_5:
_Notify_Kill_6:
_Notify_Kill_7:
_Notify_Kill_8:
_Notify_Kill_9:
_Notify_Kill_10:
_Notify_Kill_11:
_Notify_Kill_12:
_Notify_Kill_13:
_Notify_Kill_14:
_Notify_Kill_15:
_Notify_Kill_16:
_Notify_Kill_17:
_Notify_Kill_18:
_Notify_Kill_19:
_Notify_Kill_20:
_Notify_Kill_21:
_Notify_Kill_22:
_Notify_Kill_23:
_Notify_Kill_24:
_Notify_Kill_25:
;Critical
StringReplace, GK, A_ThisLabel, _Notify_Kill_
SetTimer, _Notify_Flash_%GK%, Off
GK += GF - 1
Gui, % GK + GL - GF + 1 ":Destroy"
Gui %GK%:+LastFound
If ST
DllCall("AnimateWindow","UInt",WinExist(),"Int",ST,"UInt", "0x00050001")
Gui, %GK%:Destroy
StringReplace, NotifyList, NotifyList, % "|" GK
If (Exit = GK)
ExitApp
Return
;==========================================================================
;======================================== flashes a permanent notification:
_Notify_Flash_1:
_Notify_Flash_2:
_Notify_Flash_3:
_Notify_Flash_4:
_Notify_Flash_5:
_Notify_Flash_6:
_Notify_Flash_7:
_Notify_Flash_8:
_Notify_Flash_9:
_Notify_Flash_10:
_Notify_Flash_11:
_Notify_Flash_12:
_Notify_Flash_13:
_Notify_Flash_14:
_Notify_Flash_15:
_Notify_Flash_16:
_Notify_Flash_17:
_Notify_Flash_18:
_Notify_Flash_19:
_Notify_Flash_20:
_Notify_Flash_21:
_Notify_Flash_22:
_Notify_Flash_23:
_Notify_Flash_24:
_Notify_Flash_25:
StringReplace, FlashGN, A_ThisLabel, _Notify_Flash_
FlashGN += GF - 1
FlashGN2 := FlashGN + GL - GF + 1
If Flashed%FlashGN2% := !Flashed%FlashGN2%
Gui, %FlashGN2%:Color, Silver
Else
Gui, %FlashGN2%:Color, Black
Return
;==========================================================================
;============================= wait (or force) for a notification to close:
_Notify_Wait_:
;Critical
If (Image)
{
Gui %Image%:+LastFound
If NotifyGuiID := WinExist()
{
WinWaitClose, , , % Abs(Duration)
If (ErrorLevel && Duration < 1)
{
Gui, % Image + GL - GF + 1 ":Destroy"
DllCall("AnimateWindow","UInt",NotifyGuiID,"Int",ST,"UInt", "0x00050001")
Gui, %Image%:Destroy
}
}
}
Else
Notify("No Notification specified to wait for!","waiting for all notifications is not yet implemented",10,"IN=8",A_WinDir "\explorer.exe")
Return
} |
let me know if it works but don't bother letting me know how ugly it is... just a proof of concept  |
|
| Back to top |
|
 |
Tom Guest
|
Posted: Fri Dec 04, 2009 3:34 pm Post subject: |
|
|
Thanks gwarble
I think that looks pretty good ! |
|
| Back to top |
|
 |
Tom Guest
|
Posted: Sat Dec 05, 2009 4:08 pm Post subject: |
|
|
| gwarble wrote: | also by reading your error, i'd say your label used in AC= may be at fault, possibly a label name after a {, before its "}"
make sure your requested label functions as expected outside of notify (ie:
^1::GoSub, YourLabel
) |
Thanks for your advice on this error.
My script is running inside
| Code: | if !(ErrorLevel) {
SCRIPT
} |
I think that is causing the issue.
What do I need to do with | Quote: | | ^1::GoSub, YourLabel | ??
I don't understand that bit !!
Thank you. |
|
| Back to top |
|
 |
gwarble
Joined: 23 May 2009 Posts: 234 Location: north bay, california
|
Posted: Sat Dec 05, 2009 9:04 pm Post subject: |
|
|
^1::... would be shortcut to running yourlabel: by hotkey <ctrl><1> just to test
but the ac= and at= options will run a subroutine (label) which must already be a valid subroutine...
so AC=Test
means your script must have
Test:
;...
Return
somewhere... read the tutorials about how a script is structured... if you want the action when a notify is clicked to be conditional on ErrorLevel, put that inside the subroutine:
| Code: | Test: ;= starts subroutine
If !(ErrorLevel) {
;something
}
Return ;= ends subroutine |
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|