Jump to content

Is it possible to add a pixel search in a While Loop?


scorp2k19
 Share

Recommended Posts

Hi There, I have a very basic question, iv been watching most of Autoit Youtube videos and I understand how the While Loop works but I wanted to know if its possible to add a PixelSearch inside the While Loop?

For example:

HotKeySet("^!x", "MyExit")

While 1
  ; do stuff here
WEnd

Func MyExit()
    Exit 
EndFunc

This is what I normally use for loops but I wanted to understand how to add a pixel search inside a loop, for example doing something extra if a pixel search is found while doing the loop? 

Maybe I am not explaining myself correctly because I don't have a purpose right now but I really wanna understand if this would be possible and how would it work?

 

Also a quick question, when doing the PixelSearch, I normally use the Magnifier to search for Pixels with the AutoIt Windows Info and I dont know if the pixel is the entire square I see within the Magnifier? or just the center of the magnifier? 

 

Thanks in advance!!

 

Link to comment
Share on other sites

Yes, you absolutely can. Lots of things can be put inside of other things...

While True
    While True
        While True
            If PixelSearch() Then
                While True
                    ConsoleWrite("Hi!")
                WEnd
            EndIf
        WEnd
    WEnd
WEnd

(That's an example, don't try it) Loops, functions, and conditionals can all have things inside of them

Edit: Also, Welcome! :)

Edited by seadoggie01

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

On 9/27/2019 at 4:52 PM, seadoggie01 said:

Yes, you absolutely can. Lots of things can be put inside of other things...

While True
    While True
        While True
            If PixelSearch() Then
                While True
                    ConsoleWrite("Hi!")
                WEnd
            EndIf
        WEnd
    WEnd
WEnd

(That's an example, don't try it) Loops, functions, and conditionals can all have things inside of them

Edit: Also, Welcome! :)

Thanks!!! I will try it.

So basically I could do something like this right?

 

HotKeySet("^!x", "MyExit")

While 1
  ; do stuff here
   If PixelSearch() Then
   While True
    ; do this
    WEnd
   Endif

WEnd

Func MyExit()
    Exit 
EndFunc

 

Link to comment
Share on other sites

Yes. (I meant don't try it because there was no exit condition and no parameters for the PixelSearch... aka, it won't do anything)

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

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