Results 1 to 10 of 10

Thread: FindColor returning wrong color after it changes ingame

  1. #1
    Join Date
    Apr 2015
    Posts
    51
    Mentioned
    0 Post(s)
    Quoted
    19 Post(s)

    Default FindColor returning wrong color after it changes ingame

    Greetings

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

    This is all the code I'm using:

    Code:
    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?

  2. #2
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    I've had this problem a few times. My quick fix is this:
    Simba Code:
    WriteLn(GetColors([Point(230, 891])[0]);
    Let me know if that works for you.

  3. #3
    Join Date
    Apr 2015
    Posts
    51
    Mentioned
    0 Post(s)
    Quoted
    19 Post(s)

    Default

    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.

    Code:
    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?

  4. #4
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    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.

  5. #5
    Join Date
    Feb 2012
    Location
    Florida
    Posts
    193
    Mentioned
    1 Post(s)
    Quoted
    6 Post(s)

    Default

    Quote Originally Posted by Krzysztof View Post
    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.

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

    The End Awaits. . .

  6. #6
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Quote Originally Posted by LordJashin View Post
    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).

  7. #7
    Join Date
    Feb 2012
    Location
    Florida
    Posts
    193
    Mentioned
    1 Post(s)
    Quoted
    6 Post(s)

    Default

    Quote Originally Posted by Citrus View Post
    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/Simb...os_windows.pas
    Simba Code:
    procedure TWindow.ActivateClient;
      begin
        SetForegroundWindow(handle);
      end;

    Simba Code:
    \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

    The End Awaits. . .

  8. #8
    Join Date
    Feb 2012
    Location
    Florida
    Posts
    193
    Mentioned
    1 Post(s)
    Quoted
    6 Post(s)

    Default

    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.

    The End Awaits. . .

  9. #9
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Quote Originally Posted by LordJashin View Post
    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.

  10. #10
    Join Date
    Feb 2012
    Location
    Florida
    Posts
    193
    Mentioned
    1 Post(s)
    Quoted
    6 Post(s)

    Default

    Quote Originally Posted by Citrus View Post
    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.

    The End Awaits. . .

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •