How come I cant add a variable to Obj and its function also returns null? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Gary-Atlan82
Posts: 74
Joined: 07 Mar 2023, 05:20

How come I cant add a variable to Obj and its function also returns null?

Post by Gary-Atlan82 » 24 Mar 2023, 06:04

The Obj object is just not working as I am expecting it to, I try to add WindID to it but when I check with a message box inside the function, the message box is empty.

Also the message box outside the function is also empty. Am I doing this the wrong way?

Code: Select all

space::
Var := test()
MsgBox, %Var%
Return
test(){
Obj := {}
WinID := WinExist("A")
MsgBox, %WinID%
Obj.PanelID := WinID
MsgBox, %Obj%
Return Obj
}
Any help would be greatly appreciated!

User avatar
boiler
Posts: 16951
Joined: 21 Dec 2014, 02:44

Re: How come I cant add a variable to Obj and its function also returns null?  Topic is solved

Post by boiler » 24 Mar 2023, 06:18

You can’t just display an object. You can display an element of an object:

Code: Select all

Var := test()
MsgBox, % Var.PanelID
Return
test(){
Obj := {}
WinID := WinExist("A")
MsgBox, %WinID%
Obj.PanelID := WinID
MsgBox, % Obj.PanelID
Return Obj
}

Gary-Atlan82
Posts: 74
Joined: 07 Mar 2023, 05:20

Re: How come I cant add a variable to Obj and its function also returns null?

Post by Gary-Atlan82 » 24 Mar 2023, 09:20

Thanks so much boiler, really appreciate it

Post Reply

Return to “Ask for Help (v1)”