Jump to content

Click on button with classname failured


Recommended Posts

Hello guys, I created script which must click on object with classname on website and after it, copy phrase between two tags (I used IE.au3). Scripts work but not always. Sometime script loading page and when page is already load script dont click on object. Before it script dont crash itself. I dont know what is wrong :/ Please help me guys

#include <Constants.au3>
#include <IE.au3>
#include <String.au3>
#include <Array.au3>
Opt("TrayIconDebug", 1)
HotKeySet("{F9}", "kill")
HotKeySet("{F10}", "pause")
$zero = Null
Func kill()
   Exit 0
EndFunc

Func pause()
    $Paused = NOT $Paused
    While $Paused
        Sleep(100)
        Tooltip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
 EndFunc

$i=0
Do
   nr()
Until $i<-1

Func nr()
$strona = FileReadLine("strony.txt",$i+1)
$file = fileopen(@scriptdir & "\source.txt", 10)
$IE = _IECreate($strona)
_IELoadWait($IE,1,1)
_IEAction($IE, "refresh")
_IEAction($IE, "stop")
$oInputs = _IETagNameGetCollection($IE, "span")

Sleep(1000)
For $oInput In $oInputs
   If $oInput.classname = "icon inlblk vtop b_phone4" Then _IEAction($oInput, "focus")
   If $oInput.classname = "icon inlblk vtop b_phone4" Then _IEAction($oInput, "click")
   If $oInput.classname = "link spoiler small nowrap" Then _IEAction($oInput, "focus")
   If $oInput.classname = "link spoiler small nowrap" Then _IEAction($oInput, "click")
   Next
    Sleep(1000)
$source = _IEDocReadHTML($IE)
FileWrite($file, $source)
If (_StringBetween($source, '<strong class="xx-large">', '</strong>') <> 0) Then
$target_source = _StringBetween($source, '<strong class="xx-large">', '</strong>')
$numer = fileopen(@scriptdir & "\numer.txt", 1)
FileWrite($numer, $target_source[0])
FileWrite($numer, @CRLF)
FileClose($numer)
$i+=1
_IEQuit($IE)
Else
   $i+=1
_IEQuit($IE)
EndIf
EndFunc
;;$target_source = _StringBetween($source, '<strong class="xx-large">', '</strong>')

 

Link to comment
Share on other sites

It could be because you are only giving it 1 milisecond to check the status and to load: 

$iDelay [optional] Milliseconds to wait before checking status
$iTimeout  [optional] Period of time to wait before exiting function (default = 300000 ms aka 5 min)
_IELoadWait($IE,1,1)

Try ditching those two optional parameters and using the defaults (or something larger).

Edit: and then to my earlier post I would remove that refresh because it will defeat the purpose of waiting (also not sure why you have "stop" ?)

Edited by Jfish

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...