Demusion

While 1 Loop, can't seem to get it working correctly

4 posts in this topic

Hello! I am quite new to the programming scheme, and I'm looking for some help regarding my newbie code.
I want it to work in a specific set of ways, but I'm not sure how to do it, so I came here for help.

So if it's possible, I want the specific to happen in the loop:

While 1
;Get to login 
MouseClick ("left", x, y, 2)

;Press the login button
MouseClick ("left", x, y)

;Wait for the login to finish
Sleep (5000)

; If the color of the button "Ok" is red, Press refresh and try again
If PixelGetColor (x ,y ) =   0xFF0000 Then MouseClick ("left", x, y)
ContinueLoop

;If it is green, then exit the loop and continue with the code
If PixelGetColor (x ,y ) =  0x008000 Then ExitLoop

Wend


If you have any questions, please feel free to ask me! :)

Share this post


Link to post
Share on other sites



Just now, Demusion said:

Hello! I am quite new to the programming scheme, and I'm looking for some help regarding my newbie code.
I want it to work in a specific set of ways, but I'm not sure how to do it, so I came here for help.

So if it's possible, I want the specific to happen in the loop:

While 1
;Get to login 
MouseClick ("left", x, y, 2)

;Press the login button
MouseClick ("left", x, y)

;Wait for the login to finish
Sleep (5000)

; If the color of the button "Ok" is red, Press refresh and try again
If PixelGetColor (x ,y ) =   0xFF0000 Then MouseClick ("left", x, y)
ContinueLoop

;If it is green, then exit the loop and continue with the code
If PixelGetColor (x ,y ) =  0x008000 Then ExitLoop

Wend


If you have any questions, please feel free to ask me! :)

I should probably explain it a little better specifically what it is that I want it to do:

If the color of the button is red, I want the loop to hit refresh and try again continuing from the top of the loop.
If it's green I want it to exit the loop and continue with the code.

Share this post


Link to post
Share on other sites

@Demusion welcome to the forum. If this a desktop app/web app/ etc? There are much easier ways to click the button, based on its current state, than using pixelgetcolor. Look at the AutoIt Window Info Tool in the same directory where you installed AutoIt, and hover over the button to see what information it gives you. It is always better to interact with a control (if possible) than to try mouse clicks.


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites
16 hours ago, JLogan3o13 said:

@Demusion welcome to the forum. If this a desktop app/web app/ etc? There are much easier ways to click the button, based on its current state, than using pixelgetcolor. Look at the AutoIt Window Info Tool in the same directory where you installed AutoIt, and hover over the button to see what information it gives you. It is always better to interact with a control (if possible) than to try mouse clicks.

Many thanks for the welcome :)
This is a flash based application in google chrome. Thank you, I'll try that.

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