Jump to content
turboxikka228

Wait for color loop

Recommended Posts

turboxikka228

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

Share this post


Link to post
Share on other sites
turboxikka228
15 minutes ago, gruntydatsun said:
$i = 1
while 1
    if $i = 1 then 
        ConsoleWrite("Only do once")
    EndIf
    ConsoleWrite("Do this everytime")
wend

 

sorry but i didnt realise i'm newbie at autoit  :(

please explain more

Share this post


Link to post
Share on other sites
JLogan3o13

@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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
gruntydatsun

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

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

  • Similar Content

    • BogdanNicolescu
      By BogdanNicolescu
      While 1 / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / WEnd OR:

       
      HotKeySet("{ESC}", "Terminate") While 1 MouseClick("Right",674,422) MouseClick("Left",673,447) Sleep(2000) / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / MouseClick("Left",675,339) SLeep(3000) WEnd Func Terminate()     Exit 0 EndFunc  
      Sorry if i should't let this here to be found by newbies like me -.-'
    • santoshM
      By santoshM
      Dear friends i am facing a problem , i have created a window in autoit some time it is moving with the mouse curser even if iam not clicking the window 
    • sumanth1980
      By sumanth1980
      Here i am wrote a simple lines to install basic applications but when i clicked on one application/program to install it was working fine but when i cancel the program in the middle to install another program it was not working. I am not an expert in this but i want a solution for this ... Can any one help me on this....
      ORG-1.au3
    • PleaseHelpMEIWillLoveyou
      By PleaseHelpMEIWillLoveyou
      Is there a way to use a custom terminal or something from my pc and run a script on another pc.
      please let me know if its possible
      (not for anything bad just for a project im working on)
    • juniq
      By juniq
      Hey I'm writing on a script which places a link in the context menu so you can choose several mp3 files and rename them using id3 tag udf and year / time stuff variables.
      My problem: I'm renaming the files through "FileMove", But HOW can I get the current directory of the chosen files only? I can't use stringsplit cz there are more than 1 delimiter "\". and I can't trim the string because the stringlength changes every time. How can I get ONLY the directory where the files from $cmdline chosen are? 
×