Jump to content

Recommended Posts

Posted

Hi, I'm new in Autoit, just learned several days ago, and I have never learned programming language whatsoever.

 So this may looks stupid, but I'm just clueless right now.

Below is the script I just made.

Case 1 did work splendidly, as for Case 2 is where i would want the final color that i was aiming for, it just did nothing there, it didn't click....

as for "Case Else" is for every other color.

or did I just messed up with the "ContinueLoop" ?

And I have tried with the if else, but its a total mess, just couldn't find how it should work, pretty confused with the if else logic.

Any kind of help would be much appreciated, Thank You.

 

Func body2 ()
    while 1
        Sleep(500)
        Select
            Case 1
                $red = PixelSearch (111, 264, 146, 288, 0xFF290C)
                if Not @error Then
                    Sleep(200)
                    MouseWheel("down",10)
                    Sleep(400)
                EndIf
                ContinueLoop
            Case 2
                $white = PixelSearch (103, 218, 141, 241, 0xFFFFFF)
                if Not @error Then
                    Sleep (200)
                    MouseMove ( 123, 243, 2)
                    Sleep (100)
                    MouseDown("left")
                    Sleep (300)
                    MouseUp("left")
                    Sleep(100)
                    ExitLoop
                EndIf
            case Else
                Sleep (300)
                MouseWheel ("up",10)
                Sleep (300)
                MouseWheel("down",10)
                Sleep (1000)
                ContinueLoop
        EndSelect
    WEnd

Posted
6 hours ago, Nine said:

What application are you trying to automate ?  I doubt that this code will ever be robust enough.  Maybe there is a better approach we could suggest if we know what you are after.

Just a practical color selection things, and to test what I can do with this Autoit, the main idea is to get to "click" on white color, with the condition if i encounter a red one i need to scroll down "until" it encounter white and I can click on that, if any other color I need to scroll up and then down once only and it will turn into white that I can click on,

But I also need to be at moderate speed, thus the sleep time all over the place that I experience with, 'coz I don't have any experience with any programming language at all, so I'm pretty confused as it is.

 

Posted

I've Also experiment with if else

Func body1 ()
    while 1
        Sleep(600)
        $color = PixelSearch (103, 218, 141, 241, 0xFFFFFF)
        If Not @error Then
            Sleep (200)
            MouseMove ( 123, 243, 2)
            Sleep (100)
            MouseDown("left")
            Sleep (300)
            MouseUp("left")
            Sleep(500)
            ExitLoop
        $color = PixelSearch (111, 264, 146, 288, 0xFF290C)
        ElseIf @error Then
            MouseWheel("down",10)
            Sleep(600)
        EndIf
    WEnd
EndFunc

well..... its working perfectly with the red and white color only

what i need is for the other color other than white and red, and when it finds the other colors, it needs "only" to scroll up and then down "once" and then it will turn to white, so  that it can make the click.

i've tried countless variation, but it seems what i've done always mess the code.....

any help ??

Posted

I don't understand exactly what you want, but maybe this concept/princip:

Func body2()
    While 1
        Sleep(500)

        $red = PixelSearch(111, 264, 146, 288, 0xFF290C)
        $red_ok = Not @error

        If $red_ok Then
            Sleep(200)
            MouseWheel("down", 10)
            Sleep(400)
            ContinueLoop
        EndIf

        $white = PixelSearch(103, 218, 141, 241, 0xFFFFFF)
        $white_ok = Not @error

        If $white_ok Then
            Sleep(200)
            MouseMove(123, 243, 2)
            Sleep(100)
            MouseDown("left")
            Sleep(300)
            MouseUp("left")
            Sleep(100)
            ExitLoop
        EndIf

        If Not ($red_ok Or $white_ok) Then
            Sleep(300)
            MouseWheel("up", 10)
            Sleep(300)
            MouseWheel("down", 10)
            Sleep(1000)
        EndIf
    WEnd
EndFunc   ;==>body2

 

Posted

Thanks a lot , your code really helped me a lot, it worked, i didn't know that the IF ELSE could be used like this, ohh and I'm new in this kind of thing.........

its really an eye opening for me

what i was aiming for is :

- IF the WHite color shows up i have to click on that white

- if Red  that shows up, i need to scroll down until I find the white color to click it, or if I encounter other color while scrolling down then i need to = scroll up once and then scroll down once, and the white color will appear and click it

-if other colors shows up i need to scroll up once and then scroll down once, and the white color will appear and click it

that's it.

thanks.

  • Developers
Posted (edited)
9 hours ago, altop said:

Just a practical color selection things, and to test what I can do with this Autoit,

 

9 hours ago, altop said:

But I also need to be at moderate speed, thus the sleep time all over the place that I experience with

 

1 hour ago, altop said:

what i was aiming for is :

- IF the WHite color shows up i have to click on that white

- if Red  that shows up, i need to scroll down until I find the white color to click it, or if I encounter other color while scrolling down then i need to = scroll up once and then scroll down once, and the white color will appear and click it

-if other colors shows up i need to scroll up once and then scroll down once, and the white color will appear and click it

that's it.

You are pretty explicit for somebody that "just practices".
This whole thread smells as game automation, so will be (temporary) closed until @altop provides me some real information in a PM in case this is legitimate. Please start with reading our forum rules before sending that PM. :) 

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

  • Jos locked this topic
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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