GroggyOtter / PeepAHK

A class that allows you to view (almost) any object in AHK v2.
MIT License
17 stars 2 forks source link

Peep(AHKv2)

  1. What Is Peep()?

  2. How To Use

  3. Peep Properties

  4. Changelog

Peep() is a tool for AHK v2.
It allows you to pass in one or more items and get a visual representation of what that item contains.
This includes being able to get information from nested objects without having to write complex for-loops for extracting object information or to view the primitive information you're looking for.

While Peep is a class, it's a callable class and works exactly like a function:

Peep(item1 [, item2, ..., itemN])

Peep has multiple properties (covered below) that you can change to alter how it behaves or how information is displayed.
Who doesn't like a little bit of customization?

Benefits of this tool:

Peep's custom GUI:

Preview of Peep() GUI

Or using the default MsgBox():

Preview of Peep() with MsgBox()

Along with Peep, there's also the Peep Instructions And Demo.ahk file.
This file can be ran to visually demonstrate what the different Peep properties do. Like changing the color of the GUI or how text is displayed.

First screen of the Demo file:
Preview of starting screen for demo

How To Use:

Download the script.
Use #Include to add Peep to your script.
You can remove this later as this is more of a troubleshooting tool than something you'd want to keep bundled with your code.

#Include Peep.v2.ahk

Now you can use Peep freely in your code.
To view an item, use:

Peep(item_name)

Multiple items can be viewed at once:

Peep(item1, item2, item3, item4)

You can label each item doing something like this:

Peep('Before:', item1, 'After:', item2)

There are lots of different properties (options) you can set.

See: Peep Properties

A Peep object is always returned when Peep() is called.
This object contains the text from that specific Peep instance.

Retrieve it by calling the peep object: MsgBox(peep_obj())
Or use the Text property: MsgBox(peep_obj.Text)


Peep.Properties


Peep.dark_mode {Integer}

If true, a dark theme is applied to the GUI.
Otherwise, a light theme is used.
Default value: 1


Peep.ind_type {String}

Character set to represent each level of indentation.
Normally spaces or tabs are used.
Default value: ' '


Peep.unset_value {String}

The indentifier used for values that are unset.
Default value: <UNSET>


Peep.var_ref_value {String}

The indentifier used for when a variable reference values.
Default value: <VAR_REF>


Peep.duplicate_ref_value {String}

The indentifier used for any object that has already been referenced.
Default value: <DUPLICATE_REF>


Peep.include_prim_type {Integer}

If true, primitive value types are inclueded next to their values.
Default value: 0


Peep.include_string_quotes {Integer}

If set to a positive number, strings will have double quotes around them.
If set to a negative number, strings will have single quotes around them.
If set to zero, strings do not have any additional quotes put around them.
Default value: 0


Peep.include_end_commas {Integer}

If true, a comma separates multiple items.
The last item of an item set does not have a comma after it.
Default value: 1


Peep.include_array_index {Integer}

If true, array items will include their index number before each item, starting at 1.
Default value: 0


Peep.include_built_in {Integer}

If true, all native AHK objects will include their AHK assigned properties.
Default value: 1


Peep.array_values_inline {Integer}

If true, arrays that don't contain nested objects are shown on one line.
Peep.include_built_in must also be set to false. Default value: 0


Peep.key_val_inline {Integer}

If true, keys and values reside on the same line.


Peep.indent_closing_tag {Integer}

If true, closing object tags are indented one additional level to align them with object keys/values.
If false, closing object tags are aligned with the line containing the opening tag.
Default value: 0


Peep.gui_pauses_code {Integer}

If true, code execution will pause when the Peep() GUI is shown.
This acts similarly to how MsgBox() works.
Default value: 1


Peep.disable_gui_escape {Integer}

If true, pressing escape has no effect when the GUI is the active window.
If false, pressing escape when the GUI is active will close the gui and unpause the script if it's paused.
Default value: 0


Peep.display_with_gui {Integer}

If set to a positive number, Peep's custom GUI is used to display information.
If set to a negative number, the standard MsgBox() is used.
If set to zero, nothing is displayed. A Peep object is still returned for text retrieval.
Default value: 1


Peep.default_gui_btn {String}

Sets the default button to focus on GUI display.
This is also the button that will be activated when the Edit box has focus and enter is pressed.

Default value: resume


Peep.gui_w {Integer}

The default starting width for the GUI.
Default value: 600


Peep.gui_h {Integer}

The default starting height for the GUI.
Default value: 1000


Peep.gui_x {Integer}

The default starting X coordinate.
Default value: A_ScreenWidth / 2 - (Peep.gui_w/2) (Center of screen)


Peep.gui_y {Integer}

The default starting Y coordinate.
Default value: A_ScreenHeight / 2 - (Peep.gui_h/2) (Center of screen)

Changelog


v1.3

v1.2


v1.1


v1.0