Help - Search - Members - Calendar
Full Version: Pixel Detection Problems
AC Tools Everything Macro > AC Tool > AC Tool Discussion
cobalt06
How can I have AC Tool apply the Object and IsObject commands to a specific window rather than the whole screen? I need the game that I play to be in windowed mode, but it opens in a random location each time, effectively making the pixel capture useless.

I am trying to make a bot and the basic commands such as Keydown, Keys, and Delay are all that are required. However, within the game there are a set number of starting locations. When the game starts, each character appears randomly at one of the set starting points. So I am trying to use pixel detection to tell AC Tool which location I am at and then which set of commands should be applied.

I can get my process to work, but when I close the game and reopen it, the window is not in the same location it was before so my code is voided out.

Any help would be great.
DaMOB
QUOTE(cobalt06 @ Mar 16 2009, 01:14 AM) *
How can I have AC Tool apply the Object and IsObject commands to a specific window rather than the whole screen? I need the game that I play to be in windowed mode, but it opens in a random location each time, effectively making the pixel capture useless.

I am trying to make a bot and the basic commands such as Keydown, Keys, and Delay are all that are required. However, within the game there are a set number of starting locations. When the game starts, each character appears randomly at one of the set starting points. So I am trying to use pixel detection to tell AC Tool which location I am at and then which set of commands should be applied.

I can get my process to work, but when I close the game and reopen it, the window is not in the same location it was before so my code is voided out.

Any help would be great.

You mean a window inside the game or do you me the game itself in window mode? If it is a window that is never at the same spot each time it opens inside the game then you are screwed because you will have to hunt for it using procedures you will have to write to try and find it.
cobalt06
I meant the game is in windowed mode and starts in a random location.

HOWEVER wink.gif

I just found a program that allows you to locate a window to a specific location. It's a tiny program called WinWarden.

Anywho, so far my initial tests of it prove that my final code should work. Thanks for quick response though!
DaMOB
QUOTE(cobalt06 @ Mar 16 2009, 03:05 AM) *
I meant the game is in windowed mode and starts in a random location.

HOWEVER wink.gif

I just found a program that allows you to locate a window to a specific location. It's a tiny program called WinWarden.

Anywho, so far my initial tests of it prove that my final code should work. Thanks for quick response though!

Finding where your window mode game is starting at on the screen is not difficult to do within ACTool btw.
cobalt06
QUOTE(DaMOB @ Mar 16 2009, 04:08 PM) *
QUOTE(cobalt06 @ Mar 16 2009, 03:05 AM) *
I meant the game is in windowed mode and starts in a random location.

HOWEVER wink.gif

I just found a program that allows you to locate a window to a specific location. It's a tiny program called WinWarden.

Anywho, so far my initial tests of it prove that my final code should work. Thanks for quick response though!

Finding where your window mode game is starting at on the screen is not difficult to do within ACTool btw.


Mind showing me how, then? Because that was my original question. That and using pixel detection only within that window.
DaMOB
QUOTE(cobalt06 @ Mar 16 2009, 04:15 PM) *
QUOTE(DaMOB @ Mar 16 2009, 04:08 PM) *
QUOTE(cobalt06 @ Mar 16 2009, 03:05 AM) *
I meant the game is in windowed mode and starts in a random location.

HOWEVER wink.gif

I just found a program that allows you to locate a window to a specific location. It's a tiny program called WinWarden.

Anywho, so far my initial tests of it prove that my final code should work. Thanks for quick response though!

Finding where your window mode game is starting at on the screen is not difficult to do within ACTool btw.


Mind showing me how, then? Because that was my original question. That and using pixel detection only within that window.

{WindowTop} and {WindowLeft} will tell you where it is.
cobalt06
To continue with on a similar note (sort of...not really, but no sense creating a whole new thread). Is there a way to delay my bot until something is found?

As of right now, when I'm in game and start with a hot key, AC Tool runs through the list and performs the desired tasks. However, I need it to continuously loop when one game ends and the next begins. I don't want to use time delays due to loading times and lag issues (which can vary independently from game to game). So I want the script to be "paused" until it finds another Starting Point (see code), follow that portion of the code, and "pause" during loading. The screen changes during loading, so it won't find what has been defined and ends if I loop it (this would waste loops). If I loop it on a set count, even 10000000000000000 would not be enough because the bot would end after only a few games.

Like I said, while I'm working on this, I have only been working on the correct routes/keystrokes and starting each game with the hot key.

Basically, I need a DelayUntilIsObject command of some sort lol.

Here is a basic layout for the script what I am working on:

CODE
//Establish Starting Points

//Starting Point (1) at X, Y
Object StartingPoint(1)
blahblahblah
End

//Starting Point (2) at X, Y
Object StartingPoint(2)
  blahblahblah
End

//Starting Point (3) at X, Y
Object StartingPoint(3)
  blahblahblah
End

//Starting Point (4) at X, Y
Object StartingPoint(4)
  blahblahblah
End

//Starting Point (5) at X, Y
Object StartingPoint(5)
  blahblahblah
End

////////////////////////////////////

//Use Starting Points to determine specific path routes and key strokes

//Starting Point (1)
IsObject StartingPoint(1) at X, Y        //Locating Starting Point (1)
    //If character's initial location is at Starting Point (1), follow these key commands
End


//Starting Point (2)
IsObject StartingPoint(2) at X, Y        //Locating Starting Point (2)
    //If character's initial location is at Starting Point (2), follow these key commands
End


//Starting Point (3)
IsObject StartingPoint(3) at X, Y        //Locating Starting Point (3)
    //If character's initial location is at Starting Point (3), follow these key commands
End


//Starting Point (4)
IsObject StartingPoint(4) at X, Y        //Locating Starting Point (4)
    //If character's initial location is at Starting Point (4), follow these key commands
End


//Starting Point (5)
IsObject StartingPoint(5) at X, Y        //Locating Starting Point (5)
    //If character's initial location is at Starting Point (5), follow these key commands
End
Ahk
CODE
While 1 = 1
  IsObject Bla at $PosX, $PosY
     Break
  Else
     Delay 1000
  End
End



That's the jist of it. You need to probably add a computed timeout value for the macro to trip out if you wait way too long.

CODE
Compute Timeout = {Elapsedmsec} + 30000 //30 second timeout

//Then put this in your while loop by the delay section
If $Timeout < {elapsedmsec}
   TimeStamp didn't find object in 30 seconds...stopping
   Stop
End


Of course, you can modify the code to do what you want it to, like launch the game or something and then recover.
cobalt06
QUOTE(Ahk @ Mar 17 2009, 07:39 PM) *
CODE
While 1 = 1
  IsObject Bla at $PosX, $PosY
     Break
  Else
     Delay 1000
  End
End

So this is for the loading screen at the end of my code or would I have one of this set for each StartingPosition? I think you mean the latter, which would put my code at:
CODE
//Establish Starting Points

//Starting Point (1) at X, Y
Object StartingPoint(1)
  blahblahblah
End

//Starting Point (2) at X, Y
Object StartingPoint(2)
  blahblahblah
End

//Starting Point (3) at X, Y
Object StartingPoint(3)
  blahblahblah
End

//Starting Point (4) at X, Y
Object StartingPoint(4)
  blahblahblah
End

//Starting Point (5) at X, Y
Object StartingPoint(5)
  blahblahblah
End

////////////////////////////////////



//Use Starting Points to determine specific path routes and key strokes
Compute Timeout = {Elapsedmsec} + 30000 //30 second timeout

//Starting Point (1)
While 1 = 1
  IsObject StartingPoint(1) at X, Y        //Locating Starting Point (1)
    //If character's initial location is at Starting Point (1), follow these key commands
    Break
  Else
    If Timeout < {elapsedmsec}                         //Send Timeout to AC Tool Test Log
      TimeStamp did not find StartingPoint(1) in 30 seconds...stopping
      Stop
    End
  End
End

//Starting Point (2)
While 1 = 1
  IsObject StartingPoint(2) at X, Y        //Locating Starting Point (2)
    //If character's initial location is at Starting Point (2), follow these key commands
    Break
  Else
    If Timeout < {elapsedmsec}                         //Send Timeout to AC Tool Test Log
      TimeStamp did not find StartingPoint(2) in 30 seconds...stopping
      Stop
    End
  End
End

//Starting Point (3)
While 1 = 1
  IsObject StartingPoint(3) at X, Y        //Locating Starting Point (3)
    //If character's initial location is at Starting Point (3), follow these key commands
    Break
  Else
    If Timeout < {elapsedmsec}                         //Send Timeout to AC Tool Test Log
      TimeStamp did not find StartingPoint(3) in 30 seconds...stopping
      Stop
    End
  End
End

//Starting Point (4)
While 1 = 1
  IsObject StartingPoint(4) at X, Y        //Locating Starting Point (4)
    //If character's initial location is at Starting Point (4), follow these key commands
    Break
  Else
    If Timeout < {elapsedmsec}                         //Send Timeout to AC Tool Test Log
      TimeStamp did not find StartingPoint(4) in 30 seconds...stopping
      Stop
    End
  End
End

//Starting Point (5)
While 1 = 1
  IsObject StartingPoint(5) at X, Y        //Locating Starting Point (5)
    //If character's initial location is at Starting Point (5), follow these key commands
    Break
  Else
    If Timeout < {elapsedmsec}                         //Send Timeout to AC Tool Test Log
      TimeStamp did not find StartingPoint(5) in 30 seconds...stopping
      Stop
    End
  End
End


I removed the Delays because I need it to instantly move to the next search.

So what do I need after the break to start back at the beginning of the code? As of right now, the break keeps StartingPoint(1) looped forever. I've been trying with Restart, Exit, etc and cannot seem to find a placement that works. How can I get the whole code to restart at the beginning?


My problem with using time delay is that the game's map begins to move between 15-20 seconds into each game. The map is the same for each game, but after 15-20 seconds, the map moves. So if the timing is off for loading and lag times, the bot won't work.

I hope I'm explaining this correctly.
Ahk
You need to compute the Timeout before each while loop...because 30 seconds will pass probably way before you ever get to object number 5.

Secondly, you're missing the $ in front of Timeout, which will simply either cause an error, or it will test always the same, depending on whether Tool thinks Timeout (the word) is less than we'll say 35000 (the word of) the time in milliseconds.

Also need $ on X/Y on Isobjects. A small delay will not hurt your macro much, use at least a tenth of a second if it doesn't hurt the flow (Delay 100). Testing the object repeatedly will slow down your computer and hog CPU resources from the game/application you are using and might actually cause the objects to appear slower than it would otherwise.

The whole thing needs to be enclosed in an infinite loop. Breaks only affect the current looping structure, and you can use some Temporary/return value (constants) to see how to react after a specific loop using If.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.