Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

COM IEGet() not working for popup


Best Answer Jackie Sztuk _Blackholyman , 27 October 2015 - 11:16 AM

Go to the full post »


  • Please log in to reply
3 replies to this topic
viper8690
  • Members
  • 6 posts
  • Last active: Oct 30 2015 03:40 PM
  • Joined: 19 Mar 2015

Hello all,

 

I am trying to access an <input> field on a popup. It seems that using IEGet() does not actually create the pointer.

 

this popup has a frame so I can access the desired input field with the following javascript from the console:

frames[0].document.forms[0].getElementsByTagName("input")[0].value := "test"

This is my script I'm trying:

IEGet(Name="")        ;Retrieve pointer to existing IE window/tab
{
    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
} ;written by Jethrow

WinWaitActive, Search and Select List of Values

pwb := IEGet("Search and Select List of Values")
MsgBox % IsObject(pwb)
sleep, 2000
pwb.frames[0].document.forms[0].getElementsByTagName("input")[0].value := "test"
return

The MsgBox returns 0 which tells me it's not getting the pointer. When I use iWB2Learner it shows the Title as a long URL. I've tried that as well but no luck.

 

I've also tried:

WBGet(WinTitle="ahk_class IEFrame", Svr#=1) 
{ ; based on ComObjQuery docs
   static   msg := DllCall("RegisterWindowMessage", "str", "WM_HTML_GETOBJECT")
   ,   IID := "{0002DF05-0000-0000-C000-000000000046}" ; IID_IWebBrowserApp
;   ,   IID := "{332C4427-26CB-11D0-B483-00C04FD90119}" ; IID_IHTMLWindow2
   SendMessage msg, 0, 0, Internet Explorer_Server%Svr#%, %WinTitle%
   if (ErrorLevel != "FAIL") {
      lResult:=ErrorLevel, VarSetCapacity(GUID,16,0)
      if DllCall("ole32\CLSIDFromString", "wstr","{332C4425-26CB-11D0-B483-00C04FD90119}", "ptr",&GUID) >= 0 {
         DllCall("oleacc\ObjectFromLresult", "ptr",lResult, "ptr",&GUID, "ptr",0, "ptr*",pdoc)
         return ComObj(9,ComObjQuery(pdoc,IID,IID),1), ObjRelease(pdoc)
      }
   }
}


WinWaitActive, Search and Select List of Values

pwb := WBGet()
MsgBox % IsObject(pwb)
sleep, 2000
pwb.frames[0].document.forms[0].getElementsByTagName("input")[0].value := "test"
return

This MsgBox returns 1 but I have a feeling it is using the other window titled "Invoice Management". Is there a way I can know if this is true? i.e. pwb.title.

 

any suggestions would be greatly appreciated.

 

Thanks,

 



Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012
✓  Best Answer
try reading this topic http://autohotkey.co...ed-with-paypal/
Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About

viper8690
  • Members
  • 6 posts
  • Last active: Oct 30 2015 03:40 PM
  • Joined: 19 Mar 2015

That did it. Didn't realize that I had to explicitly follow the DOM all the way down, since it was working in the console.

 

Thanks so much for helping me.  ;)



viper8690
  • Members
  • 6 posts
  • Last active: Oct 30 2015 03:40 PM
  • Joined: 19 Mar 2015

FYI to anybody stumbling across this post I added pwb.document.parentWindow to the beginning of the string so now it looks like this:

pwb.document.parentWindow.frames[0].document.forms[0].getElementsByTagName("input")[0].value := "test"