AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

A_ThisTimerParam

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
Andreone



Joined: 20 Jul 2007
Posts: 257
Location: Paris, France

PostPosted: Tue Dec 18, 2007 10:21 am    Post subject: A_ThisTimerParam Reply with quote

I encountered a problem when using a timer label for several timers at the same time. Once in the timer's label, there's is no way to know which timer is actually running.
For instance, if you make a special notification method that show a dialog for a few second, you use a timer to hide the window. To be clean, you can embed the all process in one function, using a private label and a static variable that holds the shown window id. If a second notification is launched whilst the first one is still shown, there's a problem.

What I propose is to provide an additional (and optional) parameter to the SetTimer function. This parameter could be anything the user wants (a string, a window id, the address of a structure, ...) And this value would be associated with the timer callback.

Example of what can be done now:
Code:
SomeNotificationMethod()
{
    static s_wndId
    ; code to create a window
    s_wndId := MyWindowId
    SetTimer, PrivateTimer, 5000
    return
PrivateTimer:
    WinClose, ahk_wnd %s_wndId%
    SetTimer, %A_ThisLabel%, Off
    return
}


What I suggest is something like that:
Code:
SomeNotificationMethod()
{
    ; code to create a window
    SetTimer, PrivateTimer, 5000,, %MyWindowId%
    return

PrivateTimer:
    WinClose, ahk_wnd %A_ThisTimerParam%
    SetTimer, %A_ThisLabel%, Off
    return
}


An other approach could be the SetTimer to return a timer id, but I think the proposition above is more in the spirit of AHK.
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2558
Location: Australia, Qld

PostPosted: Tue Dec 18, 2007 1:33 pm    Post subject: Reply with quote

I think the method described in call functions in HotKey, SetTimer would be more powerful and appropriate, but perhaps this would be easier to pull off. Smile
Back to top
View user's profile Send private message
Andreone



Joined: 20 Jul 2007
Posts: 257
Location: Paris, France

PostPosted: Tue Dec 18, 2007 1:54 pm    Post subject: Reply with quote

I agree that function calls would be more powerful and achieve the same goal. However, they seems also more difficult to implement than what I propose (maybe that's the reason it has been delayed/dropped).

The way is propose is simple, doesn't break existing scripts and offers a real workaround to this issue. Unless you know an other way to handle this?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group