AutoHotkey Community

It is currently May 27th, 2012, 2:52 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: model window problem
PostPosted: November 19th, 2009, 6:24 pm 
Offline

Joined: November 19th, 2009, 6:23 pm
Posts: 163
Location: Florida
Hello,

I'm having a little problem. One of our sites we use has a model window pops up however I'm having a problem getting the controls from that window. I'm not sure what you guys need to help troubleshoot but if you have suggestions or can assist please let me know...

I'm trying to use COM_Invoke to get the controls, edit text boxes, etc when the window pops up...

Anytime I try to retrieve any information from controls or whatnot I get the parent window instead of the child window....

Thanks

EDIT: sorry its a model window, not modeless


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2009, 9:07 pm 
Try obtaining some spy information. IE HTML Element Spy is a good one to use as well.

HTH


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 25th, 2009, 2:29 pm 
Offline

Joined: November 19th, 2009, 6:23 pm
Posts: 163
Location: Florida
I use that a lot, I can get all sorts of stuff from the window but when it comes to actually accessing the window I can't do it. Everything I do goes back to the parent window instead I can't get to any of the items in the modal window.

as an example: I'm able to do:

javascript:window.showModalDialog('http://www.google.com','','')

and in autohotkey:

COM_Invoke(iWebBrowser2, "Document.parentWindow.execScript", "window.showModalDialog('http://www.google.com','','')")

but I cannot seem to pass parameters or grab values from the modal window


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 25th, 2009, 10:43 pm 
Offline

Joined: November 19th, 2009, 6:23 pm
Posts: 163
Location: Florida
here's some sample code

Code:
TestNewHotkey:
COM_init()
COM_CoInitialize()
;COM_Error(0)

GotIt = 0

DetectHiddenText, On   

GoSub, COMInitializeTest
WinGet, AHKSite_ID, ID, AutoHotkey
WinGetTitle, AutoHotkey, ahk_id %AHKSite_ID%
AHKWeb = ahk_id %AHKSite_ID%
WinWait, %AHKWeb%
IfWinNotActive, %AHKWeb%, ,WinActivate, %AHKWeb%
WinWaitActive, %AHKWeb%
Sleep, 1000
COM_Invoke(iWebBrowser2, "Document.parentWindow.execScript", "window.dialogArguments.getElementsByTagName('input').item[2].focus()")  ;focus in search box
Sleep, 500
COM_Invoke(iWebBrowser2, "Document.parentWindow.execScript", "window.dialogArguments.getElementsByTagName('input').item[3].focus()")  ;focus on first search button
Sleep, 500
COM_Invoke(iWebBrowser2, "Document.parentWindow.execScript", "window.dialogArguments.getElementsByTagName('input').item[4].focus()")  ;focus on second search button

COM_CoUnInitialize()
COM_Term()
Return

COMInitializeTest:
GotIt=0
COM_init()
COM_CoInitialize()
website := "http://www.autohotkey.com"
SearchTestSiteAgain:
psh   :=   COM_CreateObject("Shell.Application")
psw   :=   COM_Invoke(psh,   "Windows") ; note this captures windows explorer windows as well
Loop, %   COM_Invoke(psw,   "Count")
{
   LocationURL := COM_Invoke(psw,"Item[" A_Index-1 "].LocationURL")
   IfInString, LocationURL,%website%
   {
      GotIt=1
      iWebBrowser2         :=   COM_Invoke(psw,"Item",A_Index-1)
      break   
   }
   Else
   {
      GotIt=0
   }
}
COM_Release(psw),   VarSetCapacity(psw,   0),   COM_Release(psh),   VarSetCapacity(psh,   0)
TryAgain_GetTestSite:
if(GotIt=0)
{
   iWebBrowser2 := COM_CreateObject("InternetExplorer.Application")
   COM_Invoke(iWebBrowser2 , "Visible", "True")
   ; this is an optional first part of code
   ;open a page
   COM_Invoke(iWebBrowser2,"Navigate","http://www.autohotkey.com")
   ; make sure the page has loaded
    loop 80                     ;   sets limit if itenerations to 40 seconds 80*500=40000=40 secs
   {   
      Sleep,500               ;   sleep half second between cycles
      If (rdy2:=COM_Invoke(iWebBrowser2,"readyState")) = 4
         break           ;   break the loop the page has loaded
   }
   GoTo, SearchTestSiteAgain
}
Else
{
   COM_Invoke(iWebBrowser2,  "Document.parentWindow.execScript", "window.showModalDialog('http://www.google.com','','')")
}
   
RETURN


I get a javascript error but thats minor...I think the code above might act wierd it might not do anything unless you close the modal window after its opened, if it does that can just do
Code:
javascript:window.showModalDialog('http://www.google.com','','')

I can't seem to get into that modal window to do anything....


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2009, 1:53 pm 
Offline

Joined: November 19th, 2009, 6:23 pm
Posts: 163
Location: Florida
no one knows?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2009, 6:59 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
Code:
iwebbrowser2fortheMODAL:=iweb_getwin(""windowtitle")


you must get a browser handle for the MODAL that is separate from the parent window
iWeb Functions

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 30th, 2009, 2:16 pm 
Offline

Joined: November 19th, 2009, 6:23 pm
Posts: 163
Location: Florida
2 problems with this so far
1) its running awfully slow activating the window
2) its not sending the commands to the modal window...

it will do the commands for a normal web page though...


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: rbrtryn, Yahoo [Bot] and 21 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group