Bixby Sayz Posted July 18, 2012 Share Posted July 18, 2012 (edited) Playing around with some of the features in 3.35. Stumped on how to do this. It is a distinct possibility I am just being brain-dead/stupid due to being way overtired. In RS the client area at the login screen is smaller than the client area after login, all thanks to that new crazy toolbar. It is not present on the login screen. So...you manually target the login screen and proceed to login. The new toolbar now appears and client area gets wider and taller (and depending on your desktop screen resolution the browser window may scroll up or down, just for fun). So now the actual client area may be something like (X1-50, Y1-50, X2+50, Y2+50) in relation to what SCAR thinks the client area is (randomly pulled those numbers out of my ass - you get the idea). Ideally I would like to tell SCAR: imagine my mouse is now at position (x,y) and retarget for me just as if I had done it manually. Barring that it would be nice to be able to resize the client area "up" to the entire size of the browser window, not just the client area in the middle of the browser window. From there I could do some good ol' fashioned figuring and set the new client. I played around with the GetParentWindow but that always returns 0 for me. Didn't spend a lot of time on this. Just killing a little time waiting for water guy to show up and fill pool. (I give it a 50/50 chance patches I made to pool hold vs I flood my lawn) Good times! Side note and completely off topic: This is where I hate using closed source. My usual plan would be to go diving through the source code to see what is there and how I could make it work for me. Not an option in this case. Can't have everything I guess. Edited July 18, 2012 by Bixby Sayz Quote Link to comment Share on other sites More sharing options...
LordJashin Posted July 18, 2012 Share Posted July 18, 2012 Well Freddy made like 3 videos on the new features in 3.35 and how they work etc. The thread about it. You could try getting the class name, or any of the naming stuff. The FindWindow API is amazing. I think they have a FindWindowBySize too. I want Freddy to make some singular versions though. No one wants to have to deal with a HWND array all the time . If you want SCAR to give you the window handle at (x, y), from my understanding there is no way to do this. But there is a function in Delphi for it called - WindowFromPoint. Quote Link to comment Share on other sites More sharing options...
nemolorn Posted July 18, 2012 Share Posted July 18, 2012 unfortunately, I don't have an answer, but will sneak to piggy back a question. I'm having trouble replacing my FindWindowtitlePart function and wondering and half expecting the solution to be along the same response >_> Quote Link to comment Share on other sites More sharing options...
FHannes Posted July 18, 2012 Share Posted July 18, 2012 (edited) Playing around with some of the features in 3.35. Stumped on how to do this. It is a distinct possibility I am just being brain-dead/stupid due to being way overtired. In RS the client area at the login screen is smaller than the client area after login, all thanks to that new crazy toolbar. It is not present on the login screen. So...you manually target the login screen and proceed to login. The new toolbar now appears and client area gets wider and taller (and depending on your desktop screen resolution the browser window may scroll up or down, just for fun). So now the actual client area may be something like (X1-50, Y1-50, X2+50, Y2+50) in relation to what SCAR thinks the client area is (randomly pulled those numbers out of my ass - you get the idea). Ideally I would like to tell SCAR: imagine my mouse is now at position (x,y) and retarget for me just as if I had done it manually. Barring that it would be nice to be able to resize the client area "up" to the entire size of the browser window, not just the client area in the middle of the browser window. From there I could do some good ol' fashioned figuring and set the new client. I played around with the GetParentWindow but that always returns 0 for me. Didn't spend a lot of time on this. Just killing a little time waiting for water guy to show up and fill pool. (I give it a 50/50 chance patches I made to pool hold vs I flood my lawn) Good times! Side note and completely off topic: This is where I hate using closed source. My usual plan would be to go diving through the source code to see what is there and how I could make it work for me. Not an option in this case. Can't have everything I guess. If the client just resizes, you should be able to just call TSCARWindowClient(GetClient).Update, that should update the client with the current position on the screen. unfortunately, I don't have an answer, but will sneak to piggy back a question. I'm having trouble replacing my FindWindowtitlePart function and wondering and half expecting the solution to be along the same response >_> Replace it? Edited July 18, 2012 by Freddy Quote Link to comment Share on other sites More sharing options...
nemolorn Posted July 18, 2012 Share Posted July 18, 2012 When I upgraded to the 3.35 beta and started moving my scripts over, alot of functions stopped working, because they were removed I've gotten most replaced, I think the find client functions are the only ones still broken. one of those that were removed was the findwindowstitlepart and now I'm trying to find a way to use that same concept to locate different screens to make my script .35 compatible Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted July 18, 2012 Author Share Posted July 18, 2012 If the client just resizes, you should be able to just call TSCARWindowClient(GetClient).Update, that should update the client with the current position on the screen.Dammit Freddy you didn't even break a sweat for that one. Next time... Quote Link to comment Share on other sites More sharing options...
FHannes Posted July 18, 2012 Share Posted July 18, 2012 When I upgraded to the 3.35 beta and started moving my scripts over, alot of functions stopped working, because they were removed I've gotten most replaced, I think the find client functions are the only ones still broken. one of those that were removed was the findwindowstitlepart and now I'm trying to find a way to use that same concept to locate different screens to make my script .35 compatible FindWindowsEx can replace FindWindowsTitlePart. function FindWindowsEx(const ParentWnd: Hwnd; const Title, ClassName: string; const RecursiveSearch, CaseSensitive, PartialMatch: Boolean): THwndArray; To get the same functionality as FindWindowsTitlePart, you need to use GetDesktopWindow for ParentWnd, Title will be the title part, ClassName should be empty, RecursiveSearch is False, CaseSensitive, not sure, I guess False, you can decided that yourself. Finally, PartialMatch set to True, which is what makes the "titlepart" match. The function returns a THwndArray, which contains handles to each window it found. You can input those into TSCARWindowClient.Create() to create a new window client for the window with that handle, and input that into SetClient to activate the client. I know this system takes a bit more effort to work with, but it opens a lot of additional possibilities for the scripter. If you have any more questions, let me know. Dammit Freddy you didn't even break a sweat for that one. Next time... Heh, just make sure that the active client actually is a TSCARWindowClient object before you do that, at the moment Update and Exists are only available in that class, and for now I have no reason to change that. Quote Link to comment Share on other sites More sharing options...
LordJashin Posted July 19, 2012 Share Posted July 19, 2012 (edited) FindWindowsEx can replace FindWindowsTitlePart. function FindWindowsEx(const ParentWnd: Hwnd; const Title, ClassName: string; const RecursiveSearch, CaseSensitive, PartialMatch: Boolean): THwndArray; To get the same functionality as FindWindowsTitlePart, you need to use GetDesktopWindow for ParentWnd, Title will be the title part, ClassName should be empty, RecursiveSearch is False, CaseSensitive, not sure, I guess False, you can decided that yourself. Finally, PartialMatch set to True, which is what makes the "titlepart" match. The function returns a THwndArray, which contains handles to each window it found. You can input those into TSCARWindowClient.Create() to create a new window client for the window with that handle, and input that into SetClient to activate the client. I know this system takes a bit more effort to work with, but it opens a lot of additional possibilities for the scripter. If you have any more questions, let me know. Heh, just make sure that the active client actually is a TSCARWindowClient object before you do that, at the moment Update and Exists are only available in that class, and for now I have no reason to change that. So that's what Update does. Hmm. What a sneaky way to incorporate WindowFromPoint? Or what function does that use? I mean how can you check if it updates when they are different windows? Or are they? Freddy I can't complain about the window API, but it is going to be confusing at first for most. Going from this: [sCAR] if FindWindowTitlePart('Firefox', false) then ActivateClient; else WriteLn('Open Firefox'); [/sCAR] to This: [sCAR] program New; var HWNDarr: THwndArray; begin HWNDarr := FindWindowsEx(GetDesktopWindow, 'Firefox', '', False, False, True); if Length(HWNDarr) < 1 then WriteLn('Open Firefox'); ActivateWindow(HWNDarr[0]); end. [/sCAR] Edited July 19, 2012 by LordJashin Quote Link to comment Share on other sites More sharing options...
FHannes Posted July 19, 2012 Share Posted July 19, 2012 So that's what Update does. Hmm. What a sneaky way to incorporate WindowFromPoint? Or what function does that use? I mean how can you check if it updates when they are different windows? Or are they? Freddy I can't complain about the window API, but it is going to be confusing at first for most. Going from this: [sCAR] if FindWindowTitlePart('Firefox', false) then ActivateClient; else WriteLn('Open Firefox'); [/sCAR] to This: [sCAR] program New; var HWNDarr: THwndArray; begin HWNDarr := FindWindowsEx(GetDesktopWindow, 'Firefox', '', False, False, True); if Length(HWNDarr) < 1 then WriteLn('Open Firefox'); ActivateWindow(HWNDarr[0]); end. [/sCAR] Update only works when the window handle doesn't change of course, it refreshes the device context handle and recalculates the input and image boxes. There's no way to call window from point directly from SCAR, as I don't really see a use for it. Quote Link to comment Share on other sites More sharing options...