Jump to content

Trouble Clicking Button IE


careca
 Share

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

Link to comment
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.

Link to comment
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

Link to comment
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)

 

Link to comment
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

Link to comment
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

 

Link to comment
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

Link to comment
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

Link to comment
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

Link to comment
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

Link to comment
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

Link to comment
Share on other sites

  • 2 months later...

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
 Share

×
×
  • Create New...