[SOLVED] Calling function with SetTimer

Get help with using AutoHotkey (v1.1 and older) 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: 122
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: 1604
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: 1604
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!
pk23
Posts: 110
Joined: 24 Apr 2015, 00:49

Re: Calling function with SetTimer

25 Aug 2019, 13:27

tmplinshi wrote:
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
	}
}
only login for saying thank you! :bravo:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Lamron750 and 415 guests