Dumping ANY kind of object

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
newvice
Posts: 24
Joined: 12 Jun 2021, 09:20

Dumping ANY kind of object

Post by newvice » 13 Jun 2021, 06:57

As I saw the question of dumping variables came ob multiple times. I never saw a solution tho for dumping objects that are "foreign" to AHK's objects.

Is there a function like the folloing powershell command?

Code: Select all

$message = $obj | Format-Custom -Depth $depth -force | out-string
write-host $message 
It dumps the whole object in a hierarchical fashion.

Can this be done in AHK somehow?
User avatar
Chunjee
Posts: 1420
Joined: 18 Apr 2014, 19:05
Contact:

Re: Dumping ANY kind of object

Post by Chunjee » 13 Jun 2021, 08:45

The json libraries do that. The following examples are simple objects but the libraries work for any depth.


https://github.com/Chunjee/json.ahk

Code: Select all

#Include %A_ScriptDir%\node_modules\json.ahk\export.ahk

JSON.stringify([1, 2, 3])
; => "[1, 2, 3]"


https://github.com/G33kDude/AutoHotkey-JSON

Code: Select all

#Include <JSON>

JSON.Dump([1, 2, 3])
; => "[1, 2, 3]"
newvice
Posts: 24
Joined: 12 Jun 2021, 09:20

Re: Dumping ANY kind of object

Post by newvice » 15 Jun 2021, 08:55

But do they also work for lets say Acc objects? Or COM Objects?
User avatar
Chunjee
Posts: 1420
Joined: 18 Apr 2014, 19:05
Contact:

Re: Dumping ANY kind of object

Post by Chunjee » 15 Jun 2021, 12:33

ah wouldn't that be cool. These don't so that because COM objects aren't enumerable or somesuch.
newvice
Posts: 24
Joined: 12 Jun 2021, 09:20

Re: Dumping ANY kind of object

Post by newvice » 16 Jun 2021, 06:42

When its somehow possible to call the mentioned powershell command, give it the object as parameter and get the strings it returns...

Or...
Is AHK capable to call .NET methods like powershell can? Then it would be a no brainer.
Post Reply

Return to “Ask for Help (v1)”