 |
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 Sep 16, 2009 10:09 am Post subject: |
|
|
Sorry, but I still cant get it to run.
could you show me a plain example how to show one notifier, sleep a while and then destroy it?
In my program i donīt want to sleep but do other things, and when I want to show the next notifier, the first one has to be removed before....
Thanx! |
|
| Back to top |
|
 |
gwarble
Joined: 23 May 2009 Posts: 235 Location: north bay, california
|
Posted: Wed Sep 16, 2009 10:38 am Post subject: |
|
|
hey man, try this, or post some code so i can see what you're trying:
| Code: | #SingleInstance Force
Notify()
Notify("Welcome to Notify()","That first notification had no parameters.`nClick this notification to open a new one...",0,"AC=ActionDemo IN=8 IW=48 IH=48", A_WinDir "\explorer.exe")
Return
ActionDemo:
HotKey, ^F12, WaitDemo
NotifyID := Notify("","this one is permanent, press ctrl-F12 to force kill after 3 seconds",0)
Return
WaitDemo:
Notify("","",-3,"Wait",NotifyID)
Notify("It should have disappeared after 3 seconds, even though it had 0 duration!","this notification will exitapp if clicked or times out",-10)
Return
#Include Notify.ahk |
and get this newest version:
| Code: |
;;;;;
;;; Notify() 0.42 - made by gwarble - sept 09
;;
; for displaying multiple customizable tray area notifications
;
; thanks to Rhys, engunneer, and HugoV
;
;
; Notify([Title,Message,Duration,Options,Image])
;
; Parameters: - Default - Notes
;
; Title - "Notification!!!" - "" to omit title line
;
; Message - "" - "" to omit message line
;
; Duration - 15 - 0 to flash until clicked
; <0 to ExitApp on click/timeout
; -0 not yet implemented
; Options - GF=50 GL=74 - string of options
; uses ((GL-GF)*2) Gui Numbers
; ie: 50 thru 99 by defaults
; [see function for all] most options static/remembered
; "NO=Reset" to reset options
; see function for details
; Image - shell32.dll (1<Image<255) - Image file, or
; number of icon in shell32.dll
;
; Returns - Gui Number used, 0 if Gui quantity exceeded
;
;
Notify(Title="Notification!!!",Message="",Duration=15,Options="",Image="")
{
Static ;Options string, eg: "TS=12 GC=Blue"
; Critical
static GF := 50 ;GF is Gui First Number
static GL := 74 ;GM is Gui Last Number
static GC := "FFFFAA" ;GC is Gui Color
static GR := 9 ;GR is Gui Radius
static GT := "Off" ;GT is Gui Transparency
static TS := 8 ;TS is Title Font Size
static TW := 625 ;TW is Title Font Weight
static TC := "Black" ;TC is Title Font Color
static TF := "Arial" ;TF is Title Font
static MS := 8 ;MS is Message Font Size
static MW := 550 ;MW is Message Font Weight
static MC := "Black" ;MC is Message Font Color
static MF := "Arial" ;MF is Message Font
static BC := "Black" ;BC is Border Colors
static BW := 2 ;BW is Border Width/Thickness
static BR := 9 ;BR is Border Radius
static BT := 105 ;BT is Border Transpacency
static BF := 150 ;BF is Border Flash Speed
static SI := 350 ;SI is Speed In (AnimateWindow)
static SC := 100 ;SC is Speed Clicked (AnimateWindow)
static ST := 450 ;SO is Speed TimeOut (AnimateWindow)
static IW := 32 ;IW is Image Width
static IH := 32 ;IH is Image Height
static IN := 0 ;IN is Icon Number
static Defaults := "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"
local AC ;AC is Action Clicked
local AT ;AT is Action Timeout (broken)
local Notify_Action, ImageOptions, GY, OtherY
;==========================================================================
Notify: ;========================================= when Notify() is called:
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 := Defaults
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% gNotify_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,, NotifyGui
Gui, %GN2%:Show, NA
WinSet, AlwaysOnTop, On
If Duration < 0
Exit := GN
If (Duration)
SetTimer, % "NotifyKill" GN - GF + 1, % - Abs(Duration) * 1000
Else
SetTimer, % "NotifyFlash" GN - GF + 1, % BF
Return % GN
;==========================================================================
;========================================== when a notification is clicked:
Notify_Action:
;Critical
SetTimer, % "NotifyKill" 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)
{
TempNotify_Action:= SubStr(A_LoopField,4)
StringReplace, ActionList, ActionList, % "|" A_Gui "=" TempNotify_Action, , All
If IsLabel(Notify_Action := TempNotify_Action)
Gosub, %Notify_Action%
Notify_Action =
Break
}
StringReplace, NotifyList, NotifyList, % "|" GN, , All
SetTimer, % "NotifyFlash" A_Gui - GF + 1, Off
If (Exit = A_Gui)
ExitApp
Return
;==========================================================================
;=========================================== when a notification times out:
NotifyKill1:
NotifyKill2:
NotifyKill3:
NotifyKill4:
NotifyKill5:
NotifyKill6:
NotifyKill7:
NotifyKill8:
NotifyKill9:
NotifyKill10:
NotifyKill11:
NotifyKill12:
NotifyKill13:
NotifyKill14:
NotifyKill15:
NotifyKill16:
NotifyKill17:
NotifyKill18:
NotifyKill19:
NotifyKill20:
NotifyKill21:
NotifyKill22:
NotifyKill23:
NotifyKill24:
NotifyKill25:
;Critical
StringReplace, GK, A_ThisLabel, NotifyKill
SetTimer, NotifyFlash%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:
NotifyFlash1:
NotifyFlash2:
NotifyFlash3:
NotifyFlash4:
NotifyFlash5:
NotifyFlash6:
NotifyFlash7:
NotifyFlash8:
NotifyFlash9:
NotifyFlash10:
NotifyFlash11:
NotifyFlash12:
NotifyFlash13:
NotifyFlash14:
NotifyFlash15:
NotifyFlash16:
NotifyFlash17:
NotifyFlash18:
NotifyFlash19:
NotifyFlash20:
NotifyFlash21:
NotifyFlash22:
NotifyFlash23:
NotifyFlash24:
NotifyFlash25:
StringReplace, FlashGN, A_ThisLabel, NotifyFlash
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",100,"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
}
|
- gwarble
the flow according to your last post should probably be:
| Code: | NID := Notify(T,M,0)
; actions
Notify("","",-1,"Wait",NID) ;=force kill NID notification before proceeding
NID := Notify(T,"Finished!",5)
or something like that... |
|
|
| Back to top |
|
 |
gwarble
Joined: 23 May 2009 Posts: 235 Location: north bay, california
|
Posted: Wed Sep 16, 2009 10:51 am Post subject: |
|
|
your posted code, needs:
| Code: |
NID := Notify("Notifier","This is a test.",0,"AC=DEMO","Icon_4.ico") ;will gosub, demo if clicked
Sleep 5000
Notify("","",-1,"Wait", NID) ;will force close in 1 second
Sleep 5000
|
for now you have to tell it which notifier you're "wait"ing for... i plan to have it check all notifications, if desired, and maybe by default it can check the last created...
keep in mind the point is to handle multiple notifications without having to kill one first, but thanks for the heads up and ideas... |
|
| Back to top |
|
 |
aaffe
Joined: 17 May 2007 Posts: 1002 Location: Germany - Deutschland
|
Posted: Wed Sep 16, 2009 11:48 am Post subject: |
|
|
Thank you. This does what expected...
Btw: Its so a pity, I cant use your function....I want to run my script at a terminal server, there is only a black box instead of the notifier which is shown at my own pc.....do you know why? |
|
| Back to top |
|
 |
gwarble
Joined: 23 May 2009 Posts: 235 Location: north bay, california
|
Posted: Wed Sep 16, 2009 2:58 pm Post subject: |
|
|
glad you like it
i don't know why, but hopefully we can figure it out (do normal AHK guis function as expected on your terminal server? what is your software setup (remote desktop or something??)
- gwarble |
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
Posted: Wed Sep 16, 2009 3:12 pm Post subject: |
|
|
@aaffe Try various settings like the tooltip clone listed above, perhaps the transparency is the cause (by default the border is transparent) _________________ AHK Wiki FAQ
TF : Text files & strings lib, TF Forum |
|
| Back to top |
|
 |
aaffe
Joined: 17 May 2007 Posts: 1002 Location: Germany - Deutschland
|
Posted: Wed Sep 16, 2009 3:22 pm Post subject: |
|
|
@gwarble: Yes, normal AHK-Functions run normal at this terminal-server.
Its on Windows2000 Server With Remote-Server-Software on it.
normal Tooltips and traytips are shown on it, but not your notify...
@HugoV: Ok, ill give it a try. |
|
| Back to top |
|
 |
aaffe
Joined: 17 May 2007 Posts: 1002 Location: Germany - Deutschland
|
Posted: Wed Sep 16, 2009 3:24 pm Post subject: |
|
|
| Perhaps its because i only can choose 256 colors on the terminal server? |
|
| Back to top |
|
 |
aaffe
Joined: 17 May 2007 Posts: 1002 Location: Germany - Deutschland
|
Posted: Wed Sep 16, 2009 3:30 pm Post subject: |
|
|
I can use another color, even white, make it transparent -> nothing works on the terminal server. always only a black or grey window....
I think I will give up. |
|
| Back to top |
|
 |
gwarble
Joined: 23 May 2009 Posts: 235 Location: north bay, california
|
Posted: Wed Sep 16, 2009 3:53 pm Post subject: |
|
|
this is tested working in vista/xppro/xphome/remotedesktop/realVNC...
what kind of terminal service are you using?? (ok i see your current post...)
Hugo is probably right, try commenting out the winset,trans... and winset,region lines and see what happens...
otherwise it may be the background/border gui is showing in front of the notification (and transparency isnt working so you cant see through it), try commenting out the line:
Gui, %GN2%:Show, % "Hide x" NewX-BW " y" NewY-BW " w" GW+(BW*2) " h" GH+(BW*2)
let me know what you find
- gwarble
EDIT: oh yeah could be the color count too, try setting GC=red because it defaults to FFFFAA or something |
|
| Back to top |
|
 |
aaffe
Joined: 17 May 2007 Posts: 1002 Location: Germany - Deutschland
|
Posted: Wed Sep 16, 2009 4:24 pm Post subject: |
|
|
Ok, without the winset, Region-commands it works!
but its a pity it doesnt look as smooth as with them in it....
but better than nothing. Thanks! |
|
| Back to top |
|
 |
gwarble
Joined: 23 May 2009 Posts: 235 Location: north bay, california
|
Posted: Wed Sep 16, 2009 4:42 pm Post subject: |
|
|
ok cool, good to know...
so instead of commenting out that line, could you do me a favor and run the unmodified Notify() with options:
"GR=0 BR=0" and see if the problem goes away... you'll still lose the sexy round corners but i'd like to know if the function works as-is with these options disabling the winset,region commands
either of you guys have recommendations for different default values?? round corners will be a hard one to give up by default, but the others?
also i noticed a problem with font face, since you can't use spaces or enclose in quotes, "Font Name" won't be usable (although Times is recognized fine, even though its named Times New Roman on the system)
(note to self, there should be logic to add a +border but remove the second gui if no radii and BW=1 (looks the same, saves a gui number/window creation)
thanks again
- gwarble |
|
| Back to top |
|
 |
aaffe
Joined: 17 May 2007 Posts: 1002 Location: Germany - Deutschland
|
Posted: Wed Sep 16, 2009 4:50 pm Post subject: |
|
|
| Yes, it does! |
|
| Back to top |
|
 |
gwarble
Joined: 23 May 2009 Posts: 235 Location: north bay, california
|
Posted: Wed Sep 16, 2009 6:56 pm Post subject: |
|
|
great, thanks for checking
so i wonder if winset,region doesnt work on Win2K at all, or if its a remote terminal issue with that software...?
- gwarble
Edit:
also, is there any documentation for AHK Stdlib compliance rules? Notify.ahk is working fine in the Lib folder [%ProgramFiles%\Autohotkey\Lib] without the #include, doesn't use any globals, has no aux. functions (using_)... but it does use a bunch of Label names (some havent been changed to Notify_XXX: format but i don't know if thats required, etc... i can't find anything on this forum or the wiki as far as rules for designing stdlib-compliant functions, ideas?
thanks |
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
|
| 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
|