Unable to use Func() Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
User avatar
zvit
Posts: 226
Joined: 07 Nov 2017, 06:15

Unable to use Func()

Post by zvit » 29 Apr 2024, 11:09

No AI can figure this out, and they all say that v2 supports Func(). But when I try to use it in any way, e.g.,

Code: Select all

MyMenu.Add(index, Func("ShowMenuWrapper"))

Code: Select all

ShowMenuWrapper := Func("ShowMenu").Bind(catToShow . "\\" . index)
MyMenu.Add(index, ShowMenuWrapper)
I get the same error: Expected 0 parameters, but got 1

Why can't I use Func()?

User avatar
mikeyww
Posts: 28869
Joined: 09 Sep 2014, 18:38

Re: Unable to use Func()  Topic is solved

Post by mikeyww » 29 Apr 2024, 11:12

You can do this in v2 but without the Func syntax. Examining the documentation shows the way.

https://www.autohotkey.com/docs/v2/lib/Func.htm#Bind

V1: BoundFunc := Func.Bind(Param1, Param2, ...)
V2: BoundFunc := FuncObj.Bind(Param1, Param2, ...)

Example

User avatar
zvit
Posts: 226
Joined: 07 Nov 2017, 06:15

Re: Unable to use Func()

Post by zvit » 29 Apr 2024, 11:52

mikeyww wrote:
29 Apr 2024, 11:12
You can do this in v2 but without the Func syntax. Examining the documentation shows the way.

https://www.autohotkey.com/docs/v2/lib/Func.htm#Bind

V1: BoundFunc := Func.Bind(Param1, Param2, ...)
V2: BoundFunc := FuncObj.Bind(Param1, Param2, ...)

Example
Ok, thanks! I already completed the script using alternative methods, but this Func() thing comes up often, and has been buggin me! So, I saved this info, and I'll use it next time. Thank you!

Post Reply

Return to “Ask for Help (v2)”