[SOLVED] Calling function with SetTimer

Get help with using AutoHotkey and its commands and hotkeys
vasili111
Posts: 747
Joined: 21 Jan 2014, 02:04
Location: Georgia

[SOLVED] Calling function with SetTimer

04 May 2015, 13:57

How to make this work?

Code: Select all

a := 12
SetTimer, z(a), -0

z(a)
{
	MsgBox, % a
}
Last edited by vasili111 on 04 May 2015, 16:16, edited 1 time in total.
DRAKON-AutoHotkey: Visual programming for AutoHotkey.
ameyrick
Posts: 119
Joined: 20 Apr 2014, 18:12

Re: Calling function with SetTimer

04 May 2015, 15:00

Code: Select all

a := 12
SetTimer, z, -0
Return

z:
SetTimer, z, off
result := z(a)
Return

z(a)
{
	MsgBox, % a
}
Last edited by ameyrick on 08 May 2015, 15:07, edited 3 times in total.
tmplinshi
Posts: 1281
Joined: 01 Oct 2013, 14:57

Re: Calling function with SetTimer

04 May 2015, 15:11

Code: Select all

#Persistent

a := 12
fn := Func("z").Bind(a)
SetTimer, %fn%, -0

z(a)
{
    MsgBox, % a
}

Code: Select all

#Persistent

a := 12
fn := ObjBindMethod(myClass, "z", a, "bbb")
SetTimer, %fn%, -0

class myClass {
	z(a, b) {
		MsgBox, % a "`n" b
	}
}
vasili111
Posts: 747
Joined: 21 Jan 2014, 02:04
Location: Georgia

Re: Calling function with SetTimer

04 May 2015, 16:15

Thank you for help :)
Solved.
DRAKON-AutoHotkey: Visual programming for AutoHotkey.
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: [SOLVED] Calling function with SetTimer

07 May 2015, 14:35

what are the advantages of tmplinshi's over ameyrick's. tmplinshi's looks overly complicated! :morebeard:
vasili111
Posts: 747
Joined: 21 Jan 2014, 02:04
Location: Georgia

Re: [SOLVED] Calling function with SetTimer

07 May 2015, 15:15

Guest10 wrote:what are the advantages of tmplinshi's over ameyrick's. tmplinshi's looks overly complicated! :morebeard:
At that time I need to directly call function in SetTimer without label so tmplinshi's examples at that situation are very useful. I need to use SetTimer inside another function.
DRAKON-AutoHotkey: Visual programming for AutoHotkey.
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: [SOLVED] Calling function with SetTimer

07 May 2015, 17:46

when i run this, it says:
Error: Target label does not exist.
---> SetTimer, %fn%, -0
The current thread will exit.

:morebeard:

Code: Select all

#Persistent
#SingleInstance Force
#NoEnv

a := 12
fn := Func("z").Bind(a)
SetTimer, %fn%, -0

z(a)
{
    MsgBox, % a
}
tmplinshi
Posts: 1281
Joined: 01 Oct 2013, 14:57

Re: [SOLVED] Calling function with SetTimer

07 May 2015, 19:35

Guest10 wrote:when i run this, it says:
Error: Target label does not exist.
---> SetTimer, %fn%, -0
The current thread will exit.

:morebeard:

Code: Select all

#Persistent
#SingleInstance Force
#NoEnv

a := 12
fn := Func("z").Bind(a)
SetTimer, %fn%, -0

z(a)
{
    MsgBox, % a
}
Requires AutoHotkey v1.1.20+.
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: [SOLVED] Calling function with SetTimer

07 May 2015, 19:55

thanks, upgraded AHK from 19 to 22, and now it works!

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], CloakerSmoker, dilligence, Google [Bot], tt_1111 and 97 guests