DebugVars

Post your working scripts, libraries and tools
lexikos
Posts: 6668
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

DebugVars

26 Nov 2016, 22:48

DebugVars

DebugVars is a script for AutoHotkey v1.1 which allows users to view and edit variables of other scripts while they are running.

The initial release was tested only on AutoHotkey v1.1.24.03.

It can connect to non-compiled scripts running on AutoHotkey v1.1 and v2-alpha.

It also contains the following reusable class-based components:
  • TreeListView: A ListView control adapted to show a "tree" of items, with "in-cell editing".
  • VarTreeGui: A GUI for editing a tree of properties. A sample script uses it to edit properties of the script's own objects.
  • VarEditGui: A GUI for editing a value, with a drop-down for type (string, integer or float).
  • DebugVarsGui: Extends VarTreeGui to provide the main functionality of the script.
I have also integrated it into SciTE4AutoHotkey's debugger.

Image

Details and Downloads
Helgef
Posts: 4031
Joined: 17 Jul 2016, 01:02
Contact:

Re: DebugVars

27 Nov 2016, 04:37

On AHK unicode 64. 1.1.22.09

Code: Select all

---------------------------
DebugVars.ahk
---------------------------
Error in #include file "...\DebugVars\TreeListView.ahk":
     Invalid Gui name.

Specifically: :Default

	Line#
	641: Return,scope
	642: }
	645: {
	646: this.prev_gui := A_DefaultGui  
	647: this.prev_lv := A_DefaultListView  
	648: }
	649: {
--->	650: Gui,this.prev_gui ":Default"
	651: if (this.prev_lv != "")  
	652: Gui,ListView,this.prev_lv
	653: }
	657: {
	658: Throw,Exception("Unknown method", -1, name)
	659: }
	660: {

The current thread will exit.
---------------------------
OK   
---------------------------

The list showed, and the variables, but when I clicked the tree it I got errors.

Updated to 1.1.24.03, no errors.
Looks very useful, thanks!
lexikos
Posts: 6668
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: DebugVars

27 Nov 2016, 22:01

I used A_DefaultGui (v1.1.23+) and didn't bother with backward-compatibility or testing old versions.
treashunter

Re: DebugVars

29 Nov 2016, 08:11

This is spectacular!

Thanks Lexikos!
guest3456
Posts: 2774
Joined: 09 Oct 2013, 10:31

Re: DebugVars

01 Dec 2016, 08:49

1. what do you think about a monospaced font for the Inspection popup?

2. i typically do a lot of MsgBox, myvar=%myvar%`nmyvar2=%myvar2% tedious debugging stuff. how would i modify this so that i can replace it with a simple DebugVars(myvar, myvar2) and get a popup with just those variables?

lblb
Posts: 129
Joined: 30 Sep 2013, 11:31

Re: DebugVars

02 Dec 2016, 12:32

What a great tool. Thanks Lexikos for your work on this (and for all the time and effort you've put into AHK).
lexikos
Posts: 6668
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: DebugVars

02 Dec 2016, 17:46

guest3456,
1. I prefer it as is, but you're free to change anything you want.
2. You can't; at least, not exactly.

The script can't connect to itself.

Instead, you can use the base VarTreeGui as demonstrated in VarTree_test.ahk, but you will be limited to objects and global variables. You cannot retrieve or modify local variables of another function. You could pass their names and values to the function (or via an object), but you could not modify them.

Alternatively, you could run the debugger client (a script like DebugVars.ahk) as a separate process and use some means of inter-process communication to send it instructions, such as "show variables myvar and myvar2". Just don't use a method that blocks the script thread and prevents debugger commands from executing.

One novel method of communication would be to use a breakpoint in an empty function. On begin (i.e. in DebugBegin), set the breakpoint with breakpoint_set. On break, query the parameter value with property_get. If there's a return value, set it with property_set. Finally, resume with run. Of course, it's probably not the easiest communication method.
JJohnston2
Posts: 193
Joined: 24 Jun 2015, 23:38

Re: DebugVars

17 Dec 2016, 20:09

Thanks for making this available... the GUI is very intuitive and especially helpful with multiple scripts running.
User avatar
hoppfrosch
Posts: 374
Joined: 07 Oct 2013, 04:05
GitHub: hoppfrosch
Location: Rhine-Maine-Area, Hesse, Germany
Contact:

Re: DebugVars

04 Jan 2017, 03:15

@lexikos: I tried to use your great new tool/feature within Scite4AutoHotkey. But it seems your changes broke the use of Breakpoints ... at least they don't work anymore here (within Scite4AutoHotkey):
  • if I set a breakpoint before starting debugging, the red breakpoint dot occurs on the selected line within Scite4AutoHotkey. Starting Debugging the breakpoint (red dot) disappears ...
  • While being in Debugging mode I cannot set any new breakpoint (from https://www.fincs.ahk4.net/scite4ahk/pages/debugger.htm: "In order to set a breakpoint on a line, click on the margin to the right of the line numbers" - this does not work here anymore, but used to work before updating).
What I did for updating Scite4AutoHotKey:
  • Cloned the modified sources from https://github.com/Lexikos/SciTE4AutoHotkey.git
  • Overwrote all files withinin my {SCITE_INSTALLDIR}\Tools directory with the contents of [GITCLONE}\tools directory
  • Replaced InternalAHK.exe with latest AutoHotkey Version 1.24.0.4 Unicode 32bit
Did I miss anything - or is the use of breakpoints really broken?
lexikos
Posts: 6668
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: DebugVars

05 Jan 2017, 01:15

You missed ahk.lua.
User avatar
hoppfrosch
Posts: 374
Joined: 07 Oct 2013, 04:05
GitHub: hoppfrosch
Location: Rhine-Maine-Area, Hesse, Germany
Contact:

Re: DebugVars

05 Jan 2017, 02:39

Thx lexikos, but it still doesn't work - beside the actions above, I replaced the following files (from git-repositry into Scite-directory):
  • source\ahk.api
  • source\ahk.keywords.properties
  • source\ahk.lua
  • source\ahk2.api
  • source\ahk2.properties
  • source\platform.properties
  • source\SciTEGlobal.properties
  • source\toolbar\lib\ComInterface.ahk
  • source\toolbar\lib\SciTEDirector.ahk
  • source\toolbar\lib\Toolbar.ahk
I identified those files as changed by using a compare tool.

Now I cannot set a breakpoint by clicking in any case (ret dot is not set) ... (in previous case it was still set, before starting debugging) ...
HotKeyIt
Posts: 1889
Joined: 29 Sep 2013, 18:35
Contact:

Re: DebugVars

05 Jan 2017, 08:46

@hoppfrosch, see here, you can download the zip evilC created and replace all files in your directory.
User avatar
hoppfrosch
Posts: 374
Joined: 07 Oct 2013, 04:05
GitHub: hoppfrosch
Location: Rhine-Maine-Area, Hesse, Germany
Contact:

Re: DebugVars

06 Jan 2017, 00:43

@HotKeyIt: Awesome - thanks! This solved my problem magically :-)
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: DebugVars

09 Jan 2017, 02:47

I needed these files in the Lib folder (plus the latest AHK version)
to get it working:
GitHub - Lexikos/dbgp: DBGp client scripts for AutoHotkey_L
https://github.com/Lexikos/dbgp

Thanks so much for this script!
The GUI is really nice too.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
lexikos
Posts: 6668
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: DebugVars

09 Jan 2017, 02:53

jeeswg wrote:I needed these files in the Lib folder
Before running the script, ensure that dbgp.ahk is installed in your function library (Lib directory), or save it at .\Lib\dbgp.ahk, where . is the directory containing DebugVars.ahk.
Source: Lexikos/DebugVars.ahk: View and edit variables of other AutoHotkey scripts while they are running.
It's the third paragraph in the readme. :roll:
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: DebugVars

09 Jan 2017, 03:36

Yeah you got me there. Although ...
Md file not supported, and if open it in Notepad,
have to convert LFs to CRLFs!!!

Btw I couldn't find A_IconHidden,
even after jogging the script with
'#NoTrayIcon', 'Menu, Tray, Icon' and 'Menu, Tray, NoIcon',
is it a special unreachable variable?

[EDIT]
OK I can now quickly 'Open with Notepad' in 7-Zip.
All is right with the world. Those readmes are now more readable.

Code: Select all

#IfWinActive, ahk_class FM ahk_exe 7zFM.exe
+Enter:: ;7-Zip - open file in Notepad ('right-click, Edit')
SendInput {F4}
Return
#IfWinActive
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
lexikos
Posts: 6668
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: DebugVars

10 Jan 2017, 03:31

GitHub shows the readme content, in its fully formatted glory, on the main page, which I linked to twice. Once with "Details and Downloads" and once when I quoted the readme.
Md file not supported, and if open it in Notepad,
have to convert LFs to CRLFs!!!
Supported? By what? It's just a text file. As for the line endings, that's a side-effect of git, and would likely happen with ".txt" files as well. If you clone (download) the repository using git on Windows (with default settings), it will convert the line endings back to `r`n automatically.
Btw I couldn't find A_IconHidden
The debugger engine only returns variables which are referenced by the script.
lexikos
Posts: 6668
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: DebugVars

27 Jan 2017, 03:11

You could simply change the ahk.debugger.max.obj.children property.

The other way would be to use the paging parameter -p with property_get/context_get.

I don't plan to develop the script in any way, and haven't encountered a need to view >100 elements.
User avatar
kczx3
Posts: 932
Joined: 06 Oct 2015, 21:39

Re: DebugVars

04 Mar 2017, 20:09

I was playing around with ListViews and Header controls this weekend and stumbled upon this glorious post. Because the post as a whole references DebugVars, I don't know that TreeListView.ahk is getting the love that it deserves. That being said, I typically prefer using the Explorer theme for my ListView and TreeViews. When applying this to a TreeListView, a selected row's color changes back to the boring blue when a column header is being resized. Any thoughts as to avoiding that (aside from not using the Explorer theme)?

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Chunjee and 59 guests