AutoHotkey Community

It is currently May 26th, 2012, 6:58 pm

All times are UTC [ DST ]




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 215 posts ]  Go to page Previous  1 ... 7, 8, 9, 10, 11, 12, 13 ... 15  Next

Do you find this group pf wrapper functions for IE Automation Usefull
no you suck 8%  8%  [ 3 ]
need better Documentation 28%  28%  [ 10 ]
What is DHTML i dont understand how this helps 11%  11%  [ 4 ]
I use Firefox this is a stupid idea 28%  28%  [ 10 ]
I know DHTML this is a reasonably good AHK adaption 6%  6%  [ 2 ]
This is the best DHTML too in the AHK Forum 19%  19%  [ 7 ]
Total votes : 36
Author Message
PostPosted: May 14th, 2009, 2:44 am 
tank wrote:
Code:
COM_Init()
run iexplore.exe http://www.autohotkey.com/
WinWait,AutoHotkey,,5
sleep,1000
myPageHandle:=IE7_Get("autohotkey")
;~ MsgBox % myPageHandle
IE7_readyState(myPageHandle) ;  waits for onload event of a webpage even if an onload isnt fired
IE7_Click_Text(myPageHandle,"forum") ; cycles thru the links collection and clicksthe first text match it finds then waits for the page load to complete

IE7_Click_Text(myPageHandle,"search")
IE7_Set_DOM(myPageHandle,"search_keywords","PLEASE HELP!! why is my thingy not working as expected?") ;example of filling out a form
IE7_Button_click(myPageHandle,"search")
IE7_Click_Text(myPageHandle,"PLEASE HELP!! why is my thingy not working as expected?")
MsgBox, 262192, Meet the Robinsons, Please Read the first Post before asking me any questions, 5
IE7_Click_Text(myPageHandle,"search")
IE7_Set_DOM(myPageHandle,"search_keywords","Automation IE7 Navigation and Scripting with Tabs") ;example of filling out a form
IE7_Button_click(myPageHandle,"search") ; click a button labeled search and wait for the page to load
IE7_Click_Text(myPageHandle,"Wait for page to load before execute next command")
MsgBox, 262192, Automation IE7 Navigation and Scripting with Tabs, 5
COM_Term()
ExitApp

the above gives an example of opening a page and clicking links and filling out web forms then clicking buttons
What file do I need to download to run this script? I get Call to non existent function, IE7_get.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2009, 4:30 am 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
read the thread start at the beginning
go ahead i know you can read :P

_________________
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: May 14th, 2009, 5:48 am 
tank wrote:
read the thread start at the beginning
go ahead i know you can read :P

I have been reading.
I am looking for the IE7 functions.
I know to use #include com.ahk or whatever the filename is.
I know to put the file IE..com.ahk in the lib folder.

What I don't know is where are the IE7 functions.

I have copied every bit of code that could possible be the IE7 functions and put them in a file named IE7.ahk in the lib folder. Obvisously I have not found the IE7 functions.

Please be patient with me, I am not asking you to write my code. I started reading about your com functions a month ago.

I am trying to learn com functions without asking for help because I am afraid of replies like yours.

As a matter of fact, I am posting as guest because I was certain I would get a RTFM response.

I have seen sooo many RTFM replies it makes me cautious of posting any questions.

I have been reading the forum for over a year and written probably 50 scripts. Some of them very large. The largest being over 5500 lines of code.

I am now beginning to learn functions and need to be guided in the right direction.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2009, 6:18 am 
Is the IE7_Nav the IE7 functions needed for the script below?
I figured the IE7 functions would be on the first page. I have read the first page 10 times. I tried using the IE7_Nav function and still can not get your script to work.
Code:
COM_Init()
run iexplore.exe http://www.autohotkey.com/
WinWait,AutoHotkey,,5
sleep,1000
myPageHandle:=IE7_Get("autohotkey")
;~ MsgBox % myPageHandle
IE7_readyState(myPageHandle) ;  waits for onload event of a webpage even if an onload isnt fired
IE7_Click_Text(myPageHandle,"forum") ; cycles thru the links collection and clicksthe first text match it finds then waits for the page load to complete

IE7_Click_Text(myPageHandle,"search")
IE7_Set_DOM(myPageHandle,"search_keywords","PLEASE HELP!! why is my thingy not working as expected?") ;example of filling out a form
IE7_Button_click(myPageHandle,"search")
IE7_Click_Text(myPageHandle,"PLEASE HELP!! why is my thingy not working as expected?")
MsgBox, 262192, Meet the Robinsons, Please Read the first Post before asking me any questions, 5
IE7_Click_Text(myPageHandle,"search")
IE7_Set_DOM(myPageHandle,"search_keywords","Automation IE7 Navigation and Scripting with Tabs") ;example of filling out a form
IE7_Button_click(myPageHandle,"search") ; click a button labeled search and wait for the page to load
IE7_Click_Text(myPageHandle,"Wait for page to load before execute next command")
MsgBox, 262192, Automation IE7 Navigation and Scripting with Tabs, 5
COM_Term()
ExitApp


Report this post
Top
  
Reply with quote  
PostPosted: May 14th, 2009, 6:27 am 
tank wrote:
need better Documentation now has 3 votes in it but no one posts questions
if there are no questions how am i to give you all better documentation
Afraid of RTFM responses.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2009, 6:49 am 
Found them, thanks for telling me to do something I had already done.

A side from all the BS of you not helping me. I do appreciate the hard work you put into the documentation to help newbies.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2009, 7:38 am 
Now I understand what is happening.

The IE7 functions you posted as New code on the first page do not work with this script you wrote.

I had to use the Old code.

Nice scripting.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2009, 2:56 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
The point i was making you have made for me
you put some effort into it and figured it out. I'll take the hit if some code wasnt updated but as you saw on your own the info is there for you to learn from.
Nothing i could do for you would have taken you thru the discovery and learning process as effectively as me refusing to repost already present info
I am glad you worked on this on your own. I consistently refuse to help when its obvious to me that somone hasnt at least tried to do there homework.
Now that you have if you have specific questions I would entertain them

_________________
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: May 14th, 2009, 3:51 pm 
tank wrote:
I consistently refuse to help when its obvious to me that somone hasnt at least tried to do there homework.
You were absolutely wrong here. "someone hasnt at least tried to do there homework".

I did do my homework, several times. I even used the "New Code" and it did not work. You were too trigger happy to assume I did not read the thread. You probably thought I came across your code in a search and never read the 1st page. Actually I started at the first page then came across your code.

Sometimes you guys need to realize some times people are very slow to learn, and everyone has their own learning style.

Mine happens to be in this order.
1. Read the forum and help file
2. Try someones code, see how it works
3. Modify their code for my needs.
4. At that point I start to understand how it works.

That is what I was trying to do here. Test your code. See how it works then apply it to my needs.

thanks for your help.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2009, 4:47 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
you really need to read my earliest posts on this forums before you judge me on this
I was more lost than you
and folks like Lexikos and Sean initially gave me as little as possible because they too knew there are things i just had to figure out for myself. I can only get you close i cant spell everything out I have to insist that you experiment and try. as you have proven the answers were there
You really didnt need me to help you needed to try more

_________________
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: May 14th, 2009, 4:48 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
Anonymous wrote:
I did do my homework, several times. I
Nothing in your post indicates that you did anything except copy a code block and post it and say i cant get it to work

_________________
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: May 14th, 2009, 6:18 pm 
You are right, I got to thinking about my first post. I should have indicated in that post what I had tried. I will do better next time.
thanks


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2009, 5:31 am 
Offline

Joined: March 18th, 2008, 4:04 am
Posts: 193
getting js script code from IE7 instance

if html is using link to js like:
<script src="myscript.js" type=text/javascript>

after I get the IE7 instance and getting it's window or document Object
is it possible to get in string all the functions code of myscript.js ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 28th, 2009, 1:38 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
Sorry for not responding sooner
I have no reason to ever do this
i spose you could use something like
Code:
file:=com_invoke(pwb,"document.all.tags.item[script].item[1].src")
and then if its a relative partial path chop off the file name from the locationURL and use it for the path then load it in a browser or use url download to var
Sorry I cant think of a good reason to bother with this tho

_________________
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: June 24th, 2009, 2:30 am 
Offline

Joined: June 24th, 2008, 8:30 am
Posts: 126
I have been using the Dom Extractor (Great tool Tank, thanks for creating, sharing, and supporting)

Just recently (today really) It has started kicking back an error when i try to "Get Window".

Here is the error:
Quote:
Function Name: "execScript"
ERROR: Access is denied.
(0x80070005)
PROG:
DESC: Access is denied.

HELP: C:\Windows\system32\mshtml.hlp,0

ERROR2: Not implemented
(0x80004001)

Will Continue?


I've disabled antivirus, firewall, etc. thinking it possibly is being blocked or something to that effect, but nothing will change it. I haven't made any changes at all to the script, not sure what the problem is. Especially since I have used it a number of times, and after using it 4 or 5 times today, all of the sudden that error started showing up.

Any ideas?

Here is the code that I am using:
Code:

;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         A.N.Other <myemail@nowhere.com>
;
; Script Function:
;   Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
#Include Com.ahk

COM_Init()



clickinfo=
(
function whichElement()
{
tname=event.srcElement.tagName;
tindex=event.srcElement.sourceIndex;
tid=event.srcElement.id;
name=event.srcElement.name;
val="";
switch(tname.toLowerCase())
{
case "input":
   val=event.srcElement.value;
   typ=event.srcElement.type
   if (typ.toLowerCase()=="button"){
   event.srcElement.disabled='true';
   }
   if (typ.toLowerCase()=="submit"){
   event.srcElement.disabled='true';
   }
   if (typ.toLowerCase()=="image"){
   event.srcElement.disabled='true';
   }
   if (typ.toLowerCase()=="reset"){
   event.srcElement.disabled='true';
   }
innerhtml=val;
  break;   
case "a":
   event.srcElement.onclick="";
   link = "\nLink = "+event.srcElement.href
innerhtml=event.srcElement.innerHTML+link;
   event.srcElement.href="javascript:Void(0)";
  break;
case "select":
   val=event.srcElement.value;
innerhtml=val;
  break;
default:
innerhtml=event.srcElement.innerHTML
}
}
    document.body.onmousedown = whichElement
)
instructions=
(
1`) Enter a title
2`) Click Get Window
3`) Click the location on the browser window you need info on
4`) Click Get Dom
)
Gui, Add, Text, x6 y10 w130 h20 , Enter the Page Title
Gui, Add, Edit, x6 y30 w210 h20 vWintitle,
Gui, Add, Text, x6 y50 w310 h60 , % instructions
Gui, Add, Button, x216 y30 w90 h20 gGetwin, Get Window
Gui, Add, Button, x6 y110 w90 h20 gGetDom, Get Dom
Gui, Add, Edit, x6 y130 w310 h90 vDom,

Gui, Show, h225 w320, DOM Extractor
Return

GuiClose:
ExitApp

Getwin:
Gui,Submit,NoHide
COM_Init()
parentWindow:=IE7_Get(Wintitle)
IE7_ExecuteJS(parentWindow, clickinfo)

return
GetDom:
tname:=IE7_ExecuteJS(parentWindow, "","tname")
tindex:=IE7_ExecuteJS(parentWindow, "","tindex")
tid:=IE7_ExecuteJS(parentWindow, "","tid")
name:=IE7_ExecuteJS(parentWindow, "","name")
innerhtml:=IE7_ExecuteJS(parentWindow, "","innerhtml")
GuiControl,Text,Dom,% "Dom accessable objects for document`.all collection `nElement type (" . tname . ")`nIndex (" . tindex . ")`nID attribute if any (" . tid . ")`nName attribute if any (" . name . ")`nhtml value = " . innerhtml
return

;https://www.merlindata.com/SearchASPs/Loc/sql/ca/UW/Query.ASP
;~ ******************************************************************************************
;~ ******************************************************************************************
;~ IE 7 functions
;~ ******************************************************************************************
;~ ******************************************************************************************
;~ function list
;~ IE7_Get(title,url="http") gets iwebrowser interface pointer and returns automation dhtml window obj ie parentWindow used itn the below functions
;~ IE7_Navigate(parentWindow,url)  Navigate and wait for page Load to complete in same frame
;~ IE7_ExecuteJS(parentWindow, JS_to_Inject, VarNames_to_Return="") Full insertion of javascript or execution or retrieval of new or existing fucntions or variables
;~ IE7_readyState(parentWindow) wait for page Load to complete
;~ IE7_Quit(parentWindow) Closes Window
;~ IE7_New(url) Loads a new window even if one does not currently exist and wait for page Load to complete in same frame
;~ IE7_Click_Text(parentWindow,innerHTML)Clicks a link byt text in the inner html of the a tag and wait for page Load to complete in same frame
;~ IE7_Click_Element(parentWindow,ID1=0) ; clicks first element it finds to match returns error if not found will also trigger readystate
;~ IE7_Button_click(parentWindow,value)Click a button based on the text of the button and wait for page Load to complete in same frame
;~ IE7_Get_DOM(parentWindow,ID1)retreive a dom object by index of all collection id or name attribute
;~ IE7_Set_DOM(parentWindow,ID1,val="innerHTML") set  a dom object by index of all collection id or name attribute
;~ ******************************************************************************************
;~ ******************************************************************************************
IE7_Get(title,url="http")
{
;~    title is required and is not case sensitive
;~    url is optional and since . exists in all url schemas it will allow un entered url to default to first found
;~  loop thru open windows for a match
   Loop, %   COM_Invoke(psw := COM_Invoke(COM_CreateObject("Shell.Application"), "Windows"), "Count")
   {
      If ( InStr(tabname:=COM_Invoke(COM_Invoke(psw, "Item", A_Index-1), "LocationName"),title,0)) && (InStr(taburl:=COM_Invoke(COM_Invoke(psw, "Item", A_Index-1), "LocationURL"),url,0) )
      {
         parentWindow:=COM_Invoke(COM_Invoke(COM_Invoke(psw, "Item", A_Index-1), "Document"), "parentWindow")
         COM_Release(taburl),COM_Release(tabname)
         Break
      }
      COM_Release(taburl),COM_Release(tabname)
   }
   COM_Release(psw) ; release the objects each loop itineration
   if parentWindow is integer
   {
      return parentWindow
   }
   else
   {
      Return error   
   }
}

;~ Navigate the given window
IE7_Navigate(parentWindow,url) ; begins navigation process and holds execution till page has loaded fully returns DOM window handle
{
;~    parent windw is a Dom window object
   if parentWindow is integer
   {   
      COM_Invoke(parentWindow, "Navigate",url) ;execute the navigation   
      IE7_readyState(parentWindow) ;Holds till document onload event is ready
      Return parentWindow
   }
   else{
      Return error   
   }
}


IE7_ExecuteJS(parentWindow, JS_to_Inject, VarNames_to_Return="") ;execute some js on a tab returns comma delimited list of vars if specified
{
   if parentWindow is integer
   {
     
  ;    If VarNames_to_Return
  ;    {
   ;      StringSplit, Vars_, VarNames_to_Return, `,
  ;       Loop, parse,VarNames_to_Return,`,
  ;          COM_Invoke(parentWindow, "execScript","var " . A_LoopField . " = undefined;")
  ;    }
      If JS_to_Inject
         COM_Invoke(parentWindow, "execScript",JS_to_Inject)
      If VarNames_to_Return
      {
         StringSplit, Vars_, VarNames_to_Return, `,
         Loop, %Vars_0%
            Ret .= COM_Invoke(parentWindow,Vars_%A_Index%) . ","
         COM_Release(Ret)         
         StringTrimRight, Ret, Ret, 1
         Return Ret
      }
         Else
         Return 0
   }
   Else
      Return error
}
IE7_readyState(parentWindow) ;pauses till there is no loading activity returns DOM window handle
{
   
   
   if parentWindow is integer
   {
      doc:=COM_Invoke(parentWindow, "Document")
      if not doc is integer
         return error
;~    MsgBox % COM_Invoke(parentWindow, "Document")   
      loop 120{ ;limit to 60 seconds
         Sleep, 500
         rdy:=IE7_ExecuteJS(parentWindow, "var rdy=document.readyState","rdy") ; best method
         If (rdy = "complete") ;Better to use the document readystate more consistent page load results
            break
         }
      COM_Release(doc)
      Return 0
   }
   else
      Return error   
   
}
IE7_Quit(parentWindow) ;Close a DOM window handle
{
   COM_Invoke(parentWindow, "execScript","window.opener='top';window.close();")
}

IE7_New(url) ;only if at least one IE window already exists return parentWindow js accessable object returns DOM window handle
{
   run http://Google.com
   winwait,Google
   parentWindow:=IE7_Get("Google")
   parentWindow:=IE7_Navigate(parentWindow,url)
   return parentWindow ; object handle
}


IE7_Click_Text(parentWindow,innerHTML) ; searches a tags and clicks first text it finds to match returns error if not found will also trigger readystate
{
   js=
   (
      var links=document.links;
      var count=links.length;
   )
   
   count1 := IE7_ExecuteJS(parentWindow, js, "count")
   loop, % count1
   {
   
      js=
      (
         var text=document.links(%A_Index%-1).innerHTML;
      )
      text1 := IE7_ExecuteJS(parentWindow, js, "text")
      IfNotInString,text1,%innerHTML%
      Continue ;skip the rest and go to next loop
      js=
      (
         document.links(%A_Index%-1).click();
      )
      IE7_ExecuteJS(parentWindow, js)     
      Break
   }
IE7_readyState(parentWindow) ; wait for page change to finish
Return
}

IE7_Click_Element(parentWindow,ID1=0) ; clicks first element it finds to match returns error if not found will also trigger readystate
{
   clickme=
   (
     
   if (isNaN("%ID1%")){ // determins if an index or id is entered
         document.all("%ID1%").click();
      }else{ // must be an index
         document.all(%ID1%).click();
      }
     
   )
   
   COM_Invoke(parentWindow, "execScript",clickme)
IE7_readyState(parentWindow) ; wait for page change to finish
Return
}

IE7_Button_click(parentWindow,value) ;Searches input tags for type button then compares the value with the sought text if found clicks returns error if not found will also trigger readystate
{
   button_click=
   (
   var i=0;
   while (i<document.all.length)
   {
      var tag=document.all(i).tagName;
      if (tag.toLowerCase()=='input')
      {
         var typ=document.all(i).type
         if (typ.toLowerCase()=='button' || typ.toLowerCase()=='submit' || typ.toLowerCase()=='reset')
         {
            var myVal=document.all(i).value;
            var theVal='%value%';
            if (myVal.toLowerCase()==theVal.toLowerCase())
            {
               document.all(i).click(); //click the button
               tag=undefined;
               typ=undefined;
               break; // end the loop
            }
         }
      }
      i=i+1;
   }

)
IE7_ExecuteJS(parentWindow, button_click)
IE7_readyState(parentWindow) ; wait for page change to finish
Return
}

;~ IE7_Get_DOM(parentWindow,ID,val="innerHTML",method="ID" )
;~ parentWindow assigned by IE7_Get(title,url="http") and must be an integer that represents a dom window handle
;~ ID will be an element id, index of all
IE7_Get_DOM(parentWindow,ID1) ;gets DOM object by ID Tag and returns string or error
{
   get_=
   (
   if (isNaN("%ID1%")){ // determins if an index or id is entered
         var tag=document.all("%ID1%").tagName;
         var i=1;
      }else{ // must be an index
         var tag=document.all(%ID1%).tagName;
         var i=2;
      }
   var tag1=tag.toLowerCase();
   
   

   switch(tag1)
      {
      case "input":
        var t=1;
        break;   
      case "textarea":
        var t=1;
        break;   
      case "select":
        var t=1;
        break;
      default:
        var t=2;
      }
   if(i==1 && t==1)
      var myVal=document.all("%ID1%").value;
   else if(i==2 && t==1)
      var myVal=document.all(%ID1%).value;
   else if(i==1 && t==2)
      var myVal=document.all("%ID1%").innerHTML;
   else if(i==2 && t==2)
      var myVal=document.all(%ID1%).innerHTML;
     
        var t=0;
        var i=0;
        var tag1=0;
        var tag=0;
   )
   myVal:=IE7_ExecuteJS(parentWindow, get_,"myVal")
   IE7_ExecuteJS(parentWindow, "var myVal='undefined';")
   Return myVal
}

IE7_Set_DOM(parentWindow,ID1,val="innerHTML") ;gets DOM object by ID Tag and returns string or error
{
   set_=
   (
   if (isNaN("%ID1%")){ // determins if an index or id is entered
         var tag=document.all("%ID1%").tagName;
         var i=1;
      }else{ // must be an index
         var tag=document.all(%ID1%).tagName;
         var i=2;
      }
   var tag1=tag.toLowerCase();
   
   

   switch(tag1)
      {
      case "input":
        var t=1;
        break;   
      case "textarea":
        var t=1;
        break;   
      case "select":
        var t=1;
        break;
      default:
        var t=2;
      }
   if(i==1 && t==1)
      document.all("%ID1%").value='%val%';
   else if(i==2 && t==1)
      document.all(%ID1%).value='%val%';
   else if(i==1 && t==2)
      document.all("%ID1%").innerHTML='%val%';
   else if(i==2 && t==2)
      document.all(%ID1%).innerHTML='%val%';
        var t=0;
        var i=0;
        var tag1=0;
        var tag=0;
   )
   IE7_ExecuteJS(parentWindow, set_)
   Return
}


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 215 posts ]  Go to page Previous  1 ... 7, 8, 9, 10, 11, 12, 13 ... 15  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, fusion1920, infogulch, Yahoo [Bot] and 11 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