Jump to content
Dequality

Need help IE automation.

Recommended Posts

Dequality
Posted (edited)

I don't really have any code cuz whatever i try it doesnt work -.- 

Can anyone please make me a sample i can study? <,< i need to make a simple script to open explorer click some objects on the site , rinse repeat.. a example with autoit' website is just fine i just need to study it.. the i can't seem to find any yt video on this.. '-_-

And yes i tried looking at the manual .. but i dont get anything from it <.<'

 

Any help highly appreciatet <3 

Edited by Dequality

Share this post


Link to post
Share on other sites
Dequality
ERROR CODE

--> IE.au3 T3.0-2 Warning from function _IEGetObjByName, $_IESTATUS_NoMatch (Name: Activity, Index: 0)
--> IE.au3 T3.0-2 Error from function _IEAction(click), $_IESTATUS_InvalidDataType
#include <IE.au3>

$oIE = _IECreate("https://www.autoitscript.com/forum/", 0, 1, 1, 0)
Sleep(5000)
$Activity = _IEGetObjByName($oIE, "Activity")

_IEAction($Activity, "click")

 

Share this post


Link to post
Share on other sites
FrancescoDiMuro
26 minutes ago, Dequality said:

Can anyone please make me a sample i can study?

There are quite a tons on the forums and on the Help file, where you should start looking at from.

The console is telling you exactly what your script is doing, so, you don't need any help from anyone.

Just understand what you have done.


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
Dequality
Just now, FrancescoDiMuro said:

There are quite a tons on the forums and on the Help file, where you should start looking at from.

The console is telling you exactly what your script is doing, so, you don't need any help from anyone.

Just understand what you have done.

Well.. ty i guess? :blink:

Share this post


Link to post
Share on other sites
TheXman

Assuming that your snippet of code was trying to click the "Activity" tab below:

image.png.1352956374d028bab3d2d343319a1899.png

If you look at the actual HTLM source for that link, it looks like:

<a href="https://www.autoitscript.com/forum/discover/unread/" data-navitem-id="2">Activity</a>

As you can see, that tag does not have a "name" attribute equal to "Activity" (name="Activity").  As a matter of fact, no tag on that page has an attribute with name="Activity".  That is why you got the NoMatch error.

What it appears you were trying to do was to click the link whose text was "Activity".  If so, then you want something similar to:

#include <IE.au3>

Local $oIE = _IECreate("https://www.autoitscript.com/forum")

_IELinkClickByText($oIE, "Activity")

If you were not trying to click that link, maybe a better explanation of what you were trying to do would help.

As FrancescoDiMuro said, the help file and forum are full of examples.  Spending some time looking thru the _IE* functions and their examples in the Help file, as well as the IE_Example example and trying to understand what is going on in those examples, should give you a solid foundation upon which to build upon.  If you actually spent time looking thru them, as you said, and got nothing from it, I doubt that you would get anything more from any additional examples that anyone else could provide.

Share this post


Link to post
Share on other sites
Nine

Well, it may sound obvious for those who spent hundreds of hours scripting a specific UDF.  But I understand the one who is starting and facing with  this incredible amount of information.  Been there too.  So thanks for @TheXman to give a clear explanation of the mechanics behind it.

 

  • Thanks 1

Share this post


Link to post
Share on other sites
Dequality
Posted (edited)
6 hours ago, TheXman said:

Assuming that your snippet of code was trying to click the "Activity" tab below:

image.png.1352956374d028bab3d2d343319a1899.png

If you look at the actual HTLM source for that link, it looks like:

<a href="https://www.autoitscript.com/forum/discover/unread/" data-navitem-id="2">Activity</a>

As you can see, that tag does not have a "name" attribute equal to "Activity" (name="Activity").  As a matter of fact, no tag on that page has an attribute with name="Activity".  That is why you got the NoMatch error.

What it appears you were trying to do was to click the link whose text was "Activity".  If so, then you want something similar to:

#include <IE.au3>

Local $oIE = _IECreate("https://www.autoitscript.com/forum")

_IELinkClickByText($oIE, "Activity")

If you were not trying to click that link, maybe a better explanation of what you were trying to do would help.

As FrancescoDiMuro said, the help file and forum are full of examples.  Spending some time looking thru the _IE* functions and their examples in the Help file, as well as the IE_Example example and trying to understand what is going on in those examples, should give you a solid foundation upon which to build upon.  If you actually spent time looking thru them, as you said, and got nothing from it, I doubt that you would get anything more from any additional examples that anyone else could provide.

I wan't to be able to find a button by _IEObjGetById/Name seems like its more reliable? :think: but ty a lot for the explanation! will try it out right now :)!

 

#include <IE.au3>

$oIE = _IECreate("https://www.autoitscript.com/forum/", 0, 1, 1, 0)
Sleep(5000)
_IELinkClickByText($oIE, "Activity")

I tried this now, no error but still didnt click anything? :think: 

Edited by Dequality

Share this post


Link to post
Share on other sites
FrancescoDiMuro
1 hour ago, Dequality said:

I tried this now, no error but still didnt click anything?

To say that, you should check for an error, and you do it with

If @error Then
    ConsoleWrite("Error calling FunctionName. Error: " & @error & @CRLF)
Else
    ; Do something
EndIf

 


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
Dequality
Posted (edited)
5 hours ago, FrancescoDiMuro said:

To say that, you should check for an error, and you do it with

If @error Then
    ConsoleWrite("Error calling FunctionName. Error: " & @error & @CRLF)
Else
    ; Do something
EndIf

 

Think i fixed it, it's working properly now but i have to hit a button which is written in java is that possible? :think: 

<a href="javascript:void(0);" onclick="return('0', '427', 'autotrainer', '', '', '', '525251', '', '', '', '30', '');"><strong>btn</strong> <br><small><i>30 </i></small></a>

this is the text i get when i right click > inspect the element :think: 

Edited by Dequality

Share this post


Link to post
Share on other sites
Nine
11 hours ago, Dequality said:

I tried this now, no error but still didnt click anything?

Was trying to see if I had the same problem as you.  And Yes I had. So after few hours of testing I finally found that there is 2 "Activity" links and it's the second link that works.

Share this post


Link to post
Share on other sites
Dequality
On 04/01/2019 at 5:25 PM, Nine said:

Was trying to see if I had the same problem as you.  And Yes I had. So after few hours of testing I finally found that there is 2 "Activity" links and it's the second link that works.

How did you find the second one? 

Share this post


Link to post
Share on other sites
Nine
5 hours ago, Dequality said:

How did you find the second one? 

$collection = _IELinkGetCollection ($oIE)

$c = 0
for $obj in $collection
  If not $obj.id Then ContinueLoop
  $c += 1
  $arr[$c][0] = $obj.name
  $arr[$c][1] = $obj.id
  $arr[$c][2] = $obj.innerText
  $arr[$c][3] = $obj.outerText
Next

_ArrayDisplay ($arr)

 

Share this post


Link to post
Share on other sites
FrancescoDiMuro
Posted (edited)

@Nine
Shouldn't you set $c+=1 before the Next command?

Spoiler
#include <Array.au3>

Global $intRow = 0, _
       $arrSomeArray[10][1]

For $i = 0 To 9 Step 1
    $arrSomeArray[$intRow][0] = $intRow
    $intRow += 1
Next

_ArrayDisplay($arrSomeArray)

 

In this way, you have one row that is not filled :)

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
Nine
5 minutes ago, FrancescoDiMuro said:

@Nine
Shouldn't you set $c+=1 before the Next command?

  Reveal hidden contents
#include <Array.au3>

Global $intRow = 0, _
       $arrSomeArray[10][1]

For $i = 0 To 9 Step 1
    $arrSomeArray[$intRow][0] = $intRow
    $intRow += 1
Next

_ArrayDisplay($arrSomeArray)

 

In this way, you have one row that is not filled :)

yes i know but it is only a debugging tool, I thought you would have known that :huh2:

Share this post


Link to post
Share on other sites
FrancescoDiMuro

@Nine
Yeah, sure 
:)
 


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

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

    • Seminko
      By Seminko
      Strange thing. When I load a page in IE and inspect, the elements are clearly there but when I try to find them using _IEGetObjById or _IETagNameGetCollection or even using JS right in the IE console, the elements can't be found.
      Have you guys even encoutered something similar?
      Site's HTML
      <div id="lastdays"> <div class="radio"> <span class="radio"><input id="lastdays_radio" type="radio" name="rangepanel_group" value="lastdays_radio"></span> </div> <div class="content"> <label for="lastdays_radio">Za posledních</label> <label for="lastdays_radio"> </label> <input name="lastdays_days" type="text" value="1" maxlength="3" id="lastdays_days" class="text days" onclick="document.getElementById('lastdays_radio').checked=true;" onfocus="document.getElementById('lastdays_radio').checked=true;"> <label for="lastdays_radio"> </label> <select name="lastdays_period" id="lastdays_period" class="combo" onclick="document.getElementById('lastdays_radio').checked=true;" onfocus="document.getElementById('lastdays_radio').checked=true;"> <option value="D">dnů</option> <option value="W">týdnů</option> <option selected="selected" value="M">měsíců</option> </select> </div> </div> document.getElementById("lastdays_days"); //returns null in IE  
    • XinYoung
      By XinYoung
      Greetings!
      I am in need of your guidance once again. I searched the forums for clicking in span, clicking by class, clicking without an ID or Name, etc., but I am unable to find a solution for my problem.
      I am trying to expand this tree in IE. There is an arrow ( > ) that i need to click, but I can't find a way to do it . Alternatively, I can double-click the text "Servers", but that seems to be even more troublesome. I will have to do this 2-3 more times as the tree expands.
      There appears to be an ID for the tree, simply called "tree", but that isn't working when I send a click to it.

      ;Open an IE session and navigate to pgAdmin. Global $oIE = _IECreate($pgAdmin) ;Maximize the IE window. WinSetState(_IEPropertyGet($oIE, "hwnd"), "", @SW_MAXIMIZE) Sleep(2000) ;Expand the tree $oTree = _IEGetObjById($oIE, "tree") _IEAction($oTree, "click") Any ideas?  
    • XinYoung
      By XinYoung
      Hello all!   I'm stuck at a seemingly simple part of my script. Using IE, I'm filling out a web form that involves clicking a "Browse" button and selecting a file. Once the file explorer dialog opens, however, I am unable to control it.
      I have a string, which is the name of the file I want, and I'm trying to insert it into the 'File name:' text box in the dialog (which already has focus), but it doesn't get inserted. I've tried ClipPut and Send. 

      What's even more concerning is, when I close the dialog, the string is then pasted into the very next window that has focus, which is often SciTE. It's like that Browse's file open dialog halts all processes. Once it's closed, the script continues.
      ;~ Open a IE window and navigate to the login page. Global $oIE = _IECreate($urlBBLogin) _IELoadWait($oIE) ;~ Recognize the form on this page (login input boxes). Local $oForm = _IEFormGetObjByName($oIE, "login") Local $oTextLogin = _IEFormElementGetObjByName($oForm, "user_id") Local $oTextPass = _IEFormElementGetObjByName($oForm, "password") ;~ Enter the Automation user credentials into the form. _IEFormElementSetValue($oTextLogin, $bbUsername) _IEFormElementSetValue($oTextPass, $bbPassword) ;~ Click the Login button. _IEFormSubmit($oForm) _IELoadWait($oIE) ;~ Navigate to the feedfile upload page. _IENavigate($oIE, $urlUpload) _IELoadWait($oIE) ;~ Click the Browse button Local $Browse = _IEGetObjById($oIE, "feedFile_chooseLocalFile") _IEAction($Browse, "Click") Local $Browse = WinWait("Choose File to Upload") ;~ Open the file we created. WinActivate($Browse) Send($finalFile) Has anyone else experienced this problem? Any ideas to get around it? Am I approaching this the wrong way?
      Any support is greatly appreciated.
      Thank you.
    • Drac89
      By Drac89
      How do i pass the IE handle to an active windows authentication prompt when the IE shows it is " waiting " , right now it is nt detecting the windows security prompt
      I used the below to wait for it to load until the 60ms timeout but still it isnt working  :
       
      #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
      #AutoIt3Wrapper_Outfile=ps_test.exe
      #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
      #include <Constants.au3>
      #include <IE_v1.au3>
      If $CmdLine[0] < 2 Then
         MsgBox($MB_OK, "Usage", "ps_WAN <username> <password>")
      Else
         wan($CmdLine[1], $CmdLine[2])
      EndIf
      Func wan($email, $password)
       $oIE = _IECreate()
      $ieo=_IENavigate($oIE, "https://cccc")
      _IELoadWait($ieo,0,60)
       Local $hWnd = WinExists("Windows Security")
      if $hWnd = 0 Then
         MsgBox($MB_OK, "Usage", "timeout")
         EndIf
      ControlFocus("Windows Security", "", "[CLASS:DirectUIHWND]")
      ControlFocus("Windows Security", "", "[CLASS:Edit; INSTANCE:1]")
       

    • SkysLastChance
      By SkysLastChance
      I am trying to wait for a pop up in IE with the title of "filed". I believe it is in a IE-frame.  I am not having any luck attaching to it. The best thing I have been able to do is find the title using the below code. 
      Is there a way I can just make AutoIt wait until it finds the  "Filed" value from the below code?
      Thank you for any help, I am probably making this harder then it really is. 
      $oIE = _IEAttach("Meditech") $oInputs1 = _IETagNameGetCollection($oIE, "div") For $oInput1 in $oInputs1 If StringStripWS($oInput1.innertext,1) = "Filed" Then $target = $oInput1 ExitLoop Else $target = "NOT FOUND" EndIf Next I have tried different variations of
      _IEAttach("MEDITECH","Filed") WinWaitActive("MEDITECH", "Filed") Here is what the popup looks like.

×