Jump to content
AC Tool Forums

Recommended Posts

Hi Whabbit, I am having some doubts about isobject, even a basic isobject function I am not able to make it work. 

 

uses
  Classes,divide;

var
   d: TDivObject;


procedure dd
begin
  d:= TDivObject.Create;

  with d do
  begin
    Def.Add('128=0,0|128=0,2|128=0,4');
    Def.Add('212=2,0|212=2,2|212=2,4');
    Def.Add('128=4,0|128=4,2|128=4,4');
  end;
end;


begin

    if IsObject('d', 1041, 123) then
    begin
    timestamp ('cave');
    delay (3000);
    end;

end;

 

Share this post


Link to post
Share on other sites
On 9/11/2020 at 2:45 PM, minimx said:

Hi Whabbit, I am having some doubts about isobject, even a basic isobject function I am not able to make it work. 

 

Spoiler

 



uses
  Classes,divide;

var
   d: TDivObject;


procedure dd
begin
  d:= TDivObject.Create;

  with d do
  begin
    Def.Add('128=0,0|128=0,2|128=0,4');
    Def.Add('212=2,0|212=2,2|212=2,4');
    Def.Add('128=4,0|128=4,2|128=4,4');
  end;
end;


begin

    if IsObject('d', 1041, 123) then
    begin
    timestamp ('cave');
    delay (3000);
    end;

end;
wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

 

 

Although I checked the forums multiple of times yesterday. I just now seen your post. So my response is...

Okay, after just looking at the code I can see what the problem is. But, running the script verified my findings. And it gave me the chance to post what the error message you should have been getting. And to explain it.

When you ran the script above. You should have been getting the RunTime Error shown in the image below:

IsObject_Error.png

This is one of the Standard RunTime Error messages. As you can see it has a lot of information. But the information that you will need from this error message, is the file/library name, the method/command, and where in the source code to find the problem code. These three things can be found in the following:

  1. The file/library name can be found on the second line after 'File Library'.
  2. The method/command can be found on the fourth line, It is toward the end of the line surrounded by single quotes (') just before the closing parentheses.
  3. And you get the placement in the source code, by looking at the sixth line "Source position". This has the line number and character position of the code causing the problem within the file/library named in the second line.
  4. And line five can give you a hint as to what is wrong. And sometimes it doesn't make sense.

So, with the above information. We can try to figure out the problem with your script.

Okay, so have have a problem with IsObject command/method on line #23 of the Unit1 file/library. And from what it looks like from line five. A parameter being used in IsObject is empty (Null, or nil).

And sure enough looking at the code that you have posted. You are passing a wrong parameter to IsObject. But, the problem isn't because of a mistake on your part. It is a mistake on my part. Because after looking at the Help file. For what I have for the IsObject function. I have found that I had given the wrong information. This one is on me.

So, I'll post the information in the next post.

Share this post


Link to post
Share on other sites

There is a couple of problems with the code. And both problems are because of the information given in the help file.

Problem 1:  Even though the information to declare and initialize the DivObject is present. You had failed to initialize the DivObject.

Solve 1:  See Objects in Divide in the Help file. The information given here is not complete. But, it does give you the information to properly initialize the DivObject.

 

Problem 2:  The syntax given in the Help file for the IsObject function is wrong. And the code given in the Example should be better than what's there.

Solve 2:  I have been working on the Help file for that last several weeks. Trying to catch problems like this. And to make it better by giving better examples. Examples that actually work if you copy and paste the code into Divide.

Although I had not gotten to redoing the IsObject page in the Help file. I went ahead and done so, so that I can post the proper information here for you.

IsObject:

IsObject

 
Description:

IsObject is a function that will check to see if a object, defined in a DivObject,
is present on the screen. Then it will return a value of True or False as to whether
or not the object was found.
 
More information on how to use Object in Divide. See Objects In Divide
 
Syntax:

IsObject(objectName: TDivObject, XCoord: Integer, YCoord: Integer):ReturnValue;
 
Parameters:

Parameter   Description
ObjectName  The name of the TDivObject to search for.
X           Is the X coordinate to start searching for the DivObject at.
Y           Is the Y coordinate to start searching for the DivObject at.
 
Return value:
Value       Description
Boolean     True = the DivObject was found.
            False = the DivObject was not found.
 
Examples:

Example 1
uses
  Classes, Divide;

var
  objMyTestObject: TDivObject; //declaration of the TDivObject

{ the procedure to initialize the object
  that we will be using. }
procedure InitMyTestObject;
  begin
    objMyTestObject := TDivObject.Create;
    with objMyTestObject do
    begin
      Def.Add('128=0,0|128=0,2|128=0,4');
      Def.Add('212=2,0|212=2,2|212=2,4');
      Def.Add('128=4,0|128=4,2|128=4,4');
    end;
  end;

begin
  { call the InitMyTestObject procedure to
    initialize the objMyTestObject so that
    we can use it. }
  InitMyTestObject;

  { Now lets check to see if we can
    find the object. }
  if IsObject(objMyTestObject, 583, 256) then
    TimeStamp('The Object was found.')
  else
    TimeStamp('The Object was not found.');
end;

Although the example code is complete, proper and will run without any errors. You will not see the TimeStamp in the True block of the if statement. That is because the values used in the definition of the DivObject was just thrown together. But, it is code that you can look at and see the proper way of doing things.

Share this post


Link to post
Share on other sites

It works!


 

uses
  Classes,divide;

var
   d: TDivObject;


procedure dd
begin
  d := TDivObject.Create;

  with d do
  begin
    Def.Add('128=0,0|128=0,2|128=0,4');
    Def.Add('212=2,0|212=2,2|212=2,4');
    Def.Add('128=4,0|128=4,2|128=4,4');
  end;
end;


begin
     dd;
    if IsObject(d, 1041, 123) then
      begin
      timestamp ('cave');
      delay (3000);
      end
    else
      begin
      timestamp ('notcave');
      delay (3000);
      end;

end;

 

Share this post


Link to post
Share on other sites

To help show you the proper coding style. I edited your script to the following:

uses
  Classes, Divide;

var
   d: TDivObject;

procedure dd
begin
  d := TDivObject.Create;

  with d do
  begin
    Def.Add('128=0,0|128=0,2|128=0,4');
    Def.Add('212=2,0|212=2,2|212=2,4');
    Def.Add('128=4,0|128=4,2|128=4,4');
  end;
end;

begin
    dd;
    if IsObject(d, 1041, 123) then
    begin
      timestamp ('cave');
      delay (3000);
    end
    else
    begin
      timestamp ('notcave');
      delay (3000);
    end;
end;

Other than that, I don't see anything wrong. And since you said it works. I didn't bother to do more than a glance at it.

Share this post


Link to post
Share on other sites

But I don't seem to get a positive response, even when it should.

I created an object using divide screen, a part of the scroll icon. In divide macro it doens't find and in a similar AC tool macro it finds the object.

Divide macro

 

uses
  Classes,divide;

var
   d: TDivObject;


procedure dd // 4x4 11, 11
begin
  d := TDivObject.Create;

  with d do
  begin
    Def.Add('218=0,0|253=0,2|246=0,4');
    Def.Add('218=2,0|253=2,2|247=2,4');
    Def.Add('225=4,0|253=4,2|248=4,4');
  end;
end;



begin
    dd;
    if IsObject(d, 11, 11) then
      begin
      timestamp ('cave');
      delay (20000);
      end
    else
      begin
      timestamp ('notcave');
      delay (3000);
      end;

end;

It gives me a negative response, 'delay 3000 and notcave' even if the object is there.

Ac tool code:


 

Object d // 11, 11 4x4
  218=0,0|253=0,2|246=0,4
  218=2,0|253=2,2|247=2,4
  225=4,0|253=4,2|248=4,4
End

IsObject d at 11, 11
delay 20000
Else
  pause 
End

It gives me a positive answer: delays 20 sec.

Share this post


Link to post
Share on other sites

First of all, the test coordinates are not the same as what you had in your original code that you posted. There you had:

if IsObject('d', 1041, 123) then

And Second, in AC Tool, unless you are checking for an object that is on your desktop. You have to set the window for the Application/Game as the active window. Before you check for any objects.

It is the same for Divide. Unless you are checking for something on your Windows Desktop. You have to set the Application's/Game's window as the active window. Then you check for the object.

Example:

Uses
  Classes, Divide;
  
var
  MyObject: TDivObject
  
  procedure initMyObject;
  begin
  	// code to initialize the object goes here.
  end;
  
begin
  { Initialize the object }
  MyObject;
    
  { set the window as the active window }
  SetActiveWindow('Window Name/Title');
    
  { Delay for 2 seconds to allow the window
    to become the active window. This delay
    is necessary, because even on the same
    system. It can take from a fraction of
    a second to 2 seconds for the window
    to be brought forward and become the
    active window. And the amount of
    time is different each time. }
  Delay(2, 'sec');
    
  { No we test for the object }
  if IsObject(SomeObject, 0, 0) then
    TimeStamp('Object found.')
  else
    TimeStamp('Object not found');    
end;

 

Share this post


Link to post
Share on other sites


Divide macro:

uses
  Classes,divide;

var
   d: TDivObject;


procedure dd // 4x4 0, 0
begin
  d := TDivObject.Create;

  with d do
  begin
    Def.Add('107=0,0|107=0,2|107=0,4');
    Def.Add('107=2,0|107=2,2|190=2,4');
    Def.Add('107=4,0|198=4,2|239=4,4');
  end;
end;



begin

SetActiveWindow(2308);
MousePos(1326, 11); // when the setactivewindow is activated it changes the divide screen from the fullscreen, this mousepos + click sets it back to fullscreen
Delay(2, 'sec');
leftclick;

Delay(2, 'sec');
    dd;
    if IsObject(d, 0, 0) then
      begin
      timestamp ('cave');
      delay (9000);
      end
    else
      begin
      timestamp ('notcave');
      delay (3000);
      end;

end;




It gives me a negative response, 'delay 3000 and notcave' even if the object is there.

Ac tool macro:

 

Object d // 0,0 4x4
  107=0,0|107=0,2|107=0,4
  107=2,0|107=2,2|190=2,4
  107=4,0|198=4,2|239=4,4
End


SetActiveWindow 2760
delay 2000
MousePos 75, 395
leftclick
delay 2000
IsObject d at 0,0
delay 20000
Else
  pause 
End

It gives me a positive answer: delays 20 sec.

Edited by minimx

Share this post


Link to post
Share on other sites

I want to know how to write in Divide and how much faster it would do a search in the screen looking for an object. The game is Braveland heroes. and some silly browser games. I want to find objects in a board. So I can make a virutal map with enemies and my own creatures

Edited by minimx

Share this post


Link to post
Share on other sites

In the last macro I was searching for a piece of the icon of divide, to do a test in it's own window, to make it more simple. Braveland is a steam game and has it own window.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and to our Privacy Policy.