Sign in to follow this  
Followers 0
sunshintabra

Need help with pixelsearch/getwinpos

7 posts in this topic

I have written a script for a game to macro a repetitive task. All it needed it to do is click the chat, send the text command, and click the OK button without having to put in individual coordinates.

To do this, I am using GetWinPos and PixelSearch. My problem is that I am using GetWinPos to provide the rectangle in PixelSearch. It works fine without it, but with it I have errors.

my examples in my code:

While $count < 1
$color = PixelSearch (50, 817, 640, 50, 0x002A20, 5)
        If @error Then
    MsgBox(0,"error","FAILURE")
    Sleep(3000)
        Else
            MouseClick ("left", $color[0], $color[1], 1, 0)
            $count = $count + 1
        EndIf
    WEnd

This one works just fine, it clicks the button and I do not recieve the msgbox saying error (i wrote that in to prove to myself it was or was not working)

While $count < 1
$size = WinGetPos ("Window Name")
$color = PixelSearch ($size[0] + $size[2], $size[0], $size [1] + $size[3], $size[1], 0x002A20, 5)
        If @error Then
    MsgBox(0,"error","FAILURE")
    Sleep(3000)
        Else
            MouseClick ("left", $color[0], $color[1], 1, 0)
            $count = $count + 1
        EndIf
    WEnd

This one (even though the OK button is clearly in sight, with my mouse even hovering over it) does not find a pixel of the selected color.

Its probably something simple, it always is.

And just in case someone thinks macroing a game is bad, its just repetitive mining every 12 seconds. Even the admin said it would be stupid to manually do it, just because its so repetitive.

Share this post


Link to post
Share on other sites



Please read the announcements and forum rules before posting.

There is a sticky one on top of every section regarding game bots and game automation: http://www.autoitscript.com/forum/forum-2/announcement-12-game-bots-and-automation/

Please stick to the rules.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Sorry, I thought about posting it just saying "hey fix this" and then the sample of code, but I prefer the straight forward route.

Now that we have confirmed my acknowledgement of the announcement and rules out of the way, is anybody willing to explain why my pixelsearch isn't working with getwinpos?

Share this post


Link to post
Share on other sites

"Acknowledge" the announcement ... but still continue violating it ... I am confused :x

I guess you simply don't get the point. As a friendly advice, drop it now. Do not atempt to justify or to argue - that will make it worse.

Your call.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

I appreciate your input, but this discussion is on pixelsearch and getwinpos. If you would like I could start a new thread that mentions nothing about GAME AUTOMATION, because to be honest you would have never known what it was for if I did not say so myself. I admitted that I probably shouldn't have, and it wasn't my best option, but I did. The forum still goes on, and my question still stands open.

If you have nothing to contribute, then let this thread die and I will not get my answer. If you want to continue to derail this thread by repeating the same thing another user said before you, then you will not be helping anyone at all.

Thank you.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

#include <Rules.au3>

$question1 = @Query("Forum", "Gaming", "Not allowed")
If @Failure Then
    $qestion2 = _PersistantQuery($question1)
    $result = 0
Endif
Return($result)

Edited by sleepydvdr

#include <ByteMe.au3>

Share this post


Link to post
Share on other sites

Sorry, I thought about posting it just saying "hey fix this" and then the sample of code, but I prefer the straight forward route.

Now that we have confirmed my acknowledgement of the announcement and rules out of the way, is anybody willing to explain why my pixelsearch isn't working with getwinpos?

Please reread and adhere to it.

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0