AutoHotkey Community

It is currently May 26th, 2012, 10:44 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 257 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6 ... 18  Next
Author Message
 Post subject:
PostPosted: September 16th, 2009, 11:09 am 
Offline

Joined: May 17th, 2007, 12:07 pm
Posts: 1004
Location: Germany - Deutschland
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2009, 11:38 am 
Offline

Joined: May 23rd, 2009, 4:48 am
Posts: 361
Location: north bay, california
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...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2009, 11:51 am 
Offline

Joined: May 23rd, 2009, 4:48 am
Posts: 361
Location: north bay, california
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...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2009, 12:48 pm 
Offline

Joined: May 17th, 2007, 12:07 pm
Posts: 1004
Location: Germany - Deutschland
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2009, 3:58 pm 
Offline

Joined: May 23rd, 2009, 4:48 am
Posts: 361
Location: north bay, california
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2009, 4:12 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
@aaffe Try various settings like the tooltip clone listed above, perhaps the transparency is the cause (by default the border is transparent)

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2009, 4:22 pm 
Offline

Joined: May 17th, 2007, 12:07 pm
Posts: 1004
Location: Germany - Deutschland
@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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2009, 4:24 pm 
Offline

Joined: May 17th, 2007, 12:07 pm
Posts: 1004
Location: Germany - Deutschland
Perhaps its because i only can choose 256 colors on the terminal server?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2009, 4:30 pm 
Offline

Joined: May 17th, 2007, 12:07 pm
Posts: 1004
Location: Germany - Deutschland
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2009, 4:53 pm 
Offline

Joined: May 23rd, 2009, 4:48 am
Posts: 361
Location: north bay, california
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2009, 5:24 pm 
Offline

Joined: May 17th, 2007, 12:07 pm
Posts: 1004
Location: Germany - Deutschland
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2009, 5:42 pm 
Offline

Joined: May 23rd, 2009, 4:48 am
Posts: 361
Location: north bay, california
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2009, 5:50 pm 
Offline

Joined: May 17th, 2007, 12:07 pm
Posts: 1004
Location: Germany - Deutschland
Yes, it does!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2009, 7:56 pm 
Offline

Joined: May 23rd, 2009, 4:48 am
Posts: 361
Location: north bay, california
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 17th, 2009, 7:51 am 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
Re: lib

related earlier discussion: http://www.autohotkey.com/forum/viewtopic.php?t=22214

I don't think there is a standard set in stone, perhaps you could also use _ as in _Notify for the labels just like you would a helper function in a lib. Also note some remarks by Chris here http://www.autohotkey.com/forum/viewtopic.php?t=14238

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 257 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6 ... 18  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: jrav and 15 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group