Jump to content

Wait for color loop


Recommended Posts

Hello i have a code

HotKeySet("{F6}","_Exit")
While 1
   sleep(100)
$pos1 = PixelSearch (1176, 636, 1233, 671,0xF0AD4E)
If IsArray($pos1) = 1 Then
   sleep (10)
   MouseClick("left", 167, 659, 2)
   Sleep (100)
   Send("text1")
   Send("{ENTER}")
   Sleep (100)
   Send("text2")
   Send("{ENTER}")
   Sleep (100)
   Send("text3")
   Send("{ENTER}")
   Sleep (100)
   Send("text4")
   Send("{ENTER}")
EndIf
 $pos2 = PixelSearch(633, 660, 718, 692, 0x5CB85C)
 If IsArray($pos2) = 1 Then
    Send("{F5}")
    Sleep (1000)
    EndIf
WEnd
Func _Exit()
Exit
EndFunc

This loop works fine, but i want to send "text1","text2","text3","text4" only once, but it keep spamming "text1","text2","text3","text4" until $pos2 Please help me

Link to comment
Share on other sites

  • Moderators

@turboxikka228 perhaps further explanation of what you're trying to accomplish would help us help you. Relying on PixelSearch and Sends is a notoriously unstable way of doing things, as you're coming to find. There is doubtless an easier way to accomplish what you are after.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Hey, ok so I mean you create a counter set at one outside the while loop, only do the text1,2,3 part if the value of that counter is 1.  Increment the counter at the end of the while loop.  Like JLogan3o13 said, there's likely a better way to do what you want to do than using send though.

Anyway, here it is in your code:
 

HotKeySet("{F6}","_Exit")

$count = 1

While 1
    sleep(100)
    $pos1 = PixelSearch (1176, 636, 1233, 671,0xF0AD4E)
    if $count = 1 and IsArray($pos1) = 1 Then
        sleep (10)
        MouseClick("left", 167, 659, 2)
        Sleep (100)
        Send("text1")
        Send("{ENTER}")
        Sleep (100)
        Send("text2")
        Send("{ENTER}")
        Sleep (100)
        Send("text3")
        Send("{ENTER}")
        Sleep (100)
        Send("text4")
        Send("{ENTER}")
    EndIf

    $pos2 = PixelSearch(633, 660, 718, 692, 0x5CB85C)
    If IsArray($pos2) = 1 Then
        Send("{F5}")
        Sleep (1000)
    EndIf
    $count += 1
WEnd

Func _Exit()
    Exit
EndFunc

hope that helps

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

×
×
  • Create New...