Jump to content

If's ElseIf's!


Recommended Posts

While 1
    If PixelGetColor(600, 500) = 0 And WinGetText("Dark Throne (beta) Recruitloop - Microsoft Internet Explorer", "You have made 0 clicks today. You have 350/350 clicks remaining today") Then
        MouseClick("Left", 566, 388, 1)
    EndIf
WEnd

While 2
    If PixelGetColor(600, 500) = 0 And WinGetText("Dark Throne (beta) Recruitloop - Microsoft Internet Explorer", "Due to players using automated programs which hurt our site, refreshing has been disabled. Please use the recruit! button on the recruiter. Click here to continue") Then
        MouseClick("Left", 577, 484, 1)
    EndIf
WEnd

While 3
    If PixelGetColor(600, 500) = 0 And WinGetText("Dark Throne (beta) Recruitloop - Microsoft Internet Explorer", "You have already clicked the maximum number of members for today") Then
        MsgBox(48, "Done", "You have finished Clicking!")
    EndIf
WEnd

Posted Image

Here i have three things to do. How would i make it so it would go to the second one if the first one was not true and so on?

Edited by Googler24022
Link to comment
Share on other sites

You mean something like the following?

While 1
    If PixelGetColor(600, 500) = 0 And WinGetText("Dark Throne (beta) Recruitloop - Microsoft Internet Explorer", "You have made 0 clicks today. You have 350/350 clicks remaining today") Then
        MouseClick("Left", 566, 388, 1)
    ElseIf PixelGetColor(600, 500) = 0 And WinGetText("Dark Throne (beta) Recruitloop - Microsoft Internet Explorer", "Due to players using automated programs which hurt our site, refreshing has been disabled. Please use the recruit! button on the recruiter. Click here to continue") Then
        MouseClick("Left", 577, 484, 1)
    ElseIf PixelGetColor(600, 500) = 0 And WinGetText("Dark Throne (beta) Recruitloop - Microsoft Internet Explorer", "You have already clicked the maximum number of members for today") Then
        MsgBox(48, "Done", "You have finished Clicking!")
          ExitLoop
    EndIf
WEnd

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

  • Moderators

If PixelGetColor(600, 500) = 0
Never seen a pixel color at 0 before?

But I would put this at top anyway:

Opt("WinTitleMatchMode", 4)
Opt("PixelCoordMode", 0); sets the pixel to search in active window
Opt("MouseCoordMode", 0); makes sure mouse click is in active window not screen

Winactivate("Dark Throne")

While 1
If PixelGetColor(600, 500) = 0 And WinGetText("Dark Throne (beta) Recruitloop - Microsoft Internet Explorer", "You have made 0 clicks today. You have 350/350 clicks remaining today") Then
        MouseClick("Left", 566, 388, 1)
    ElseIf PixelGetColor(600, 500) = 0 And WinGetText("Dark Throne (beta) Recruitloop - Microsoft Internet Explorer", "Due to players using automated programs which hurt our site, refreshing has been disabled. Please use the recruit! button on the recruiter. Click here to continue") Then
        MouseClick("Left", 577, 484, 1)
    ElseIf PixelGetColor(600, 500) = 0 And WinGetText("Dark Throne (beta) Recruitloop - Microsoft Internet Explorer", "You have already clicked the maximum number of members for today") Then
        MsgBox(48, "Done", "You have finished Clicking!")
          ExitLoop
    EndIf
WEnd

Good luck

EDIT: "/" whoda thunk it means so much :(

Edited by ronsrules

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Usually if its not 1 of 2 possible options, I would use Select...Case...EndSelect over If...ElseIf...Else...EndIf just so that you don't start nesting If statements within If statements.

I'm not into structual engineering along side my code, I'll let the architects build the pyramids :( (stupid joke)

Writing AutoIt scripts since

_DateAdd("d", -2, _NowCalcDate())
Link to comment
Share on other sites

While 1
  Select
    Case StatusbarGetText("Dark Throne (beta) Recruitloop - Microsoft Internet Explorer") = "Done" And WinGetText ( "Dark Throne (beta) Recruitloop - Microsoft Internet Explorer" , "clicked today" )
        MouseClick ( "Left" , 566, 388 , 1)
    Case WinGetText ( "Dark Throne (beta) Recruitloop - Microsoft Internet Explorer" , "Due to players using automated programs which hurt our site, refreshing has been disabled" )
        MouseClick ( "Left" , 575, 475 , 1)
EndSelect
WEnd

Posted Image

Nope nothing works. I don't want to exit the loop. The weird thing is that the second case keeps repeating itself even though it isnt not true. Do you think i should add more functions to try and identify the page more?

Edited by Googler24022
Link to comment
Share on other sites

While 1
  Select
    Case StatusbarGetText("Dark Throne (beta) Recruitloop - Microsoft Internet Explorer") = "Done" And WinGetText ( "Dark Throne (beta) Recruitloop - Microsoft Internet Explorer" , "clicked today" )
        MouseClick ( "Left" , 566, 388 , 1)
    Case WinGetText ( "Dark Throne (beta) Recruitloop - Microsoft Internet Explorer" , "Due to players using automated programs which hurt our site, refreshing has been disabled" )
        MouseClick ( "Left" , 575, 475 , 1)
EndSelect
WEnd

Nope nothing works. I don't want to exit the loop. The weird thing is that the second case keeps repeating itself even though it isnt not true. Do you think i should add more functions to try and identify the page more?

<{POST_SNAPBACK}>

If i look at the code, tour trying to get text from IE

WinGetText from IE returns "" =nothing, does not work on IE window text

Have to use com for that like:

;Autor: DaleHohm
$url = "http://www.amazon.com"

; Create IE Object
$ObjIE=ObjCreate("InternetExplorer.Application")

; Set IE visible, navigate to URL and wait for load complete
With $ObjIE
  .Visible = True
  .Navigate($url)
  Do; Idle until load complete
    Sleep(50)
  Until .ReadyState = 4
EndWith

; These variables collect everything inside the BODY tag
$theText = $ObjIE.document.body.innerText; gets just text
$theHTML = $ObjIE.document.body.innerHTML; gets everything including HTML
Link to comment
Share on other sites

Your com does not work. I downloaded the latest beta but it says its a undefined function.

<{POST_SNAPBACK}>

Not my com, DaleHolm's com :( , should work

If you use SciTE you must do "tools"=>"Beta run Alt + F5"

GivesnNo problem on my pc's! (win2000 & WinXP sp2)

Link to comment
Share on other sites

Problem Solved!

Thanks!

Sorry for my many questions.

Also!? Do coms work with the autoit script well?

Another q : Will i be able to open firefox with this?

Anoter Question : Where do i find out about coms? i find it very hard to get any info on them.

Thanks!

Edited by Googler24022
Link to comment
Share on other sites

Problem Solved!

Thanks!

Sorry for my many questions.

Also!? Do coms work with the autoit script well?

Another q : Will i be able to open firefox with this?

Anoter Question : Where do i find out about coms? i find it very hard to get any info on them.

Thanks!

<{POST_SNAPBACK}>

1) You did it in AutoIt =>so yes

2)Firefox does not work with com objects

3)It's all on MSDN, IE objects

Have to convert the exaples to AutoIt (if there are any)

Hope this helps

Link to comment
Share on other sites

Theres a certain piece of text i want now, so when the program finds this text it will do something and if its not the right text, do something else? How would i go about getting the text from the page? The page also changes so it would pointless using the $theText = $ObjIE.document.body.innerText; gets just text

Im not sure though? :(

Link to comment
Share on other sites

Theres a certain piece of text i want now, so when the program finds this text it will do something and if its not the right text, do something else? How would i go about getting the text from the page? The page also changes so it would pointless using the $theText = $ObjIE.document.body.innerText; gets just text

Im not sure though? :(

<{POST_SNAPBACK}>

I think you want to do somthing like:

see if "clicked today" or "Due to players using automated programs which hurt our site, refreshing has been disabled" is in the text

$url = "http://www.darkthrone.com/";dont know rest of url

; Create IE Object
$ObjIE=ObjCreate("InternetExplorer.Application")

; Set IE visible, navigate to URL and wait for load complete
With $ObjIE
  .Visible = True
  .Navigate($url)
  Do; Idle until load complete
    Sleep(50)
  Until .ReadyState = 4;would be statusbartext done then
EndWith

While 1
    $theText = $ObjIE.document.body.innerText; gets just text
    if StringInStr($theText ,"clicked today") then
      ;do the suff you want
    ElseIf StringInStr($theText ,"Due to players using automated programs which hurt our site, refreshing has been disabled") then
      ;do other stuff you want
    Endif
    sleep(1000);checks every second
Wend

If the $ObjIE.document.body.innerText gets the refreshed text that is

It shoud do the trick

If you have to refresh the page over and over include this in the while loop

With $ObjIE
  .Visible = True
  .Navigate($url)
  Do; Idle until load complete
    Sleep(50)
  Until .ReadyState = 4;would be statusbartext done then
EndWith
Edited by TuMbLeWeEd
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...