Sign in to follow this  
Followers 0
Andrejj

Pixelsearch with ElseIf and checking string

3 posts in this topic

Hello,

I have two problems where I can't find a solution currently.

I have a snippet which does something if it finds a special color on a predefinied pixel. If the color cant be find it will set the global variable $count2 to 1:

Local $coord = PixelSearch(321, 300, 321, 300, 0xBB9200)
        If Not @error Then
            Send("{esc}")
            Sleep(100)
            Send("{esc}")
        Else
            $count2 = 1
        EndIf

Now I want to change the Else to an ElseIf and make another Pixelsearch. I tried this one but it doesnt work:

Local $coord = PixelSearch(321, 300, 321, 300, 0xBB9200)
        If Not @error Then
            Send("{esc}")
            Sleep(100)
            Send("{esc}")
        ElseIf
            Local $coord = PixelSearch(321, 300, 321, 300, 0xBB9200)
        If Not @error Then
            Send("{esc}")
            Sleep(100)
            Send("{esc}")
        Else
            $count2 = 1
        EndIf

Someone knows how its done right?

Now the other thing:

I am generationg a random String with twelve letters:

$zeichen = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  $string = StringSplit($zeichen, "")
  $anzahl_der_zeichen = 12
  $zeichen2 = ""
  For $i = 1 To $anzahl_der_zeichen
   $zeichen2 &= $string[Random(1, UBound($string) - 1)]
  Next

Now I want the script to check if the same letter is appearing three times consecutively.

If this is happening the script should loop one more time and generate a new string until the check is false.

Thanks for your help and a merry christmas to everyone here :)

Share this post


Link to post
Share on other sites



ElseIf needs a test condition. Did you read the help topic for If..ElseIf...Else...Endif ?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

mayby u want do something like that

Local $coord = PixelSearch(321, 300, 321, 300, 0xBB9200)
        If Not @error Then
            Send("{esc}")
            Sleep(100)
            Send("{esc}")
        ElseIf @error Then  ;<<<<<<<<<<<<<<<<<<<
            Local $coord = PixelSearch(321, 300, 321, 300, 0xBB9200)
            If Not @error Then
                 Send("{esc}")
                 Sleep(100)
                 Send("{esc}")
            Else
                 $count2 = 1
            EndIf   ; <<<<<<<<<<<<<<<<<<
        EndIf
Edited by sliwek

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
Sign in to follow this  
Followers 0