1
votes

I've been using Autohotkey for a while to access some elements on a webpage, I can do so just fine using: wb.document.elements[x].forms[x].value and assigning this to a value. I apologize but my knowledge of Javascript is very limited.

Recently I looked at the code for the page and noticed the following:

<script type="text/javascript" defer="defer"> 
form = new ActiveForm('EditingServiceInformationforSOMEGUY','Editing Service Information for SOME GUY');
    data = {};
    data.header = ["addressid", "contactid", "address1", "address2", "city", "state", "zip"];
    data.body = [["275101010", "254101010", "1001 Maudlin", "Apt. 1774", "Beverly Hills", "CA", "90210"]];

I have been unsuccessfully trying to access the data.body portion of this through AHK. If I type in the address bar while viewing the page:

javascript: alert(data.body[0])

I get a messagebox with the data.body values comma separated.

I can't seem to replicate this through Autohotkey. I've tried a lot of different syntax but I'm missing something here. I'd like to get a msgbox with the same values that I'm seeing in the Javascript Alert, and then further manipulate them from there.

I've tried many different combinations in my script to show data.body as the list of comma separated variables, but can't seem to get it to fire correctly.

My current AHK code is below, the line that attempts to assign tempvar is the one I can't get right.

Settitlematchmode, 2
WinGetTitle, Webstring, Title of the page
wb := IEGet(Webstring)

    tempvar := wb.document(data.header[0])
    msgbox % tempvar . "|" . Isobject(tempvar)
    IEGet(Name:="") {
        IfEqual, Name,, WinGetTitle, Name, ahk_class IEFrame
            Name := ( Name="New Tab - Windows Internet Explorer" ) ? "about:Tabs"
            : RegExReplace( Name, " - (Windows|Microsoft) Internet Explorer" )
        For wb in ComObjCreate( "Shell.Application" ).Windows
            If ( wb.LocationName = Name ) && InStr( wb.FullName, "iexplore.exe" )
                Return wb
    }
1
I cant answer to your question but maybe this link can help you: ahkscript.org/boards/viewtopic.php?f=6&t=5714vasili111

1 Answers

0
votes

@vasili111 was on the right track. Try this:

Settitlematchmode, 2
WinGetTitle, Webstring, Title of the page
wb := IEGet(Webstring)

IID := "{332C4427-26CB-11D0-B483-00C04FD90119}" ; IID_IHTMLWindow2
window := ComObj(9,ComObjQuery(wb,IID,IID),1)

    tempvar := window.data.header.0
    ; or use
    ;tempvar := window.eval("data.header[0]")

    msgbox % tempvar . "|" . Isobject(tempvar)
    IEGet(Name:="") {
        IfEqual, Name,, WinGetTitle, Name, ahk_class IEFrame
            Name := ( Name="New Tab - Windows Internet Explorer" ) ? "about:Tabs"
            : RegExReplace( Name, " - (Windows|Microsoft) Internet Explorer" )
        For wb in ComObjCreate( "Shell.Application" ).Windows
            If ( wb.LocationName = Name ) && InStr( wb.FullName, "iexplore.exe" )
                Return wb
    }