Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[AHK_L/v2] ObjTree - Explore and Edit objects easily


  • Please log in to reply
61 replies to this topic
HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

ObjTree will display a GUI containing your objects and its items.
Now your objects can be edited as well.

Note icon_exclaim.gif You will need latest AutoHotkey_L or AutoHotkey_H to use these functions.

Download ObjTree.ahk - or - ObjTree.ahk (AHK_v2 version)

Requires latest _Struct class.
Credits:
- majkinetor for Attach() - Attach() for 64-bit - Attach() for v2
- Solar for LV_SortArrow() [Optional]
- PhiLho for ToolTips in TreeView
- shajul for List Arrays/Objects easily (GUI) [Lib] [AHK_L]

- Multiple windows support
- - Enter or double click in ListView displays keys of selected object, press BackSpace to jump to parent object.
- ListViews Checkbox will be ticked if key or value is an object and can be double clicked to be displayed.
- ToolTip in TreeViw shows contents of keys and first 20 keys and values of objects.
- Optionally different ToolTipObject can be used to display custom values, see example.
- Selected key/object is highlighted in ListView when selected in TreeView
- If IsObject(Key), there will be additional child node containing its keys/values. It will have same name (address) as Key.
- - also the key will be selected in ListView rather than showing its keys/values in ListView.
- - double click on such a key in ListView will also show its items
- hwnd:=ObjTree(Object [, Title, Options, ToolTipObject])
   - hwnd = ahk_id of created window

   - Object = object to show in Gui
   - Title = Title for Gui
   - Options separated by comma.
   - - +/-ReadOnly[level] - level means from which depth on object will be editable.
   - - Gui options
   - - Font options, different to Gui options this requires Font=
   - - Gui Show options, also GuiShow= is required

hwnd:=ObjTree(Object,"View My Object","-Readonly2 +AlwaysOnTop, GuiShow=w440 h240 ,Font=s12:Arial")
   - ToolTipObject
   - - optionally you can use a different object for ToolTips, it must have the same structure as your object
- Objects and their Keys are enumerated in alphabetical order only
; Simple Example
WinWaitClose % "ahk_id " ObjTree({MyObject:{"Key With Object":["a","This is a test","b",2]}
					,"Another Object":{Key:["c",1,"d",2]}
					,"Empty Object":[]
					,"Another Object 2":["e",1,"f",2]})
; Example with custom ToolTip and Editable values
WinWaitClose % "ahk_id " ObjTree({MyObject:{"Key With Object":["a","This is a test","b",2]}
					,"Another Object":{Key:["c",1,"d",2]}
					,"Empty Object":[]
					,"Another Object 2":["e",1,"f",2]}
		,"My ObjTree Gui Title","-ReadOnly"
		,{MyObject:{"Key With Object":"This is a an object`nKey is a string and value is object"}
					,"Another Object":{Key:"This is an object"}
					,"Empty Object":"This object is empty"
					,"Another Object 2":"Another object"})
ExitApp


Enjoy wink.png

Update
11.10.2012 Version 1.0.1.0
- Fixed few issues
- Added support for multiple windows
21.03.2012 Version 1.0.0.5
- Removed autoexpanding the item when it is selected
20.03.2012 Version 1.0.0.4
- Fixed OnMessage to be used only while Gui is shown and restore back afterwards.
16.03.2012 AHKv2 Version 1.0.0.3
- Fixed Attach() and ObjTree for latest AHKv2 version.
14.03.2012 - Version 1.0.0.1
- Added Cancel option when closing Gui
- Added possibility to add custom ToolTips for items to Gui
- - Simply pass forth parameter to ObjTree having same key/object structure like your object.
01.03.2012 - Changed to use _Clone() method instead of ObjClone to support custom clone operations
18.02.2012 - Edit objects (pass -ReadOnly[depth])
13.09.2011 - Changed to use _Struct class
23.03.2011 - Added additional EditBox + some bugfixes
19.03.2011 - Enabled view of Keys if these are objects



fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
It would be nice to see something like this in Scite4AHK debugging.

fincs
  • Moderators
  • 1662 posts
  • Last active:
  • Joined: 05 May 2007
SciTE4AutoHotkey already supports object inspection, it was added to beta 4.

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
I know and I've used it before, my comment was more related to the GUI, since you need to open a new window just to see the value.

Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
Nice. Related: [function] Explore object

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Thanks ;)

Updated to show keys and values of keys as well.

- If IsObject(Key), there will be additional child node containing its keys/values. It will have same name (address) as Key.
- - also the key will be selected in ListView rather than showing its keys/values in ListView.
- - double click on such a key in ListView will also show its items



HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

Added additional EditBox to see large string values + some bugfixes



fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
Suggestion: Make it possible to modify values of objects.
It might also be nice to have an edit field where you could type the names of global objects to show.

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

Suggestion: Make it possible to modify values of objects.
It might also be nice to have an edit field where you could type the names of global objects to show.

This is in work, I need to fix a few issues before releasing.
I could provide import object button.

  • Guests
  • Last active:
  • Joined: --
Hi, very nice function. Thanks for sharing.

A couple of problems I noticed:

1. It should be mentioned Attach is required.
2. It does not seem to be compatible with the 64bit build. Not sure if it's a problem of Attach or this function.

- Multiple Guis, currently only one GUI can be displayed, script will wait until it is closed.

What about using unnamed GUIs so that the user does not have to care about the Gui numbers the function uses. Plus it can be called multiple times as demonstrated in this post. Currently it seems it halts the script.
ObjTree([1,2,3],"test")
msgbox called 
ObjTree([4,5,6],"test2")
I would like to see it running in the background and the window automatically updates the contents of the object.

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
That would require two modes, because sometimes it's desirable to see the current value for debugging.

  • Guests
  • Last active:
  • Joined: --
What do you mean by two modes. Users can pause the script if desirable. To see the current value of an object is the whole point of this function and currently if you have a dynamically changing object, you have to close the window again again again and again. And multiple windows means to view them at the same time, not like having to close the other one to see another one.

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
What about message handlers, callbacks, hotkeys and menu items then?

  • Guests
  • Last active:
  • Joined: --
I said what do you mean by two modes

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
One that updates the contents and one that doesn't.