-
dark_mode
indent_str
unset_value
var_ref_value
duplicate_ref_value
include_prim_type
include_string_quotes
include_end_commas
include_array_index
include_built_in
array_values_inline
key_value_inline
indent_closing_tag
gui_pauses_code
disable_gui_escape
display_with_gui
default_gui_btn
gui_w
gui_h
gui_x
gui_y
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:
- Allows you to quickly see inside (almost) any AHK v2 item
- Ensure objects are being constructed and arranged correctly
- Verify values/primitive types
- Information is displayed in a custom custom GUI
- GUI provides multiple features including code pausing, quick script closing and reloading, and a button to copy gui text to clipboard
- The main control is an edit box instead of a text box so you can pull smaller snippets from the displayed text
- A Peep object is always returned. This object can be called to return the text that was generated from that specific instance of Peep().
Peep's custom GUI:
Or using the default 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:
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)
If true, a dark theme is applied to the GUI.
Otherwise, a light theme is used.
Default value: 1
Character set to represent each level of indentation.
Normally spaces or tabs are used.
Default value: ' '
Peep.ind_type := " "
4 SpacesPeep.ind_type := "| "
Create a connecting pipe between elementsPeep.ind_type := "|---"
Create a grid effect
The indentifier used for values that are unset.
Default value: <UNSET>
The indentifier used for when a variable reference values.
Default value: <VAR_REF>
The indentifier used for any object that has already been referenced.
Default value: <DUPLICATE_REF>
If true, primitive value types are inclueded next to their values.
Default value: 0
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
If true, a comma separates multiple items.
The last item of an item set does not have a comma after it.
Default value: 1
If true, array items will include their index number before each item, starting at 1.
Default value: 0
If true, all native AHK objects will include their AHK assigned properties.
Default value: 1
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
If true, keys and values reside on the same line.
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
If true, code execution will pause when the Peep() GUI is shown.
This acts similarly to how MsgBox() works.
Default value: 1
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
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
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.
continue
orresume
= Closes the GUI and unpauses if script is paused state.reload
= Reloads the current running script. Useful when testing quick changes to a script.exit
= Closes the current running script.clipboard
= Save the displayed text to the clipboard.unpause
= Unpauses the script if it's currently in a paused state. The GUI will remain visible.
Default value: resume
The default starting width for the GUI.
Default value: 600
The default starting height for the GUI.
Default value: 1000
The default starting X coordinate.
Default value: A_ScreenWidth / 2 - (Peep.gui_w/2)
(Center of screen)
The default starting Y coordinate.
Default value: A_ScreenHeight / 2 - (Peep.gui_h/2)
(Center of screen)
- Fixed a problem where gui controls weren't parsed correctly as the script assumed they'd only come from enumerating a GUI.
- Complete rewrite of core logic.
- Updates to GUI
- Reload button added.
- Gui is now resizeable.
- Gui position and size is remembered between calls.
- This resets between reloads.
- Gui starting position and width can be set using the newly added properties:
- Peep.gui_w
- Peep.gui_h
- Peep.gui_x
- Peep.gui_y
- Added a dark mode property:
dark_mode
- Sets light/dark theme of the Peep GUI.
- Bug fixes
- Unset variables are now handled correctly.
- Alignment issues have been corrected.
- Circular reference protection has been added
- If item1 references item2 and item2 references item1, it won't crash the script.
Peep.examples.ahk
was rewritten and renamedPeep Instructions And Demo.ahk
- This script can be ran to demonstrate the different property options.
- This also provides code with Peep() being used.
- Added property to toggle end commas.
- Works well when
key_value_inline
is set to false.
- Works well when
- Added properties to set the strings used for
unset
values,VarRef
values, and duplicate object references. - Added JSDoc tags.
- This provides self-documenting calltips when using this script in VS Code with THQBY's v2 addon.
- Built-in property lists have been expanded and improved.
- Added an
Exit Script
button to close whatever script called peep() - Added ability to pass multiple variables/objects into peep().
Peep(var1, obj1, obj2, arr1)
- Added an
exit_on_close
property.
When set to true, the script that called Peep() will close when the GUI is closed.
- Initial commit