Juvigy

IE automation

15 posts in this topic

Hi Guys,

I have a very complex IE page with lots of Java and Iframes. I need to be able to look for a change in one <input> field. So what i have done is to identify the field and hook an event listener with ObjEvent($title, "_Evt_")  and then i use :

Func _Evt_OnChange()
    Local $o_object = @COM_EventObj
    ConsoleWrite( "Change" & $o_object.value  &@CRLF)
    _FileWriteLine($MainLog, "Change:" & _NOW())
    TitleCheck($o_object.value)
EndFunc

Which work fine user doesn't interact with some of the other buttons or radios on the page. As soon as the user does some interaction or refreshes the page or navigates - the event listener is 'deleted' somehow and no longer works. Any idea how to counteract that? The easiest this is to detect if there is ANY change on the page - then i can identify the INPUT and check for its value. Any idea how to do that ?

Share this post


Link to post
Share on other sites



Any help will be greatly appreciated.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

ObjEvent($title, "_Evt_")

What is $title ? How you declare this variable ?

 

Edited by mLipok

NEW:     ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2016-11-12
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft Components * TeamViewer API -UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, The Art of Computer Programming
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites

$title is an <input> object. I get to it with getElementsByTagName ("input").  Everything works when i first start the script. However if i change the value of another <input> element using the mouse - the event listener stops working ! Which forces me to add event listeners to all inputs fields which makes the script restart which is a lot of work and not very consistent. There has to be easier and more elegant way!

Share this post


Link to post
Share on other sites

Try with $oIE 


NEW:     ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2016-11-12
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft Components * TeamViewer API -UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, The Art of Computer Programming
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites
ObjEvent($$oIE  , "_Evt_")

????

What are the events that are supported ?

Share this post


Link to post
Share on other sites

hm...

here is modyfied version:

; Trap COM errors so that 'Back' and 'Forward'
; outside of history bounds does not abort script
; (expect COM errors to be sent to the console)

#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

_Example()
Func _Example()
    Local $oIE = _IECreate("www.google.com")

    Local $oBody = _IETagNameGetCollection($oIE, "body", 0)
    Local $oTags_coll = _IETagNameGetCollection($oBody, 'input')
    Local $aEvents[1]
    Local $i = 0
    For $oTag_enum In $oTags_coll
        $aEvents[$i] = ObjEvent($oTag_enum, "_IEEvent_")
        If @error Then ConsoleWrite('! ---> @error=' & @error & '  @extended=' & @extended & ' : ObjEvent' & @CRLF)
        $i += 1
        ConsoleWrite("> $i=" & $i & @CRLF)
        ReDim $aEvents[$i + 1]
    Next
    ConsoleWrite("! Ubound=" & UBound($aEvents) & @CRLF)

;~  Local $oIEEvents = ObjEvent($oIE, "_IEEvent_", "DWebBrowserEvents2")
EndFunc   ;==>_Example

; Waiting for user to stop script manually
While Sleep(100)
WEnd

Func _IEEvent_OnChange()
    Local $oCOM_EventObj = @COM_EventObj
    ConsoleWrite("Change: " & $oCOM_EventObj.value & @CRLF)
EndFunc   ;==>_IEEvent_OnChange

Func _IEEvent_onmouseover()
    Local $oCOM_EventObj = @COM_EventObj
    ConsoleWrite($oCOM_EventObj.tagname & " : " & $oCOM_EventObj.id & @LF)
EndFunc   ;==>_IEEvent_onmouseover

 


NEW:     ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2016-11-12
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft Components * TeamViewer API -UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, The Art of Computer Programming
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites

Basically I do the same thing. The problem is that if i do some changes with the mouse - the events are lost.

For example i have 2 dropdown input boxes and 1 label. I want to monitor the value of the label. I set event on the label monitoring change. And if i change value on the label at this point - everything is ok and works. But if i use the drop down - after that the listening event on the label stops working. So i need to set events on all drop downs and setup events to restart the script if a drop down is used to reattach listening event on the label. Problem is there are soo many dropdowns and not only dropdowns but other elements and some special conditions that make scripting that a lot of work. Isn't there a better way?
 Something like :

Local $oIE = _IECreate("www.google.com")
 $event = ObjEvent($oIE, "_Evt_")
 
 Func _Evt_OnChange()
    'check label value
    'if value is changed display msg
 Endfunc

 

Share this post


Link to post
Share on other sites

The second example loaded in this post by the guru @trancexx might interest you ...


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

#10 ·  Posted

@Chimp Thanks for the link I was searching for the following example.....

@Juvigy I think you would like to use @trancexx  example from post #16

 

 


NEW:     ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2016-11-12
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft Components * TeamViewer API -UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, The Art of Computer Programming
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites

#11 ·  Posted

I tried it , but it doesnt work. I get a lot of errors due to old autoit version.
 Events are fired , but

Func Event_onclick($oEvtObj)
    If IsObj($oEvtObj) Then
        ConsoleWrite("onclick = " & $oEvtObj & @CRLF)
        ;ConsoleWrite("id = " & $oEvtObj.srcElement & " fired onclick" & @CRLF)
        If $oEvtObj = $oIE.document.getElementById("idButton") Then
            $oIE.Quit()
            Exit
        EndIf
    EndIf
EndFunc

the commented line gives me "The requested action with this object has failed.:"

Also i don't see anything that would help me here.  What am i missing?

 

Share this post


Link to post
Share on other sites

#12 ·  Posted

@Chimp

@mLipok

I almost managed to do it. Now i use Browser_DocumentComplete event which inside contain $event = ObjEvent($title, "_Evt_").

The problem is that Browser_DocumentComplete event  fires twice which in turn attaches 2 events on $title which in turn fires 2 "Onchange" events.

How can i make it to be just one ?

Share this post


Link to post
Share on other sites

#13 ·  Posted

16 hours ago, Juvigy said:

I almost managed to do it. Now i use Browser_DocumentComplete event which inside contain $event = ObjEvent($title, "_Evt_").

can you post what's your script so far...

16 hours ago, Juvigy said:

The problem is that Browser_DocumentComplete event  fires twice which in turn attaches 2 events on $title which in turn fires 2 "Onchange" events.

How can i make it to be just one ?

is your script refreshing the web page, or it changes something in the page layout, within the "Browser_DocumentComplete" function?? if so this could trigger the 'Browser_DocumentComplete' event function twice...(just a wild guess)

 

16 hours ago, Juvigy said:

 

How can i make it to be just one ?

... in the 'COM reference' of the AutoIt help, within the example of the "COM events" session, I see that them makes use of this method:

$oEventObject.stop ; Tell IE we want to stop receiving Events

maybe you could use this method to temporary 'pause' the events during page refresh or updates so to avoid unwanted event firing..?? (a wild guess again)

... posting a working reproducer of your script could be of help to help...


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

4 hours ago, Chimp said:

... in the 'COM reference' of the AutoIt help, within the example of the "COM events" session, I see that them makes use of this method:

$oEventObject.stop ; Tell IE we want to stop receiving Events

 

This seems interesting - i will see if i can use that. So basically the documentcomplete event fires twice , because i have 2 frames. It fires for each frame.

Here is my code:

Func Browser_DocumentComplete($oDisp, $sUrl)
    ConsoleWrite("DocumentComplete:"&$oDisp.ReadyState &@CRLF)
    $event = ObjEvent($title, "_Evt_") ; title is an input object
EndFunc

I think i can use  $oDisp to identify which frame fired the event , but i cant find how - cant seem to find the methods of that object in the IE documentation. For example $oDisp.Name works , but $oDisp.SomethingElseICanUse doesnt.

Another Q - how can i see that there is already an active event handler attached to an object? For example to modify above like this so i can have only 1 title event:

Func Browser_DocumentComplete($oDisp, $sUrl)
    ConsoleWrite("DocumentComplete:"&$oDisp.ReadyState &@CRLF)
    If IsEvent($event) then return 1
    $event = ObjEvent($title, "_Evt_") ; title is an input object
EndFunc

@edit I managed to do it using If $oDisp.LocationName <> "Some location"  then    ContinueLoop - thus event is added only once.

Now i face another issue - clicking an calendar control on the page 'deletes' all my events. This is the java code that i think does that:

javascript:tpzOnFocus('X100');openCalendar(document.topaz, document.topaz.X100);

Now i am wondering what to do now ?

Edited by Juvigy
cracked it

Share this post


Link to post
Share on other sites

#15 ·  Posted

So i tested a bit more and there are few things from the helpfile that are not working for me:
 

Quote

$EventObject.stop            ; Tell IE we want to stop receiving Events
$EventObject=0               ; Kill the Event Object

If you don't know (for some reason) the names of the events, you can add a UDF with only the prefix. In this example: Func IEEvent_($Eventname).
When an event is received and no IEEvent_ Eventname UDF exists, this function will be called instead and the name of the event will be placed in the variable $Eventname.

All this is not working for me. Reproducer on the last part can be found here :

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • PunkoHead
      IE function to click on nav button
      By PunkoHead
      Hi all,
      I am having an issue with a website that I want to automate.
      I have this menu and I want to click on the Custom button.

       
       
      The buttons with "inspect element" are: 
       

       
      The code that I tried is
      $sSearch = "Custom" $oFrame = _IEFrameGetObjByName($oIE, "options") $oDivs = _IETagNameGetCollection($oFrame, "ul") For $oDiv In $oDivs If String(_IEPropertyGet($oDiv, "InnerText")) = $sSearch Then _IEAction($oDiv, "click") ExitLoop EndIf Next I also tried with:
      $sMyString = "Custom" Local $oLinks = _IELinkGetCollection($oIE) For $oLink In $oLinks Local $sLinkText = _IEPropertyGet($oLink, "innerText") If StringInStr($sLinkText, $sMyString) Then _IEAction($oLink, "click") ExitLoop EndIf Next  
      However, these are not working. Any ideas?
       
       
    • Dent
      How to download uniquely generated PDF?
      By Dent
      Hi everyone,
      My script uses IE11 on Win7 to log in to a site and enters data into a couple of forms. Upon clicking a link this data is used by the site to generate a PDF report.
      With my current set-up if I do this manually the PDF opens in a new IE tab and I can download or print it. If I right-click the link that creates the PDF and choose Save Target As the PDF is generated and the Open/Save As dialogue at the bottom of the screen opens. All good.
      However I would like the script to automatically download the PDF and close IE and then exit. Closing IE (_IEQuit) and exiting the script are easy enough, but I'm struggling getting the script to download the PDF.
      The link to generate the PDF contains a unique number each time the page with the link is reached, so it's not static. The link position however, using _IELinkGetCollection I can tell the link to generate the PDF is always the 10th one from the end of the page, so using $iNumLinks - 10 I am able to click the link.
      What I believe I need to use is InetGet however the problem I've been facing is that the link isn't static and I haven't worked out a way to access the link by index - is this possible?
      Here is the website HTML for the section containing the link although I don't think it's of much use but it at least shows the format of the link (I can't post a link as it's a password protected area)...
      <div class="rmButton right"><a title="Generates a PDF version of the market report in a new window." href="/rmplus/generatePdf?mr_id=60991" target="_blank">print/save as pdf</a></div> The full link https://www.rightmove.co.uk/rmplus/generatePdf?mr_id=60991 just for completeness - visiting it will give a HTTP 500 unless logged in.
      And here is the code that clicks this link opening the generated PDF in a new tab...
      $oLinks = _IELinkGetCollection($oIE) $iNumLinks = @extended $PrintPDF = _IELinkClickByIndex($oIE, ($iNumLinks - 10)) So, how to use InetGet to visit that link? Or is there a way to Save As the newly opened tab? I've tried _IEAction($oIE, "saveas") but it seems not to work in a tab containing only a PDF.
    • AnAdventurer
      Newbie with a question... or two (IE focused)
      By AnAdventurer
      Hello hello!
      As the title suggests, I am fairly new to AutoIt. In fact, I am new to scripting/coding in general! I've done a few Codecademy courses on CSS and HTML and perhaps Java though this was all a few years back. I've recently come across AutoIt and decided to give it a try since I do quite a few repetitive tasks on a daily basis. In the last couple of weeks I've managed to master (or at least get comfortable with) mouse clicks(left/right), window focus, sending key strokes, controls, and pixel search.
      Now let's get to the topic.
      At this point in time I've tried out a few simple IE scripts but I am having difficulty understanding some things and tying everything together into one tool.
      Specifically, I am struggling with this little bit of code I got from DaleHohm in his IE examples thread. Post #3 (The last example.)
      #include <IE.au3> $sImgDir = "c:\foo\"; Please make certain this folder already exists (silent failure if not) $sWebPage = "http://www.autoitscript.com/forum/index.php?"; webpage with images $oIE = _IECreate() _IENavigate($oIE, $sWebPage) $oIMGs = _IETagNameGetCollection($oIE.document, "img") ; Loop through all IMG tags and save file to local directory using INetGet For $oIMG in $oIMGs $sImgUrl = $oIMG.src $sImgFileName = $oIMG.nameProp INetGet($sImgUrl, $sImgDir & $sImgFileName) Next I have a couple questions about the code above.
      1) ".src" ".nameProp" What are these called? I figured out that I can change the .src to something like .href and it gets anything on the webpage with a .href tag but where can I learn more about these? I still haven't been able to figure out what ".nameProp" is for or what it does. Is there any documentation/list of all the different ".PurpleTextAfterAVariable" (Edit: Not sure why it's red in the above example, just checked SciTE and it's purple there) that I can use?
      2) I understand that the code above gets every "For $oIMG in $oIMGs" on the page but how can I make it only get the first 5? I've tried doing a "count" and a "for" but I am unsure what to replace the "For...in" statement with to keep the script functional. Is there a way to limit the _IETagNameGetCollection function to only get a specific amount of tags?
       
      Finally, the reason I can't just use the code as is.
      The site I am trying to get images from works in this way:
      A href= "Link-To-Picture.jpg" Img src= "Link-To-Picture-thumbnail.jpg" The script above downloads every single thumbnail from the image gallery which is great, it does what it's supposed to but I need the full resolution image.
      After changing the script to get anything with an "A href" tag it does what I need it to do, it gets every single image in full resolution... along with every single one of the 80-100 extra files/links to other sites that are listed under an "A href" tag.
       
      Now I've come up with two solutions but unfortunately, as I mentioned above. I don't know how to put my solution into the code above to make it work.
      Solution 1) Only get the first 5 instances of "A href" on the page.
      As mentioned above. I don't know how to do this.
      Solution 2) Read the entire page, find "-Thumbnail.jpg" replace with ".jpg" and use the script as is.
      I understand how to do a replace. All I am missing is how to do a replace within a field in the code of an IE page. I assume that I have to use the HTMLRead functions but how do I use/alter the data read?
      I really hope all of this make sense and that someone here will be able to help me figure out a solution to my issue or at least answer one of my questions! I do have plenty more questions and I am sure that I'll have even more by the time I figure this out.
      Thank you very much for your time!
    • Dent
      How do I write to this form in IE?
      By Dent
      This is the page with the form I'm trying to write to Tennis Odds Calculator
      Username : dent
      Password : autoit
      Here's my full code:-
      #include <IE.au3> Local $TOCUsername = "dent" Local $TOCPassword = "autoit" Local $oIE = _IECreate("http://www.tennisoddscalculator.com/") If Not IsObj($oIE) Then Exit ConsoleWrite("Error creating instance of IE" & @CRLF) Local $oIE = _IEAttach("TOC") _IELoadWait($oIE) _IENavigate($oIE, "http://www.tennisoddscalculator.com/account/calculator/") _IELoadWait($oIE) Local $Page = _IEBodyReadText($oIE) If StringInStr($Page, "Username or Email") Then Local $oUsername = _IEGetObjByName($oIE, "username") _IEFormElementSetValue($oUsername, $TOCUsername) Local $oPassword = _IEGetObjByName($oIE, "password") _IEFormElementSetValue($oPassword, $TOCPassword) Local $oClassReturn = $oIE.document.getElementsByClassName("form-actions") If Not IsObj($oClassReturn) Then Exit ConsoleWrite("Error in $oClassReturn" & @CRLF) Local $oTagReturn = $oClassReturn.Item(0).getElementsByTagName("button") If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF) $oTagReturn.Item(0).Click() _IELoadWait($oIE) ElseIf StringInStr($Page, "Use the menu at the top") Then _IENavigate($oIE, "http://www.tennisoddscalculator.com/account/calculator/") _IELoadWait($oIE) Else MsgBox(0, "Error", "Unknown error") EndIf Sleep(2000) Local $oForm = _IEFormGetObjByName($oIE, "form") Local $sFirstServePc1 = "55.7" Local $sFirstServePc2 = "54.9" Local $sFirstServeWonPc1 = "60.0" Local $sFirstServeWonPc2 = "54.6" Local $sSecondServeWonPc1 = 72.4" Local $sSecondServeWonPc2 = "61.0" Local $sBPSavePc1 = "78.0" Local $sBPSavePc2 = "68.8" Local $oPlayer1FSPC = _IEFormElementGetObjByName($oForm, "fs") $oPlayer1FSPC.Value = $sFirstServePc1 Local $oPlayer2FSPC = _IEFormElementGetObjByName($oForm, "ofs") $oPlayer2FSPC.Value = $sFirstServePc2 Local $oPlayer1FSWPC = _IEFormElementGetObjByName($oForm, "fsw") $oPlayer1FSWPC.Value = $sFirstServeWonPc1 Local $oPlayer2FSWPC = _IEFormElementGetObjByName($oForm, "ofsw") $oPlayer2FSWPC.Value = $sFirstServeWonPc2 Local $oPlayer1SSWPC = _IEFormElementGetObjByName($oForm, "ssw") $oPlayer1SSWPC.Value = $sSecondServeWonPc1 Local $oPlayer2SSWPC = _IEFormElementGetObjByName($oForm, "ossw") $oPlayer2SSWPC.Value = $sSecondServeWonPc2 Local $oPlayer1BPS = _IEFormElementGetObjByName($oForm, "kps") $oPlayer1BPS.Value = $sBPSavePc1 Local $oPlayer2BPS = _IEFormElementGetObjByName($oForm, "kpb") $oPlayer2BPS.Value = $sBPSavePc2  
    • Dent
      [SOLVED] Possibly used before declaration error in IE.au3
      By Dent
      Hi all,
      So I have a script that interacts with IE but for some reason I can't identify I'm getting the 'possibly used before declaration' error even though I've declared and used those variables.
      Local $oPlayer1FSPC = _IEGetObjByName($oIE, "fs") $oPlayer1FSPC.Value = $sFirstServePc1 Local $oPlayer2FSPC = _IEGetObjByName($oIE, "ofs") $oPlayer2FSPC.Value = $sFirstServePc2 Local $oPlayer1FSWPC = _IEGetObjByName($oIE, "fsw") $oPlayer1FSWPC.Value = $sFirstServeWonPc1 Local $oPlayer2FSWPC = _IEGetObjByName($oIE, "ofsw") $oPlayer2FSWPC.Value = $sFirstServeWonPc2 Local $oPlayer1SSWPC = _IEGetObjByName($oIE, "ssw") $oPlayer1SSWPC.Value = $sSecondServeWonPc1 Local $oPlayer2SSWPC = _IEGetObjByName($oIE, "ossw") $oPlayer2SSWPC.Value = $sSecondServeWonPc2 Local $oPlayer1BPS = _IEGetObjByName($oIE, "kps") $oPlayer1BPS.Value = $sBPSavePc1 Local $oPlayer2BPS = _IEGetObjByName($oIE, "kpb") $oPlayer2BPS.Value = $sBPSavePc2 The $s variables have had strings assigned earlier in the script and I've tested that with ConsoleWrite