Jump to content
Bixby Sayz

Get Windowed Client's position relative to Desktop?

Recommended Posts

Well I remember in SCAR 3.34 there was a way, can't find it in SCAR 3.35 though. In delphi there is a few functions of interest. Like WindowFromPoint, DesktopFromClient. Some handy point conversion for clients and desktops but I forget their names.

 

Well with the new windows api. You could find the client, and do like FindWindow on it, find where it is on the screen (which would be relative to desktop). Then add those (x, y) as the offset.

 

 

I forget what function finds the windows position on the screen too. Is it GetWindowBox?

Edited by LordJashin
Link to comment
Share on other sites

Figured it out on my own completely by accident.

 

Try putting this right after your call to SetupOSI in a script and set your graphics mode back to OpenGL. Your color functions should still work even though you are in OpenGL mode. (NB: If you are going to call Activate to bring the window to the front do this *before* setting the client)

 

[sCAR]var

ImageArea: TBox;

InputArea: TBox;

Client: TSCARClient;

 

begin

SetupOSI();

Client := GetClient();

ImageArea := Client.ImageArea;

InputArea := Client.InputArea;

SetClient(TSCARWindowClient.Create(GetDesktopWindow)).Free();

Client := GetClient();

Client.ImageArea := ImageArea;

Client.InputArea := InputArea;

[/sCAR]

 

Edit: Nvm. Doesn't work as well as I hoped. Returns a weird count when doing countcolors.

Edited by Bixby Sayz
Link to comment
Share on other sites

Figured it out on my own completely by accident.

 

Try putting this right after your call to SetupOSI in a script and set your graphics mode back to OpenGL. Your color functions should still work even though you are in OpenGL mode. (NB: If you are going to call Activate to bring the window to the front do this *before* setting the client)

 

[sCAR]var

ImageArea: TBox;

InputArea: TBox;

Client: TSCARClient;

 

begin

SetupOSI();

Client := GetClient();

ImageArea := Client.ImageArea;

InputArea := Client.InputArea;

SetClient(TSCARWindowClient.Create(GetDesktopWindow)).Free();

Client := GetClient();

Client.ImageArea := ImageArea;

Client.InputArea := InputArea;

[/sCAR]

 

Edit: Nvm. Doesn't work as well as I hoped. Returns a weird count when doing countcolors.

 

Yeah I noticed that countcolor works on some DirectX modes, like MIN with directX on. I bet there is an easier way to do it in delphi, I could port the function from Delphi eventually. I've started making my own library, with keyboard functions too, see this post.

 

Did Freddy say that you need the () after those functions? Or maybe you do that just in case or out of habit.

Edited by LordJashin
Link to comment
Share on other sites

It's a bit more complicated than that. There is a thread on how/why on the SRL forums. I'll see if I can dig up the link.

 

Edit: OpenGL Tutorial (Basics)

 

He has a working Reflection like OpenGL plugin: GLHook Beta. Interesting stuff, but I just haven't had time to play with it.

 

Off topic: I see SRL is suffering from the same lack of developers. The MSI project (which has really sucked for a while) has been put on hold.

Edited by Bixby Sayz
Link to comment
Share on other sites

It's a bit more complicated than that. There is a thread on how/why on the SRL forums. I'll see if I can dig up the link.

 

Edit: OpenGL Tutorial (Basics)

 

He has a working Reflection like OpenGL plugin: GLHook Beta. Interesting stuff, but I just haven't had time to play with it.

 

Off topic: I see SRL is suffering from the same lack of developers. The MSI project (which has really sucked for a while) has been put on hold.

 

SRL is just a big commit pool with sharks, and lack of any fish to eat because the water never changes. Thus the pool is barren, fish less, shark filled, mayhem. If a new fish ever comes along it drowns in the pool and dies...to the help section of the pool

Overall the ecosystem over there is "poor", and has no hope till the pool turns into an aquarium (OSI). Which we know will never happen.

 

OSI:

We over at OSI have labeled sections of the aquarium, and structures inside of it for fish to play with and hide behind. With a built in SHIT-Filter. Over at SRL all the droppings are inside the pool, and there is no filter. SRL 5, 6, 4. How about you keep it simple damnit, and provide some good documentation?! Can't stand looking at this:

[scar]

{

sdfsdfdsfsdfs

-----

 

~

 

 

 

~

 

Example: O WAIT NO ONE uses this LOL

[/scar]

Case closed.

 

No offense to anyone from SRL...I just like my pool of commits analogy xD, lots of exaggeration above

</rant>

 

I will take a look at all that stuff soon enough. Been working on the Login stuff. And I'm about to commit something major here soon.

Edited by LordJashin
Link to comment
Share on other sites

And I'm about to commit something major here soon.
Can't wait to see what you got.

 

On a side note I managed to get it to properly read color on both OpenGL and DirectX modes. Using the desktop client below on OpenGL is hit or miss, but the bitmap always works. (Note saving the client to a bitmap without the intermediate step of the desktop does not work)

 

[sCAR]procedure TestDesktopClient;

var

WindowClient: TSCARWindowClient;

DesktopClient: TSCARWindowClient;

BitmapClient: TSCARBitmapClient;

Bitmap: TSCARBitmap;

begin

// Should be 408 pixels of color clLoginText at Login screen...

 

// Get current client window so we can set it back later, then try count color...

WindowClient := TSCARWindowClient(GetClient);

WindowClient.Activate();

Wait(1000);

WriteLn('Client: ' + IntToStr(CountColor(clLoginText, RSX1, RSY1, RSX2, RSY2)));

 

// Set client to desktop and try count again...

DesktopClient := TSCARWindowClient.Create(GetDesktopWindow);

DesktopClient.ImageArea := WindowClient.InputArea;

SetClient(DesktopClient);

WriteLn('Desktop: ' + IntToStr(CountColor(clLoginText, RSX1, RSY1, RSX2, RSY2)));

 

// Save client area to bitmap, set as client, and try count again...

Bitmap := DesktopClient.Capture();

BitmapClient := TSCARBitmapClient.Create(Bitmap);

SetClient(BitmapClient);

WriteLn('Bitmap: ' + IntToStr(CountColor(clLoginText, RSX1, RSY1, RSX2, RSY2)));

 

// Set things back the way they were

SetClient(WindowClient);

DesktopClient.Free();

BitmapClient.Free();

Bitmap.Free();

end;

[/sCAR]

Link to comment
Share on other sites

Can't wait to see what you got.

 

On a side note I managed to get it to properly read color on both OpenGL and DirectX modes. Using the desktop client below on OpenGL is hit or miss, but the bitmap always works. (Note saving the client to a bitmap without the intermediate step of the desktop does not work)

 

[sCAR]procedure TestDesktopClient;

var

WindowClient: TSCARWindowClient;

DesktopClient: TSCARWindowClient;

BitmapClient: TSCARBitmapClient;

Bitmap: TSCARBitmap;

begin

// Should be 408 pixels of color clLoginText at Login screen...

 

// Get current client window so we can set it back later, then try count color...

WindowClient := TSCARWindowClient(GetClient);

WindowClient.Activate();

Wait(1000);

WriteLn('Client: ' + IntToStr(CountColor(clLoginText, RSX1, RSY1, RSX2, RSY2)));

 

// Set client to desktop and try count again...

DesktopClient := TSCARWindowClient.Create(GetDesktopWindow);

DesktopClient.ImageArea := WindowClient.InputArea;

SetClient(DesktopClient);

WriteLn('Desktop: ' + IntToStr(CountColor(clLoginText, RSX1, RSY1, RSX2, RSY2)));

 

// Save client area to bitmap, set as client, and try count again...

Bitmap := DesktopClient.Capture();

BitmapClient := TSCARBitmapClient.Create(Bitmap);

SetClient(BitmapClient);

WriteLn('Bitmap: ' + IntToStr(CountColor(clLoginText, RSX1, RSY1, RSX2, RSY2)));

 

// Set things back the way they were

SetClient(WindowClient);

DesktopClient.Free();

BitmapClient.Free();

Bitmap.Free();

end;

[/sCAR]

 

For OpenGL, DirectX:

I don't understand. So you can read color from the Desktop client, and bitmaps. So you should be able to, like cut the bitmap from the desktop to the area of the client (RS2). Then set that as the client somehow? This new client system is awesome but on how it works, gives me the cold shoulder sometimes.

 

In other news BIG UPDATE pushed! This fixes all the crap that went down with Setup Graphics, also take a look at the new write ln's!

 

Changes:

1. SMARTsetupEx in Initiate smart was put into a TRY statement so that if I closed it right as it booted, maybe it won't cause havoc ?

2. Tons of WriteLn's added, and fail safe maneuvering

3. OSI.scar Main include file, Comments, and shuffled crap around

4. BROWSER SUPPORT, with full writeln help, and tries to fix it for you. First it will notice that ColorCount doesn't work (Autosetup graphic) after that it has a LOOP. First it tries to Change the graphics settings back to Software (this is setup perfctly so that when SAFE MODE shows up next to software mode it doesn't mess everything up. If smart is loaded too, SAFE tends to show up in browser as well). After it changes the graphics settings, it will check RSReady, then it will click where AutoSetup graphic usually is. Then script will stop.

 

That's a rough/terrible summary. Things to watch out for though. Loading SMART, then trying the browser might cause problems! You might need to restart SCAR/close smart. I don't think you will ever have to close browser, but sometimes maybe refresh page? I'm not entirely certain, it was random when it happened to me.

It should be fine, I've ironed most of everything out now. Miracle the thing even works. I had lost faith a little in freddy's client system. Check out the commit here: https://github.com/OSI1/OSI1/commit/4fd6a9270c7499ec568272e0d47c3d32f1aaf4b0

 

I recommend everyone downloads this latest version Immediately! Because it is uber awesome!

 

1Geq9l.jpg

Edited by LordJashin
Link to comment
Share on other sites

For OpenGL, DirectX:

I don't understand. So you can read color from the Desktop client, and bitmaps. So you should be able to, like cut the bitmap from the desktop to the area of the client (RS2). Then set that as the client somehow? This new client system is awesome but on how it works, gives me the cold shoulder sometimes.

 

As I said I was playing around with the the login functions and setting graphics as well. One of the problems I wanted to solve was: How do you set the graphics if SCAR can't read the screen and you don't know what what size the client is or what graphics mode is being used for sure. What I came up with was grab the client screen from the desktop and not the client itself then use that to find colors/calc coords. Once that is done you can set things back to client and go merrily on your way.

 

But like I said I have little time to do more than "play" these days.

 

I do have a working routine to find and closes every single message/ad box in the game including the yelps icon, skill guide, in game ads, etc. It turns out there are 4 different types of X close buttons used but once you have them it's pretty easy to iterate through them.

Link to comment
Share on other sites

As I said I was playing around with the the login functions and setting graphics as well. One of the problems I wanted to solve was: How do you set the graphics if SCAR can't read the screen and you don't know what what size the client is or what graphics mode is being used for sure. What I came up with was grab the client screen from the desktop and not the client itself then use that to find colors/calc coords. Once that is done you can set things back to client and go merrily on your way.

 

But like I said I have little time to do more than "play" these days.

 

I do have a working routine to find and closes every single message/ad box in the game including the yelps icon, skill guide, in game ads, etc. It turns out there are 4 different types of X close buttons used but once you have them it's pretty easy to iterate through them.

 

If you could send me the script that closes the ads, or w/e code you have for that I could push it into OSI somewhere.

As for not reading the client, you can still get the SIZE of the client. GetWindowBox, etc. So we could integrate that and say if not RSClient image area in box and give it some tolerance on how far the dimensions can go. I think I will put this in at some point.

 

For not reading it, I leave it to you to figure out lol. It is possible, just like SendInput is possible to send keys to any application (potentially even minimized i heard here).

 

We do need to update the coordinate checking so that if we ever want to change it. We can just change some globals. Like RSX1, RSY1. I think most functions should have those in them.

Link to comment
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...