Hi I read your post about struggling with AHK v2. Generally, the v1 Gui functions were partirately bad.
Code: Select all
Tray := A_TrayMenu
Tray.Add("TrayClock", LaunchTrayClock) ; just pass a function object.
;...
return ; end autoexec section
;...
LaunchTrayClock() {
Run "C:\Users\JF\Documents\Programming\AHK Scripts\TrayIconTime\TrayClock.ahk"
}
So here's a brief intro:
1. Using a function object as an argument
Code: Select all
; https://www.autohotkey.com/docs/v2/lib/Func.htm
MsgBox LaunchTrayClock.Name
LaunchTrayClock() {
Run "C:\Users\JF\Documents\Programming\AHK Scripts\TrayIconTime\TrayClock.ahk"
}
2. Executing a function
3. Executing a function (only works at the beginning of a line)
4. Fat arrow syntax (In line functions)
Code: Select all
; https://www.autohotkey.com/docs/v2/lib/Func.htm
MsgBox LaunchTrayClock.Name
LaunchTrayClock() =>
Run("C:\Users\JF\Documents\Programming\AHK Scripts\TrayIconTime\TrayClock.ahk")
5. Single lines
Code: Select all
Tray := A_TrayMenu
Tray.Add("TrayClock", LaunchTrayClock) ; just pass a function object.
;...
return ; end autoexec section
;...
LaunchTrayClock() =>
Run("C:\Users\JF\Documents\Programming\AHK Scripts\TrayIconTime\TrayClock.ahk")
Code: Select all
Tray := A_TrayMenu
Tray.Add("TrayClock", LaunchTrayClock) ; just pass a function object.
;...
return ; end autoexec section
;...
LaunchTrayClock() => Run("C:\Users\JF\Documents\Programming\AHK Scripts\TrayIconTime\TrayClock.ahk")
Code: Select all
Tray := A_TrayMenu
Tray.Add("TrayClock", LaunchTrayClock() => Run("C:\Users\JF\Documents\Programming\AHK Scripts\TrayIconTime\TrayClock.ahk")) ; just pass a function object.
;...
return ; end autoexec section
;...
Code: Select all
Tray := A_TrayMenu
Tray.Add("TrayClock", LaunchTrayClock() => Run("C:\Users\JF\Documents\Programming\AHK Scripts\TrayIconTime\TrayClock.ahk")) ; just pass a function object.
;...
; autoexec section doesn't exist in v2
;...