dedronek

Click on button with classname failured

7 posts in this topic

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>')

 

Share this post


Link to post
Share on other sites



When I refresh page manual script sometimes starts work fine, but after some time script hangs again. I think it is problem with status IE.

Share this post


Link to post
Share on other sites

I looked on try icon and script hangs on IE.au3, Line 483, Sleep(100). Anyone can help me?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

I have solution. My problem resolved func 

_IELoadWaitTimeout()

Thanks for your help :)

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