Code Monkey home page Code Monkey logo

peepahk's Introduction

Peep(AHKv2)

  1. What Is Peep()?

  2. How To Use

  3. Peep Properties

  4. Changelog


What Is Peep()?

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:

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.

  • continue or resume = 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


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

  • Fixed a problem where gui controls weren't parsed correctly as the script assumed they'd only come from enumerating a GUI.

v1.2

  • 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 renamed Peep 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.
  • 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.

v1.1

  • 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.

v1.0

  • Initial commit

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.