NoEars 10 Posted March 24, 2016 (edited) Hi to whoever can help me and thank you in advance I've been using SCAR for a while to automate some tedious jobs at my work and it works great! I've only used basic sequences up until now for use on my own machine but wish to make the script work on other computers. I recently got bmp's working consistently on my computer and others that run the same windows appearance (windows classic theme) The problem is some people have a different windows theme which changes the color and adds gradients sometimes. This then means the buttons I wish to find and click have nothing unique about them on the different appearances. I've attached two examples and my basic script. Win7 Classic: drop down menu tooltip text Win7 Basic: drop down menu tooltip text Let me know if I wasn't clear enough Cleanup.scar Cleanup.scar Edited March 24, 2016 by NoEars Quote Share this post Link to post Share on other sites
Wanted 12 Posted March 25, 2016 (edited) ... Your best bet is to simplify the problem. You want to click in roughly the same area so you can constrain your click boundaries a little bit.. if what you need to click is in a dynamic location find something that is predictable from which to offset it from. Let me know if you need further elaboration... Your next best bet is to attempt to detect multiple different styles by creating bitmaps or whatever for all or some of them and then forcing the end user to adhere during script usage. Your last resort should be trying to create some insanely complex (nearly impossible/probable) algorithm that can handle any different style... obviously not the route I would suggest... may be less work than that if you can find an existing function like deformedbitmap and magically get it working... would not recommend either. It may be a combination of the above and/or unmentioned methods, but I hope this helps you understand the trend in thought when it comes to solving color based macroing designs. Edited March 25, 2016 by Wanted Quote Share this post Link to post Share on other sites
NoEars 10 Posted March 29, 2016 Thanks heaps for the reply Wanted. It sounds like detecting multiple different styles will be the way. Would creating two bitmaps and then using two 'FindBitmap' functions with an if/or be the cleanest approach? The location of a lot of these buttons is based on where the user has dragged the window so they can be completely random & on rare cases on the second screen. Thanks again for the reply it will help greatly with what I'm trying to achieve. Quote Share this post Link to post Share on other sites
Wanted 12 Posted March 29, 2016 (edited) On closer examination, it appears the text you are looking for is the same for both. In that case you can make something like a bitmap mask or a TextTPA and use one of OSI's TextTPA functions {=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=function TextToTPA(Text: string; Chars: Integer): TPointArray;Contributors: Wanted, Freddy.Description: Turns a line of text into an array of points.Date Created: August 7th, 2011. By Wanted & Freddy.Last Modified: July 20th, 2012. By Freddy=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}function TextToTPA(Text: string; Chars: Integer): TPointArray;var BmpText: TSCARBitmap; Client: TSCARClient;begin Result := []; if (Length(Text) < 1) then Exit; BmpText := CreateBitmapMaskFromText(Text, Chars); Client := SetClient(TSCARBitmapClient.Create(BmpText)); try FindColorEx(Result, clWhite, 0, 0, BmpText.Width - 1, BmpText.Height - 1); finally SetClient(Client).Free; BmpText.Free; end;end; https://github.com/OSI1/OfficialSCARInclude/tree/master/Divi/Pixel {=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=function FindTextTPAInTPA(Text: string; Chars: Integer; SearchTPA: TPointArray; var P: TPoint): Boolean;Contributors: Wanted, Freddy.Description: Checks a TPA to see if contains the a line of text using its TPA.Date Created: October 20th, 2011. By WantedLast Modified: November 28th, 2011. By Wanted=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}function FindTextTPAInTPA(Text: string; Chars: Integer; SearchTPA: TPointArray; var P: TPoint): Boolean;var TextTPA, TPA: TPointArray;begin Result := False; TextTPA := TextToTPA(Text, Chars); try if (not (TPAInTPARelEx(TextTPA, SearchTPA, TPA))) then Exit; except Exit; end; P := TPA[0]; Result := True;end; https://github.com/OSI1/OfficialSCARInclude/blob/master/Divi/TFunctions/TPA.scar You can get the TPA of the text using FindColorEx(TPA, clBlack, X1, Y1, X2, Y2); For the chars you need something like LoadChars2 or LoadCharsFromFont2 you may be able to use the fonts from your windows folder (if you know which one) or worst case create your own font char bitmap set... Let me know if this works. Edited March 29, 2016 by Wanted Quote Share this post Link to post Share on other sites
NoEars 10 Posted March 31, 2016 (edited) Thanks again for the follow up I'm currently looking into TextTPA, In the meanwhile I found a common link between the formats and switched to using DTM's which has worked incredibly well. The icon in the top left of these menus is exactly the same, doesn't move, can't be resized and the offsets are the same on different windows appearances. So this seems to have solved all my problems and I've now got a script that's working on multiple setups. The only thing I would like to do to optimize what I've made is somehow get the script to type faster than 'typetext' allows, this is fairly nit picky as the whole script is still faster than a human can do it and more accurate. I reallllly appreciate your replies and the help you offer others it's so awesome. Edited March 31, 2016 by NoEars Quote Share this post Link to post Share on other sites
Wanted 12 Posted April 1, 2016 (edited) Glad you found a solution involving my suggestion to find something that was predictable and offset-able. The TypeText thing is a consequence of SCAR becoming more human like and forgetting to keep some of the old impossibly fast human input methods.. I've forgotten this issue existed in newer SCAR's (without the use of plugins) and I've mentioned it to Freddy a long time ago but if I've forgotten so I am sure so has he so you should make a thread about it in http://forums.scar-divi.com/forumdisplay.php?f=43 since the bug tracker is under re-construction. The work around in the mean time is pretty simple though... just make a custom function that uses KeyDown and KeyUp without any delay. Edited April 1, 2016 by Wanted Quote Share this post Link to post Share on other sites