Looking for Lexikos "ExploreObj"

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
EvetsNalon
Posts: 11
Joined: 25 Aug 2018, 17:55

Looking for Lexikos "ExploreObj"

11 Sep 2018, 20:36

Hello, I have been following a ton of tutorials both text and video... In particular I am going thru one by Joe Glines that is used to connect to a Debug Instance of Chrome and then get data from it by using Class, Tag, Name or ID.. I do not seem to be having an issue with connecting I believe, but in this code he is using ExploreObj function..

Of course I could not get that to work at all, because it stops with an error that warned that that "function does not exist"...

So, as usual I begin to do the massive SEARCH for this function... I may be incorrect, but my guess would be that I would need to find that *ahk and #Include it before I could access it...

I found some (what was labeled as Test Area code) here: Dated back in 2011
https://autohotkey.com/board/topic/6436 ... re-object/

I copied that and saved it as ExploreObj.ahk and included it....

As I run the code, and am getting a ton of message windows regarding Keys and Values, but NO actual values are being output to the Debug Window.

Just these windows:
ExploringRootObejct_1.png
(46.17 KiB) Downloaded 101 times
ExploringRootObejct_2.png
(36.77 KiB) Downloaded 101 times
ExploringRootObejct_3.png
(25.22 KiB) Downloaded 101 times
Image



Further details... I am using his code that he gives the examples for which point to his website page, which of course I am also using for testing..

His site:

http://the-automator.com/

And here is the code:

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
;~ #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
;SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#Include ../Chrome.ahk
#Include ExploreObj.ahk
#Include %A_ScriptDir%

for Index, Tab in Chrome.GetTabs()
	MsgBox, % "type: " Tab.type "`nurl: " Tab.url

Tab := Chrome.GetTab() ;Connect to Active tab

;********************Methd: Class, Tag, Name, ID  **** ***********************************
data:=Chm_Get(Tab,Method:="class",Attribute:="widget-title",Index:=1)
;MsgBox % data.InnerText
;DebugWindow(ExploreObj(obj),1,1,200,0)
DebugWindow(ExploreObj(data),1,1,200,0)




;********************Method: Class, Tag, Name, ID  **** ***********************************
;********************Get Property***********************************
Chm_Get(Tab,Method="Class",Attribute="hfeed",Index=1){
 Obj:={}
 ;***********Class*******************
 if (Format("{:L}",Method)="Class"){ ;Case-insensitive check to see if method = Class
 Obj.OuterHTML:= Tab.Evaluate("document.getElementsByClassName('" Attribute "')[" Index-1 "].outerHTML").Value
 Obj.Value:= Tab.Evaluate("document.getElementsByClassName('" Attribute "')[" Index-1 "].value").Value
 Obj.InnerText:= Tab.Evaluate("document.getElementsByClassName('" Attribute "')[" Index-1 "].innerText").Value
 Obj.TextContent:= Tab.Evaluate("document.getElementsByClassName('" Attribute "')[" Index-1 "].textContent").Value
 } ;***********Tag*******************
 Else if (Format("{:L}",Method)="Tag"){  ;Case-insensitive check to see if method = Tag
 Obj.OuterHTML:= Tab.Evaluate("document.getElementsByTagName('" Attribute "')[" Index-1 "].outerHTML").Value
 Obj.Value:= Tab.Evaluate("document.getElementsByTagName('" Attribute "')[" Index-1 "].value").Value
 Obj.InnerText:= Tab.Evaluate("document.getElementsByTagName('" Attribute "')[" Index-1 "].innerText").Value
 Obj.TextContent:= Tab.Evaluate("document.getElementsByTagName('" Attribute "')[" Index-1 "].textContent").Value
 } ;************Name******************
 Else if (Format("{:L}",Method)="Name"){  ;Case-insensitive check to see if method = Name
 Obj.OuterHTML:= Tab.Evaluate("document.getElementsByName('" Attribute "')[" Index-1 "].outerHTML").Value
 Obj.Value:= Tab.Evaluate("document.getElementsByName('" Attribute "')[" Index-1 "].value").Value
 Obj.InnerText:= Tab.Evaluate("document.getElementsByName('" Attribute "')[" Index-1 "].innerText").Value
 Obj.TextContent:= Tab.Evaluate("document.getElementsByName('" Attribute "')[" Index-1 "].textContent").Value
 } ;***********ID*******************
 Else if (Format("{:L}",Method)="ID"){  ;Case-insensitive check to see if method = ID
 Obj.OuterHTML:= Tab.Evaluate("document.getElementById('" Attribute "').outerHTML").Value
 Obj.Value:= Tab.Evaluate("document.getElementById('" Attribute "').value").Value
 Obj.InnerText:= Tab.Evaluate("document.getElementById('" Attribute "').innerText").Value
 Obj.TextContent:= Tab.Evaluate("document.getElementById('" Attribute "').textContent").Value
 } Else{ MsgBox fix Attribute- Valid values are: Name, Class, Tag, ID
}
return obj
}


The output I am getting is JUST the labels:...
Debug Window

InnerText =
OuterHTML =
TextContent =
Value =


Image

Hmmmmm.. Any Ideas how I can make sure that I actually have the correct Include or Function... Or am I completely off the reservation here and totally incorrect

Thanks!
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Looking for Lexikos "ExploreObj"

12 Sep 2018, 17:28

Looking for Lexikos "ExploreObj"
I do not remember writing such a function, and I do not have any file by that name on my computer.

Perhaps Joe Glines can help.
Joe Glines wrote:
User avatar
FanaticGuru
Posts: 1906
Joined: 30 Sep 2013, 22:25

Re: Looking for Lexikos "ExploreObj"

12 Sep 2018, 18:45

lexikos wrote:
Looking for Lexikos "ExploreObj"
I do not remember writing such a function, and I do not have any file by that name on my computer.

Perhaps Joe Glines can help.
Joe Glines wrote:
Here is something simliar that I use:

Code: Select all

/*
; inspired by Lexikos ExploreObj()
PrintArr
   Prints the layout of an array (in text form) so that you can easily
   see the layout of it.

   array = The input array. Don't add the []'s.
   depth = How deep should we go if there are arrays within arrays?
   * indentLevel should not be touched as it's hard-coded in! DO NOT TOUCH.

example: st_printArr([["aaa","bbb","ccc"],[111,222,333]])
output:
[1]
    [1] ==> aaa
    [2] ==> bbb
    [3] ==> ccc

[2]
    [1] ==> 111
    [2] ==> 222
    [3] ==> 333
*/
st_printArr(array, depth=5, indentLevel="")
{
   for k,v in Array
   {
      list.= indentLevel "[" k "]"
      if (IsObject(v) && depth>1)
         list.="`n" st_printArr(v, depth-1, indentLevel . "    ")
      Else
         list.=" => " v
      list.="`n"
   }
   return rtrim(list)
}
It is from the String Things library by tidbit that gives you credit for inspiration.

But it seems that Learning One might have actually been the author of ExploreObj:

https://autohotkey.com/board/topic/6436 ... re-object/

Very useful. I use it all the time for a quick look at an array. It also helped me to learn how to recursively step through an array which was useful in other applications for me that did not even involve arrays.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
EvetsNalon
Posts: 11
Joined: 25 Aug 2018, 17:55

Re: Looking for Lexikos "ExploreObj"

12 Sep 2018, 19:24

lexikos wrote:
Looking for Lexikos "ExploreObj"
I do not remember writing such a function, and I do not have any file by that name on my computer.

Perhaps Joe Glines can help.
Joe Glines wrote:
Hello, Yes, just this evening I believe I have cleared this up.. Thanks for your input "Lexikos", and I apologize for the confusion.. After many hours trying to find references to this function... I did however find that you were contributed to its creation.. The [Function] ExploreObj.. However after a thorough repeat and diving deeper I found that
the creator of this function was actually a person that goes by the name on here of "Learning one" Thanks! ... to you "Learning One" for your contributions .....

Profile Icon Here:
LearningOne.png
(4.25 KiB) Downloaded 50 times
It does seem however, that as I have been researching, that as.. (You Have Often Done)...., You gave him/her very sound advice, and helped them clean up the code much better than originally written, as seen in this Archived Thread:

https://autohotkey.com/board/topic/6436 ... re-object/

Learning One's achievements page:

http://learning-one.comli.com/


Anyhow thanks again, and so sorry for the mix up.. Sometimes it is best to research to the "nth" degree in order to actually find what it is your looking for and not going on what others might have said..

I did, after seeing where and what it actually was, was able to figure out how this works.. Sorry, as I am still a bit of a "Noob" on this ..

As for "Joe Glines".... I like his tutorials and very much appreciate his effort to help myself and other get into and learning AutoHotkey and other languages as needed... Seems to be very busy at this time and has not been able to assist myself on this path of learning.. I get it.. It is what it is..

Still working out other details as I learn, which is a good thing I guess. Plugging along and sucking this all in like a sponge as quickly as I can..


Thanks again, and I hope that I never need any further assistance, but that is likely to be a False Assumption...

I Now have to Dive into this Chrome.AHK [Library} and figured it out ASAP..

Thanks!.. :D

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: CrowexBR and 268 guests