AutoHotkey_H v2 A_TrayMenu Problem

Post AHK_H specific scripts & libraries and discuss the usage and development of HotKeyIt's fork/branch
Larkal
Posts: 14
Joined: 08 Mar 2019, 00:36

AutoHotkey_H v2 A_TrayMenu Problem

Post by Larkal » 08 Apr 2020, 05:59

Code: Select all

A_TrayMenu.Add "Exit", "ExitApp"
This was working in a previous version of AutoHotkey_H 2, but I just updated to the latest release (as of 2 days ago) and now this code throws an error
Error: Invalid number of parameters.

Line#
---> 002: A_TrayMenu.Add("Exit", "ExitApp")

The current thread will exit.
Did something change with menu objects or is this a new bug? I've tried adding 3 parameters and get the same error.
swagfag
Posts: 4126
Joined: 11 Jan 2017, 17:59

Re: AutoHotkey_H v2 A_TrayMenu Problem

Post by swagfag » 08 Apr 2020, 12:31

the change is _l v2 related, specifically: https://www.autohotkey.com/boards/viewtopic.php?f=37&t=2120&start=40#p276644
an error is raised when a function is called with an incorrect number of parameters
since MenuObject::Add() passes ItemName, ItemPos and Menu to the callback function, u see how the standard ExitApp(ExitCode)'s signature doesnt fit
change ur code as follows:

Code: Select all

A_TrayMenu.Add("Exit", (*) => ExitApp())
Larkal
Posts: 14
Joined: 08 Mar 2019, 00:36

Re: AutoHotkey_H v2 A_TrayMenu Problem

Post by Larkal » 09 Apr 2020, 02:06

Awesome thanks that fixed it!
Post Reply

Return to “AutoHotkey_H”