object pointer to object variable name

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

object pointer to object variable name

23 Jan 2018, 12:19

- Here's an object pointer to object variable name example.
- It shows a window temporarily, but ScriptInfo can suppress that.
ScriptInfo(): Get ListLines/ListVars/ListHotkeys/KeyHistory text - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=9656
- Another interesting link.
DebugVars - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=24984

Code: Select all

q:: ;object pointer to object variable name
oArray1 := {}
oArray2 := {}
oArray3 := {}
MsgBox, % ObjGetVarName(oArray1)
MsgBox, % ObjGetVarName(oArray2)
MsgBox, % ObjGetVarName(oArray3)
return

ObjGetVarName(ByRef oArray)
{
	ListVars
	WinWaitActive, ahk_class AutoHotkey
	vPtr2 := &oArray
	;MsgBox, % Format("0x{:X}", vPtr2)
	Loop
	{
		ControlGetText, vText, Edit1, ahk_class AutoHotkey
		if InStr(vText, ": Object object {address: ")
			break
		Sleep, 100
	}
	WinHide, ahk_class AutoHotkey
	Loop, Parse, vText, `n, `r
	{
		vTemp := A_LoopField
		if (vTemp = "Global Variables (alphabetical)")
			vOutput := ""
		if !vPos := InStr(vTemp, ": Object object {address: ")
			continue
		vPtr := SubStr(vTemp, vPos+26, -1)
		;MsgBox, % "[" vPtr "]"
		if (vPtr = vPtr2)
			vOutput .= vTemp "`r`n"
	}
	;MsgBox, % Clipboard := vOutput
	return SubStr(vOutput, 1, -2)
}
return
Last edited by jeeswg on 23 Jan 2018, 13:53, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: object pointer to object variable name

23 Jan 2018, 12:55

It gets stuck in the first loop. It works if I just do ControlGetText ....

Thanks for sharing, cheers.
User avatar
derz00
Posts: 497
Joined: 02 Feb 2016, 17:54
Location: Middle of the round cube
Contact:

Re: object pointer to object variable name

23 Jan 2018, 12:56

Code: Select all

q::
code := Clipboard
code := StrReplace(code, "if InStr(vText, "": Class object {address: "")", "if InStr(vText, "": Object object {address: "")")
Clipboard := code
ExitApp
Cheers.
try it and see
...
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: object pointer to object variable name

23 Jan 2018, 13:53

- Thanks derz00, the first InStr said 'Class object', but both should say 'Object object'. I've corrected it.
- Oh so Helgef, do you not use object classes? I thought you liked them hehe.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: object pointer to object variable name

23 Jan 2018, 16:24

Hehe, does it work for object classes?
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: object pointer to object variable name

23 Jan 2018, 16:55

- Not currently, I could try to change it (it should be fairly straightforward).
- It's just based on what ListVars shows, which is Class object, Object object, and regular variables.
- But ListVars only shows the address for Class object and Object object.
- So ListVars is quite handy for letting you see all the classes that are defined.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: fiendhunter and 229 guests