Jump to content
careca

Trouble Clicking Button IE

Recommended Posts

Hi, i feel im close to getting it to work, but there must be something im missing that's probably easy for you experts.

Spoiler

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\W10\Desktop\BeeMp3.au3" /UserParams    
+>22:12:47 Starting AutoIt3Wrapper v.18.708.1148.0 SciTE v.4.1.0.0   Keyboard:00000816  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\W10\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\W10\AppData\Local\AutoIt v3\SciTE
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\W10\Desktop\BeeMp3.au3
+>22:12:47 AU3Check ended.rc:0
>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\Users\W10\Desktop\BeeMp3.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
--> IE.au3 T3.0-2 Warning from function _IEGetObjById, $_IESTATUS_NoMatch (col-md-12)
--> IE.au3 T3.0-2 Error from function _IEAction(click), $_IESTATUS_InvalidDataType
Download / Play
Download / Play
Download / Play
Download / Play
Download / Play
Download / Play
Download / Play
Download / Play
Download / Play
Download / Play
+>22:12:54 AutoIt3.exe ended.rc:0
+>22:12:54 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 7.542

#include <IE.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>

$Visible = 1
Local $oIE
$oIE = _IECreate("https://beemp3s.net/mp3-download.html", 0, $Visible, 1, 1)
_IELoadWait($oIE)
If $oIE <> @error Then
    ;_ArrayText()
    _QuerySite('Finding Hope - Without You')
    ;_IEQuit($oIE)
    ;Exit
Else
    MsgBox(64 + 262144, 'Fail', 'Could not create a new window')
EndIf

;=============================================================================

Func _QuerySite($Name)
    Local $oIE_ObjectToSearch = _IEGetObjById($oIE, 'query')
    _IEDocInsertText($oIE_ObjectToSearch, $Name)
    Local $oIE_ObjectToClick = _IEGetObjById($oIE, "search-action")
    _IEAction($oIE_ObjectToClick, 'click')
    _IELoadWait($oIE, 2000)
    ;=============================================================================
    Local $oSubmitClick = _IEGetObjById($oIE, "col-md-12")
    _IEAction($oSubmitClick, "click")
    _IELoadWait($oIE, 2000)
    ;=============================================================================
    Local $oBtns = _IETagNameGetCollection($oIE, "div")
    For $oBtn In $oBtns
        If String($oBtn.classname) = "col-md-12" Then
            If String($oBtn.innertext) = "Download / Play" Then
                ConsoleWrite($oBtn.innertext & @CRLF)
                _IEAction($oBtn, 'click')
            EndIf
        EndIf
    Next
    ;=============================================================================
    ;Local $oElements = _IETagNameAllGetCollection($oIE)
    ;For $oElement In $oElements
    ;    If $oElement.id Then MsgBox($MB_SYSTEMMODAL, "Element Info", "Tagname: " & $oElement.tagname & @CRLF & "id: " & $oElement.id & @CRLF & "innerText: " & $oElement.innerText)
    ;Next
    ;=============================================================================
    ;_IEQuit($oIE)
    ;Exit
    ;=============================================================================
EndFunc   ;==>_QuerySite

;=============================================================================

Func _ArrayText()
    If FileExists('Titles.txt') Then
        Local $FO = FileOpen('Titles.txt')
        Local $R2A = FileReadToArray($FO)
        Local $iLineCount = @extended
        FileClose($FO)
        For $f = 0 To $iLineCount - 1
            ConsoleWrite($f & ' - ' & $R2A[$f] & @CRLF)
            _QuerySite($R2A[$f])
        Next
    Else
        MsgBox(64 + 262144, 'Fail', 'Could not find the file Titles.txt')
    EndIf
EndFunc   ;==>_ArrayText

;=============================================================================

The idea is to get into this site, write into the search and click, which i did, but now the problem is clicking in any of the buttons in the results page, im looking for a way to click the first one, it always matches to what i want, so no need to fiddle around.

Site

Thanks for help in advance.

Capture.PNG


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
2 hours ago, careca said:

_IEDocInsertText($oIE_ObjectToSearch, $Name)

Interesting that this works. Normally, I would write this as --

_IEFormElementSetValue($oIE_ObjectToSearch, $Name)
Quote

Local $oBtns = _IETagNameGetCollection($oIE, "div")

Instead of getting a collection of divs, try using _IELinkGetCollection (each div contains a link) and then process the link collection for the desired class name.

Share this post


Link to post
Share on other sites

Ah yes, thanks, changed for setvalue.

But for the rest of it, the getcollection outputs zero.

#include <IE.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>

$Visible = 1
Local $oIE
$oIE = _IECreate("https://beemp3s.net/mp3-download.html", 0, $Visible, 1, 1)
_IELoadWait($oIE)
If $oIE <> @error Then
    ;_ArrayText()
    _QuerySite('Finding Hope - Without You')
    ;_IEQuit($oIE)
    ;Exit
Else
    MsgBox(64 + 262144, 'Fail', 'Could not create a new window')
EndIf

;=============================================================================

Func _QuerySite($Name)
    Local $oIE_ObjectToSearch = _IEGetObjById($oIE, 'query')
    ;_IEDocInsertText($oIE_ObjectToSearch, $Name)
    _IEFormElementSetValue($oIE_ObjectToSearch, $Name)
    Local $oIE_ObjectToClick = _IEGetObjById($oIE, "search-action")
    _IEAction($oIE_ObjectToClick, 'click')
    _IELoadWait($oIE, 2000)
    ;=============================================================================
    Local $oSubmitClick = _IEGetObjById($oIE, "col-md-12")
    _IEAction($oSubmitClick, "click")
    _IELoadWait($oIE, 2000)
    ;=============================================================================
    Local $oLinks = _IELinkGetCollection($oIE)
    ConsoleWrite('$oLinks ' & $oLinks & @CRLF)
    Local $iNumLinks = @extended
    ConsoleWrite('$iNumLinks ' & $iNumLinks & @CRLF)
    Local $sTxt = $iNumLinks & " links found" & @CRLF & @CRLF
    For $oLink In $oLinks
        $sTxt &= $oLink.href & @CRLF
    Next
    ;=============================================================================
    #cs
        Local $oBtns = _IETagNameGetCollection($oIE, "div")
        For $oBtn In $oBtns
        If String($oBtn.classname) = "col-md-12" Then
        If String($oBtn.innertext) = "Download / Play" Then
        ConsoleWrite($oBtn.innertext & @CRLF)
        _IEAction($oBtn, 'click')
        EndIf
        EndIf
        Next
    #CE
    ;=============================================================================
    ;Local $oElements = _IETagNameAllGetCollection($oIE)
    ;For $oElement In $oElements
    ;    If $oElement.id Then MsgBox($MB_SYSTEMMODAL, "Element Info", "Tagname: " & $oElement.tagname & @CRLF & "id: " & $oElement.id & @CRLF & "innerText: " & $oElement.innerText)
    ;Next
    ;=============================================================================
    ;_IEQuit($oIE)
    ;Exit
    ;=============================================================================
EndFunc   ;==>_QuerySite

;=============================================================================

Func _ArrayText()
    If FileExists('Titles.txt') Then
        Local $FO = FileOpen('Titles.txt')
        Local $R2A = FileReadToArray($FO)
        Local $iLineCount = @extended
        FileClose($FO)
        For $f = 0 To $iLineCount - 1
            ConsoleWrite($f & ' - ' & $R2A[$f] & @CRLF)
            _QuerySite($R2A[$f])
        Next
    Else
        MsgBox(64 + 262144, 'Fail', 'Could not find the file Titles.txt')
    EndIf
EndFunc   ;==>_ArrayText

;=============================================================================

 


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

This code

Local $oSubmitClick = _IEGetObjById($oIE, "col-md-12")
    _IEAction($oSubmitClick, "click")
    _IELoadWait($oIE, 2000)

results in the following errors

--> IE.au3 T3.0-2 Warning from function _IEGetObjById, $_IESTATUS_NoMatch (col-md-12)
--> IE.au3 T3.0-2 Error from function _IEAction(click), $_IESTATUS_InvalidDataType

It also appears to be unneeded since the code immediately before it clicks the search button. B)

Here's a working version of the other code --

Local $oLinks = _IELinkGetCollection($oIE)
    Local $iNumLinks = @extended
    ConsoleWrite('$iNumLinks ' & $iNumLinks & @CRLF)
    Local $sTxt = $iNumLinks & " links found" & @CRLF & @CRLF
    For $oLink In $oLinks
        $sTxt &= $oLink.href & @CRLF
    Next
    ConsoleWrite($sTxt)

 

Share this post


Link to post
Share on other sites

Yea that first code gives that error, but i decided to leave it there in case i need to use it in the future for something else, i've been ignoring it.

But for the second code, i want to click the button, so do i use $sTxt in the _ieaction?

Cannot try it out as im not home atm.


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
13 minutes ago, careca said:

But for the second code, i want to click the button, so do i use $sTxt in the _ieaction?

$sTxt isn't useful; it's just to show the details on the found links. You would need to do something like this to click the first download link --

Local $oLinks = _IELinkGetCollection($oIE)
    For $oLink In $oLinks
        If StringInStr(String($oLink.classname), 'init-download') Then
            _IEAction($oLink, "click")
            ExitLoop
        EndIf
    Next

 

Share this post


Link to post
Share on other sites

I'll check it out when i get home, thanks.


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

OK, so i stumbled on another problem, it's just that once i click the button, the page redirects, and opens a new tab, in this new tab is what i need to act uppon, but im stuck in the redirected window so no code works obviously, so i did the _IEAttach to the link of the new tab, which is always the same, but contains the button/link for the download itself, but curiously, after the attach without errors, i call the source code and to my surprise it is still the one from the redirected window.

Searched all around an cannot find a way to "jump" into this new tab, if i close the original, all shuts down.


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

Ah, nice, that's why adguard blocked the site.

Searching for an alternative i came across this:

https://mp3skull.us/video/Finding-Hope---Without-You-(Lyric-Video)-feat.-Holly-Drummond/FlY_ei-FnGY/

Tried many ways of clicking the button, or get the link where it's highlighted, do you have any ideas?

Thanks in advance.

Capture.PNG

The normal _IEGetObjById and click fails, invalid id.

Edited by careca

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

I didn't initially, now im struggling with it, getting lots of errors, even with the example from the help file, i could figure out there are 2 frames, but that's it, stuck.

More specifically when i try the code from help:

Local $oFrames = _IEFrameGetCollection($oIE)
Local $iNumFrames = @extended
Local $sTxt = $iNumFrames & " frames found" & @CRLF & @CRLF
Local $oFrame = 0
For $i = 0 To ($iNumFrames - 1)
    $oFrame = _IEFrameGetCollection($oIE, $i)
    $sTxt &= _IEPropertyGet($oFrame, "innertext") & @CRLF
Next
MsgBox($MB_SYSTEMMODAL, "Frames Info", $sTxt)

I get

"C:\Program Files (x86)\AutoIt3\Include\IE.au3" (2295) : ==> The requested action with this object has failed.:
$oTemp = $oObject.document.body
$oTemp = $oObject^ ERROR

And that it points into IE.au3 in line 2295

Edited by careca

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

Hi, thanks for the suggestion, i abandoned this, found another site and completed the tool, an mp3 downloader for youtube videos,

ended up being forbidden here because apparently it violates the google TOS.

So i kept the tool just for myself.


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

Don't know about all this coding work up there but yes I know a different and a easy way to download your file into mp3. I myself using this since 8+ months simple just visit https://scdownloader.online and paste your link click the download button. In just a click your file will be downloaded.

Edited by donaldcassey

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

    • By zuladabef
      I want to set the value of a input, but I only have the input name and input id.  I cannot find a form in the source.  Form collection does not return any results.  
      Is there a way to use FormElementSetValue without a form name? Can I use _IEGetObjByName or _IEGetObjById?  If so, how do I set the value once I have the object? Where do I go from here? Local $oIE = _IEAttach("[Website Goes Here"]) Local $oForm = _IEFormGetCollection($oIE, 1) Local $oQuery = _IEFormElementGetCollection($oForm, 4) _IEFormElementSetValue($oQuery, "Set it to this")  
    • By Seminko
      Hey there,
      below function returns an "object collection" (not sure if that's the correct term) of 'a' elements grabbed from within //*[@id="J_DetailMeta"].
      However, I need the returned collection not to include objects with 'aria-disabled = true'. Is there a way of removing specific objects from such a collection?
      Func GetObjectList($sPicker) $oDetailMeta = _IEGetObjById($oIE, "J_DetailMeta") If Not @error Then $tags = $oDetailMeta.GetElementsByTagName("ul") For $tag in $tags $data_ID_value = $tag.GetAttribute("data-property") If $sPicker = "color" Then If $data_ID_value = '????' Or $data_ID_value = "????" Then $oReturnList = $tag.GetElementsByTagName("a") EndIf ElseIf $sPicker = "network" Then If $data_ID_value = '????' Then $oReturnList = $tag.GetElementsByTagName("a") EndIf ElseIf $sPicker = "storage" Then If $data_ID_value = '????' Then $oReturnList = $tag.GetElementsByTagName("a") EndIf EndIf Next EndIf Return $oReturnList EndFunc $oColorList = GetObjectList("color") For $oColor In $oColorList If StringInStr($oColor.GetAttribute("aria-disabled"), "true") <= 0 Then ; remove object from the collection ??? EndIf Next  
    • By yoschga
      is there a possibility to let ie.au3 click into a form? i use on a project where i need to click into a form where items are loaded just writing it in or fill the form is no option
       

    • By RamaKrishna9
      What are the minimum system requirements(like Windows OS version, IE browser version, etc,.) for IE.au3(3.3.14.2) to work properly?
    • By MakzNovice
      Hello Experts,
      I am working on modifying table data of a browser currently in IE (soon in FF)
      My sequence of operations:
      1. Activate Browser
      2. Get Browser table
      3. Modify data  in table
      4. Suppress any warning/error message from webpage
      5. Activate the Webpage again 
      6. Send {F11} key sequence twice to achieve some update without Updating form ( {F5})
       
      My problem is at Step 5, as it activates the wrong window ( last used application rather than my browser window)
      My code snippet for it as follows
      $bFoundWindow = False Local $aList = WinList("[REGEXPTITLE:(?i)(.*Internet Explorer.*)]") Local $hWND = 0 For $i = 1 To $aList[0][0] If False = $bFoundWindow And $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 1) Then WinActivate($aList[$i][1]) ; 1. Activate Browser window WinSetState ( $aList[$i][1], "", @SW_MAXIMIZE) $hWND = $aList[$i][1] $objEditIE = _IEAttach ($aList[$i][1], "hwnd") $oTitles = _IETagNameGetCollection($objEditIE, "TITLE") For $oTitle In $oTitles $sTitle = $oTitle.innerText If $sTitle = $searchString Then MsgBox(0,"APPLICATION Found", "Got Edit List Window", 1) $bFoundWindow = True ExitLoop EndIf Next EndIf Next If False = $bFoundWindow Then MsgBox(0,"Error","Please launch Edit window for updating values in Browser prior to script execution",10) Exit EndIf ; MY CODE HERE TO MODIFY TABLE ; 2. Get Browser table ; 3. Modify data  in table ; Check if message from webpage pop-up window exists if so click ok on it Local $nCounter = 0 Local $nMaxCounter = 5 while 1 If WinExists("Message from webpage","") Then ControlClick("Message from webpage","","Button1","primary",1) ;4. Suppress any warning/error message from webpage Else $nCounter = $nCounter + 1 Sleep(100) ;MsgBox(0,"Counter", $nCounter, 1) If $nCounter = $nMaxCounter Then ExitLoop EndIf WEnd ;5. Activate the Webpage again  WinActivate($hWND) ; have already tried WinActivate($aList[$i][1]) but no success ;6. Send {F11} key sequence twice to achieve some update without Updating form ( {F5}) Send("{F11}") WinActivate($hWND) ;WinActivate($aList[$i][1]) Sleep(100) Send("{F11}") Any support will be highly appreciated
×
×
  • Create New...