SRL Archive - General Botting Help

FindColor returning wrong color after it changes ingame


Krzysztof

2019-08-26 06:27:12

Greetings

I have a problem I've no clue how to deal with.

This is all the code I'm using:


program new;
begin
Writeln('Color1 is ' + IntToStr(GetColor(230, 891)));
end.

So, I start up the game, and run the script. It returns the correct color, let's call it ColorA. I know it's correct because it's the same result I get using Simba's Color Picker on that very spot (part of HUD).
Now, I change the color. It's a colorful bar representing on of the ingame resources, so if I began with an empty bar I'll fill it up, or vice versa - changing the color drastically.

Now, if I'll use Simba's Color Picker I clearly see the color has changed to ColorB (in that very pixel). But if I run the above code, I get the ColorA result for some reason. Even if I restart Simba and load up the same code, I still get the outdated ColorA result.

The only way to get it to show an appropriate result, is to save and exit the game, then boot it back up and load the save. Then, Simba returns the correct color again. As if the game had some mysterious protection of layers or something, obfuscating the results by not making them update with the rest of the game.

Can somebody help me figure out what's going on and how to deal with it?

Citrus

2019-08-26 09:26:41

I've had this problem a few times. My quick fix is this:

WriteLn(GetColors([Point(230, 891])[0]);
Let me know if that works for you.

Krzysztof

2019-08-26 10:17:06

It seems to work, however it outputs 0 if I select the game window as the target window (instead of default full screen on Simba's startup).
I also checked my original script and, same, it works properly if I don't select the game window as target.


Compiled successfully in 266 ms.
3749166
Successfully executed.
New window: 393798
Compiled successfully in 265 ms.
0
Successfully executed.

Unfortunately, I don't know how to make it work for fullscreen, and when using Borderless Gaming for borderless windowed, it only outputs a 16777215 color. And the window is never at a fixed position, so I'd have to manually reset the color coordinates every time.

Anything to try next?

Citrus

2019-08-27 00:37:42

I don't know exactly what you're trying to do, but it sounds like you need to get the position of the window and set a custom client area.
http://docs.villavu.com/simba/scriptref/window.html
Check out GetProcesses() and the Client Area functions. You can use those to do everything you need.

LordJashin

2019-08-28 18:17:36

From: Krzysztof
It seems to work, however it outputs 0 if I select the game window as the target window (instead of default full screen on Simba's startup).
I also checked my original script and, same, it works properly if I don't select the game window as target.


Compiled successfully in 266 ms.
3749166
Successfully executed.
New window: 393798
Compiled successfully in 265 ms.
0
Successfully executed.

Unfortunately, I don't know how to make it work for fullscreen, and when using Borderless Gaming for borderless windowed, it only outputs a 16777215 color. And the window is never at a fixed position, so I'd have to manually reset the color coordinates every time.

Anything to try next?


You should use ActivateClient; before your call to GetColor, or some window activation functions to bring the window to the front when you run your script so that Simba can deal with it. Also why are you trying to GetColor when you can use Simba's built in color picker to get all your colors figured out for your FindColor functions. I can't understand what you are doing. But please enlighten us and we will help you.

Citrus

2019-08-28 22:37:22

From: LordJashin
You should use ActivateClient; before your call to GetColor, or some window activation functions to bring the window to the front when you run your script so that Simba can deal with it. Also why are you trying to GetColor when you can use Simba's built in color picker to get all your colors figured out for your FindColor functions. I can't understand what you are doing. But please enlighten us and we will help you.


ActivateClient is for keyboard input, and won't do anything to help if he's using the desktop as his client.
It sounds like he's using GetColor to check a single pixel, like the IsLoggedIn function for RS does (or did, idk).

LordJashin

2019-08-29 16:30:16

From: Citrus
ActivateClient is for keyboard input, and won't do anything to help if he's using the desktop as his client.
It sounds like he's using GetColor to check a single pixel, like the IsLoggedIn function for RS does (or did, idk).


Well. Regardless of what you think of ActivateClient; or the docs say. You need to use the
WINAPI method to bring the window to the foreground, front, active, whatever you want to call it.
In order for this to work. And i know because I've used the winapi raw before to do this exact thing.
In fact here's the windows specific file and this is what u need to have happen for this to work:
https://github.com/MerlijnWajer/Simba/blob/master/Units/MMLCore/os_windows.pas

procedure TWindow.ActivateClient;
begin
SetForegroundWindow(handle);
end;


\subsection{ActivateClient}

This functies tries to bring the current target to the front.
This will only work if the target is a System Window. When a bitmap is set as a
target, or a pointer to data, then it will not work.

This right here is the root of the answer. In order for you to get this to work with your game. You need to get your window to the "front".
This DOCS is from Simba's source. And its basically saying you need to select the outside of your game's window in order for it to do this.
If you select the inside bitmap. It won't bring it to the front. You need to select the actual window with the maximize button and everything and make sure u call ActivateClient;.

EDIT: Also here's my 2012 tutorial - [Tutorial] Scripting for other things besides Runescape with Simba

LordJashin

2019-08-29 17:08:19

Its because you have the Desktop as the Client. So your WINDOW isn't giving an UPDATED IMAGE to Simba. It has a STATIC image. Because YOU have the DESKTOP selected. NOT THE WINDOW.
Good luck mate.
You might have to try wizardry to get this to work.
It would be helpful if you gave us a screenshot of your desktop or something.

Citrus

2019-08-29 23:52:22

From: LordJashin
Its because you have the Desktop as the Client. So your WINDOW isn't giving an UPDATED IMAGE to Simba. It has a STATIC image. Because YOU have the DESKTOP selected. NOT THE WINDOW.
Good luck mate.
You might have to try wizardry to get this to work.
It would be helpful if you gave us a screenshot of your desktop or something.


He's not targeting the game window because it's being rendered in such a way that Simba can't read the pixels. Hence using the desktop.
It varies, but most applications will still render if they're not in the foreground.

LordJashin

2019-08-30 01:31:54

From: Citrus
He's not targeting the game window because it's being rendered in such a way that Simba can't read the pixels. Hence using the desktop.
It varies, but most applications will still render if they're not in the foreground.


Maybe. Surely this is correct for most everything. But games are unique. They use OpenGL, Direct3D, and etc to render. So I'm not sure. But anyway. Hopefully the OP can figure out a solution. Best of luck.