Jump to content

Questions about "while"


Jostein
 Share

Recommended Posts

Was just wondering how i did the While "Not" code, like I want the script to pause when the value im asking for is not true

like

$value = PixelGetColor(1,1)

while $value (were the value is not true)

sleep(100)

wend

MouseMove(12, 765)
    Sleep(100)
    MouseDown("left")
    MouseUp("left")

Or if i can do it this way

do
$randomwait = random(100,500,1)
$value = PixelGetColor(1,1)
sleep($randomwait)
until $value = (the spesefic collor im looking for)

    MouseMove(12, 765)
    Sleep(100)
    MouseDown("left")
    MouseUp("left")

Dont know if im totaly lost here, but Atleast what i want is the script to pause while the pixelgetcolor dont find its true color.

Tried lots of different types of doing it, and I havent gotten it to work. And somhow Pixelgetcolor shows up whit the same value, even if the pixel is an different color.

Link to comment
Share on other sites

Well.. you mean something like this?

While Not $Value
    blah blah
Wend

:P

-edit-

Oops, sorry. That's not what you wanted. Have you tried this?

do
$randomwait = random(100,500,1);Not really necessary, just use Sleep()
$value = PixelGetColor(1,1)
sleep($randomwait)
until $value = (the spesefic collor im looking for)

That should do what you want.

Edited by Nahuel
Link to comment
Share on other sites

Was just wondering how i did the While "Not" code, like I want the script to pause when the value im asking for is not true

like

$value = PixelGetColor(1,1)

while $value (were the value is not true)

sleep(100)

wend

MouseMove(12, 765)
    Sleep(100)
    MouseDown("left")
    MouseUp("left")

Or if i can do it this way

do
$randomwait = random(100,500,1)
$value = PixelGetColor(1,1)
sleep($randomwait)
until $value = (the spesefic collor im looking for)

    MouseMove(12, 765)
    Sleep(100)
    MouseDown("left")
    MouseUp("left")

Dont know if im totaly lost here, but Atleast what i want is the script to pause while the pixelgetcolor dont find its true color.

Tried lots of different types of doing it, and I havent gotten it to work. And somhow Pixelgetcolor shows up whit the same value, even if the pixel is an different color.

Use

Sleep(1)
Link to comment
Share on other sites

issue solved:D

this code works.

#include "color.au3"
HotKeySet("{esc}", "terminate")
do
$value = PixelGetColor (19, 241)
sleep(1)
msgbox(2, $value, "Still not the right color",  15)
until $value = (16777215)
func terminate()
    Exit
    EndFunc
Link to comment
Share on other sites

well Nahuel, I now its not needed. But there is an good reason for it to be there:D Random times is importain for my script. But the (1) is to ofthen, only need a check each sec or 2, and i want the script to act randomly. when it comes to times it uses to perform actions

Link to comment
Share on other sites

this would also work for you (not tested):

#include "color.au3"
HotKeySet("{esc}", "terminate")

while $value <> 16777215
  $value = PixelGetColor (19, 241)
  sleep(1)
  msgbox(2, $value, "Still not the right color",  15)
wend

func terminate()
    Exit
EndFunc

<> means 'not equal to'

Also, try using Traytips instead of message boxes, personally I feel they get the job done better in most cases as theyre less obtrusive

Edited by ame1011
[font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font]
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

  • Recently Browsing   0 members

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