Jump to content

pixelsearhch, do.. until...


mrtgtr
 Share

Recommended Posts

Func OTUR()
    While 1
        PixelSearch(976, 140, 990, 147, 0x020202, 5)
        PixelSearch(976, 193, 990, 199, 0x020202, 5)
        PixelSearch(976, 245, 990, 252, 0x020202, 5)
        PixelSearch(976, 296, 990, 303, 0x020202, 5)
        PixelSearch(976, 349, 990, 356, 0x020202, 5)
        PixelSearch(976, 402, 990, 409, 0x020202, 5)
        PixelSearch(976, 453, 990, 460, 0x020202, 5)
        PixelSearch(976, 505, 990, 512, 0x020202, 5)
        If @error Then
            Sleep(50)
            Send("{c down}")
            Sleep(50)
            Send("{c up}")
            Do
                Sleep(100)
            Until Not @error
        EndIf
    WEnd
EndFunc   ;==>OTUR

Hello, I want to if cordinates are not black then press c one time and sleep until to cordinates are red, then when cordinates is red press c one time again. My loop is must be like this

but my script pressing c key continuously ( when cordinates are black , red...)

I hope I explain my problem sorry for my bad english.

Edited by Jos
Run code through tidy
Link to comment
Share on other sites

  • Developers

Maybe you need to rethink the logic of your script as this is not even close.

Reviewing your history here in this forum I think there is a slim chance this thread stays open for a long time.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Maybe you need to rethink the logic of your script as this is not even close.

Reviewing your history here in this forum I think there is a slim chance this thread stays open for a long time.

Jos

 

I can do with PixelGetColor and work good. (below)

Func OTUR()
    While 1
        If PixelGetColor(990, 146, 7) <> 0x0000000 Then
            If PixelGetColor(990, 199, 7) <> 0x0000000 Then
                If PixelGetColor(990, 251, 7) <> 0x0000000 Then
                    If PixelGetColor(990, 303, 7) <> 0x0000000 Then
                        If PixelGetColor(990, 356, 7) <> 0x0000000 Then
                            If PixelGetColor(990, 408, 7) <> 0x0000000 Then
                                If PixelGetColor(990, 460, 7) <> 0x0000000 Then
                                    If PixelGetColor(990, 512, 7) <> 0x0000000 Then
                                        Sleep(50)
                                        Send("{c down}")
                                        Sleep(50)
                                        Send("{c up}")
                                        Do
                                            Sleep(100)
                                        Until PixelGetColor(990, 146, 7) = 0x0000000 Or PixelGetColor(990, 199, 7) = 0x0000000 Or PixelGetColor(990, 251, 7) = 0x0000000 Or PixelGetColor(990, 303, 7) = 0x0000000 Or PixelGetColor(990, 356, 7) = 0x0000000 Or PixelGetColor(990, 408, 7) = 0x0000000 Or PixelGetColor(990, 460, 7) = 0x0000000 Or PixelGetColor(990, 512, 7) = 0x0000000
                                    EndIf
                                EndIf
                            EndIf
                        EndIf
                    EndIf
                EndIf
            EndIf
        EndIf
    WEnd
EndFunc   ;==>OTUR

I want to do this with pixelsearch for work smooth, but did not.

Edited by Jos
Tydied source
Link to comment
Share on other sites

  • Moderators

mrtgtr, it looks like your keyboard threw up. Can you please explain in detail what you're trying to accomplish, what application window you're trying to manipulate, and perhaps a screenshot? Help us help you ;)

"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

I can do with PixelGetColor and work good. (below)

Func OTUR()
    While 1
        If PixelGetColor(990, 146, 7) <> 0x0000000 Then
            If PixelGetColor(990, 199, 7) <> 0x0000000 Then
                If PixelGetColor(990, 251, 7) <> 0x0000000 Then
                    If PixelGetColor(990, 303, 7) <> 0x0000000 Then
                        If PixelGetColor(990, 356, 7) <> 0x0000000 Then
                            If PixelGetColor(990, 408, 7) <> 0x0000000 Then
                                If PixelGetColor(990, 460, 7) <> 0x0000000 Then
                                    If PixelGetColor(990, 512, 7) <> 0x0000000 Then
                                        Sleep(50)
                                        Send("{c down}")
                                        Sleep(50)
                                        Send("{c up}")
                                        Do
                                            Sleep(100)
                                        Until PixelGetColor(990, 146, 7) = 0x0000000 Or PixelGetColor(990, 199, 7) = 0x0000000 Or PixelGetColor(990, 251, 7) = 0x0000000 Or PixelGetColor(990, 303, 7) = 0x0000000 Or PixelGetColor(990, 356, 7) = 0x0000000 Or PixelGetColor(990, 408, 7) = 0x0000000 Or PixelGetColor(990, 460, 7) = 0x0000000 Or PixelGetColor(990, 512, 7) = 0x0000000
                                    EndIf
                                EndIf
                            EndIf
                        EndIf
                    EndIf
                EndIf
            EndIf
        EndIf
    WEnd
EndFunc   ;==>OTUR

I want to do this with pixelsearch for work smooth, but did not.

If by smooth you mean fast then you're out of luck. Pixelsearch is slow.

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

While 1
Local $xPos1 = 990
Local $yPos1 = 146
For $i=1  To 8
    Local $C1 = PixelGetColor($xPos1,$yPos1,7)
    If $C1 <> 0x000000 Then
        Sleep(50)
        Send("{c down}")
        Sleep(50)
        Send("{c up}")
    EndIf
    $yPos1 += 52
WEnd

This will probably do what you want it to do.

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

I would let OP answer this question before an answer is given. :shifty:

Can you please explain in detail what you're trying to accomplish, what application window you're trying to manipulate, and perhaps a screenshot? Help us help you ;)

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

  • Moderators

Although the code really leaves little to be desired, and we all have our own ideas of what's going on, ... the OP doesn't "need" to do anything.

They asked a straight forward question using specific code that doesn't prove to be malicious or concerning.

In all seriousness, why even post in this thread if you're going to be monotonous?  If you're going to be that way, there was a chat forum designed for you.

@mrtgtr

What the is "7" for in PixelGetColor(xpos, ypos, hwnd) hwnd parameter?  Obviously computergroove knows?  :blink:

From looking at the first code, I'm going to assume you think that putting 7 there is the number of pixels it will search top to bottom?

Using this as a basis of that hypothesis:

 

PixelSearch(976, 140, 990, 147, 0x020202, 5)

 

1.  You're not looking for 0x000000 in the above like you are in your PixelGetColor() queries.

2.  You're looking for 5 shades below or up from 0x020202

3.  You're not checking @error after every pixelsearch.

pseudo code for first post:

Func OTUR()
    Local $iErr
    While 1
        PixelSearch(976, 140, 990, 147, 0x000000)
        If @error Then $iErr += 1
        PixelSearch(976, 193, 990, 199, 0x000000)
        If @error Then $iErr += 1
        PixelSearch(976, 245, 990, 252, 0x000000)
        If @error Then $iErr += 1
        PixelSearch(976, 296, 990, 303, 0x000000)
        If @error Then $iErr += 1
        PixelSearch(976, 349, 990, 356, 0x000000)
        If @error Then $iErr += 1
        PixelSearch(976, 402, 990, 409, 0x000000)
        If @error Then $iErr += 1
        PixelSearch(976, 453, 990, 460, 0x000000)
        If @error Then $iErr += 1
        PixelSearch(976, 505, 990, 512, 0x000000)
        If @error Then $iErr += 1
        If $iErr = 8 Then ; number of pixelsearch calls
            ; unsure why you are sending up and down with a delay like that
            ;  but sure you have your reasons
            Sleep(50)
            Send("{c down}")
            Sleep(50)
            Send("{c up}")
            ; the below code is redundant, a sleep() only would be fine
            #cs
            Do
                Sleep(100)
            Until Not @error
            #ce
        EndIf
        Sleep(10)
        $iErr = 0
    WEnd
EndFunc   ;==>OTUR
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

 

Although the code really leaves little to be desired, and we all have our own ideas of what's going on, ... the OP doesn't "need" to do anything.

They asked a straight forward question using specific code that doesn't prove to be malicious or concerning.

In all seriousness, why even post in this thread if you're going to be monotonous?  If you're going to be that way, there was a chat forum designed for you.

@mrtgtr

What the is "7" for in PixelGetColor(xpos, ypos, hwnd) hwnd parameter?  Obviously computergroove knows?  :blink:

From looking at the first code, I'm going to assume you think that putting 7 there is the number of pixels it will search top to bottom?

Using this as a basis of that hypothesis:

 

1.  You're not looking for 0x000000 in the above like you are in your PixelGetColor() queries.

2.  You're looking for 5 shades below or up from 0x020202

3.  You're not checking @error after every pixelsearch.

pseudo code for first post:

Func OTUR()
    Local $iErr
    While 1
        PixelSearch(976, 140, 990, 147, 0x000000)
        If @error Then $iErr += 1
        PixelSearch(976, 193, 990, 199, 0x000000)
        If @error Then $iErr += 1
        PixelSearch(976, 245, 990, 252, 0x000000)
        If @error Then $iErr += 1
        PixelSearch(976, 296, 990, 303, 0x000000)
        If @error Then $iErr += 1
        PixelSearch(976, 349, 990, 356, 0x000000)
        If @error Then $iErr += 1
        PixelSearch(976, 402, 990, 409, 0x000000)
        If @error Then $iErr += 1
        PixelSearch(976, 453, 990, 460, 0x000000)
        If @error Then $iErr += 1
        PixelSearch(976, 505, 990, 512, 0x000000)
        If @error Then $iErr += 1
        If $iErr = 8 Then ; number of pixelsearch calls
            ; unsure why you are sending up and down with a delay like that
            ;  but sure you have your reasons
            Sleep(50)
            Send("{c down}")
            Sleep(50)
            Send("{c up}")
            ; the below code is redundant, a sleep() only would be fine
            #cs
            Do
                Sleep(100)
            Until Not @error
            #ce
        EndIf
        Sleep(10)
        $iErr = 0
    WEnd
EndFunc   ;==>OTUR

 

thanx I will try now,

5 is color tolerance at pixelsearch

7 is color tolerance at pixelgetcolor, same thing

Link to comment
Share on other sites

While 1
Local $Color = PixelSearch(990,146,990,512,0x000000,7,52)
    If $Color <> 0x000000 Then
        Sleep(50)
        Send("{c down}")
        Sleep(50)
        Send("{c up}")
    EndIf
     Sleep(100)
WEnd

Is this right?

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

  • Moderators
While 1
Local $Color = PixelSearch(990,146,990,512,0x000000,7,52)
    If $Color <> 0x000000 Then
        Sleep(50)
        Send("{c down}")
        Sleep(50)
        Send("{c up}")
    EndIf
     Sleep(100)
WEnd

Is this right?

Seriously?

Please look at the functions themselves and what each parameter is before attempting to help someone.  What is 52 supposed to represent in the hwnd parameter?

@mrtgtr

As I said, you put 7 in the hwnd parameter.  It has zero to do with tolerance for PixelGetColor.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Seriously?

Please look at the functions themselves and what each parameter is before attempting to help someone.  What is 52 supposed to represent in the hwnd parameter?

@mrtgtr

As I said, you put 7 in the hwnd parameter.  It has zero to do with tolerance for PixelGetColor.

While 1 
Local $Color = PixelSearch(990,146,990,512,0x000000,7,52);(XPos1,YPos1,XPos2,YPos2,color to scan for,variance for the color,skip 52 pixels to speed up search)
     If $Color <> 0x000000 Then;If the color isn't black then do the following
         Sleep(50)
         Send("{c down}")
         Sleep(50)
         Send("{c up}")
     EndIf
      Sleep(100)
WEnd

I think you need to look again. I believe I did it right.

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

  • Moderators

Indeed, I was caught up on your original post with the 7 in pixelgetcolor, then saw another you posted without working code, and reacted hastily, my apologies.

Edit:

But again, without changing the y value, you're repeating the same thing over and over without checking the other variants.  Are you sure what 52 pixels you're stepping in, probably x and y, and since x was always fixed in the OP original answer, that could be a huge issue.

Anyway, enough, help away.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I use pixelsearch however I am more fond of pixelgetcolor. PixelSearch starts on the top left corner of the x1,y1 coords and checks the color then it goes to x1, y1+1 and checks and then x1,y1+2 etc until it gets to the end of the search x axis then it goes to x2,y1 and so on. The 52 was approximately what he was doing in his first post. I am skipping 52 pixels and it is looping on the x axis which is 1 pixel high. If I say step 52 pixels it will process as search x1,y1 then look for the color then look at x1,y53 (maybe y52 but I dont think so).

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

In all seriousness, why even post in this thread if you're going to be monotonous?  If you're going to be that way, there was a chat forum designed for you.

I do not like to help game automation.

Just have a look at a small snippet from a topic that was locked:

  Sleep(100)
                Send("{p DOWN}")
                Sleep(150)
                Send("{p UP}")
                $ATAKBOX = True
                $TOPLUCEKBOX = True
                $BUFBOX = True

Another:

        PixelSearch( 160, 67, 160, 67, 0x000000 )
            If Not @error Then
            Send("{1 down}")
            sleep(50)
            Send("{1 up}")

And again, they duck the questions with an almost identical script in this >topic

Please, don't bash people trying to help you. This is obviously game automation and it's very obvious to see.  :whistle:

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

  • Moderators

I do not like to help game automation.

Just have a look at a small snippet from a topic that was locked:

  Sleep(100)
                Send("{p DOWN}")
                Sleep(150)
                Send("{p UP}")
                $ATAKBOX = True
                $TOPLUCEKBOX = True
                $BUFBOX = True

Another:

        PixelSearch( 160, 67, 160, 67, 0x000000 )
            If Not @error Then
            Send("{1 down}")
            sleep(50)
            Send("{1 up}")

And again, they duck the questions with an almost identical script in this >topic

Please, don't bash people trying to help you. This is obviously game automation and it's very obvious to see.  :whistle:

@Mikahs

The OP's 3 lines of code without context doesn't tell you what it is.

It's not against the rules to ask for help.  They can ask for help on anything they want, as long as they don't prove to be asking for game automation help.

People all to often put their two cents in on posts they truly have no idea what the OP post is all about, they simply assume.

Bottom line, it may be game automation, it may not.  If you have questions about it, don't post in the thread.  Eventually the person will make a mistake in that thread or another, there's no need for a lynch mob.

Don't get me wrong, I really do appreciate the help.  But Jos had this handled, didn't need people others chiming in.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Developers

Don't get me wrong, I really do appreciate the help.  But Jos had this handled, didn't need people others chiming in.

Totally agree!

@MikahS: All you could do is report the post when you feel there is something wrong, but in this case I was the first to respond so simply stay out and let me handle it.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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