Jump to content

Can't make my script run in a loop - (Locked)


Recommended Posts

Hello everyone!

I'm new here so I hope I won't mess anything up.
Recently I started making a little script that is searching for a pixel color in defined space and then clicking the spot, there are two cases, with two different colors and I don't know how to write the script so it stops when both colors are missing.
Below is my code:

#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>

; Odszukuje kwadracika "New" w kolorze fioletowym i naciska go
Local $aCoord = PixelSearch(1930, 40, 2560, 1020, 0xCC66FF)
; Odszukuje znaczek telefonu
Local $bCoord = PixelSearch(0, 0, 2559, 1059, 0xFFFF99)
Local $i = 1
Switch $i
    Case 1
        Do
;If Not @error Then
;Local $aCoord = PixelSearch(1930, 40, 2560, 1020, 0xCC66FF)
Local $aCoord = PixelSearch(1930, 40, 2560, 1020, 0xCC66FF)
        MouseClick($MOUSE_CLICK_PRIMARY, $aCoord[0], $aCoord[1], 1)
        Sleep(500)
Local $cCoord = PixelSearch(1930, 40, 2560, 1020, 0xFAEBFF)
        MouseClick($MOUSE_CLICK_PRIMARY, $cCoord[0], $cCoord[1], 1)
        Sleep(500)
        If @error Then
            $i = 2
        EndIf
        Until $i = 1
    Case 2
        Do
;Local $bCoord = PixelSearch(1930, 40, 2560, 1020, 0xFFFF99)
Local $bCoord = PixelSearch(0, 0, 2559, 1059, 0xFFFF99)
        MouseClick($MOUSE_CLICK_PRIMARY, $bCoord[0], $bCoord[1], 1)
        Sleep(500)
Local $dCoord = PixelSearch(2000, 750, 2490, 950, 0xFBFF00)
        MouseClick($MOUSE_CLICK_PRIMARY, $dCoord[0], $dCoord[1], 1)
        Sleep(500)
Local $fCoord = PixelSearch(2000, 750, 2490, 950, 0xACACAC)
        MouseClick($MOUSE_CLICK_PRIMARY, $fCoord[0], $fCoord[1], 1)
        Sleep(500)
Local $cCoord = PixelSearch(1930, 40, 2560, 1020, 0xFAEBFF)
        MouseClick($MOUSE_CLICK_PRIMARY, $cCoord[0], $cCoord[1], 1)
        Sleep(500)
        If @error Then
            $i = 0
        EndIf
        Until $i = 2
;EndIf
EndSwitch

I will get rid of the comments when it will start working as I want it.
Also I think MsgBoxConstants is not required but is the remain of a Helpfile script :D

Link to post
Share on other sites
Link to post
Share on other sites
2 hours ago, Nine said:

Can I ask what is the application you are trying to automate ?  Looks to me some sort of a game, right ?  Plz read forum rules...

Yes, you are right and from what I read that technically declines my request.
Although if I can tell something more it is not for any score, game gave me access to something but I have to go through a lot of "popups" to receive what I actually care for, that's why I wanted to automate that.

Link to post
Share on other sites
  • Moderators

Welcome to the AutoIt forum.

Unfortunately you appear to have missed the Forum rules on your way in. Please read them now - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked.

See you soon with a legitimate question I hope.

The Moderation team

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...