Page 1 of 5 123 ... LastLast
Results 1 to 25 of 105

Thread: TMufasaLayer - Draw on any window!

  1. #1
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default TMufasaLayer - Draw on any window!

    Simba plugin that allows you to draw on any window.

    • Follows the target window including minimizing/maximizing
    • Will only be on top of the target window - you can bring a window on top of the layer without any issues
    • Auto paint option, if enabled will automatically draw the image every 35ms using much less CPU than SMART.

    The files needed (plugin and application) are attached to this post, simply extract them info your plugins directory (most likely C:/Simba/Plugins/)

    Finally here is a script you can test with, it will draw on what you have set Simbas target as:
    Simba Code:
    {$loadlib libMufasaLayer}

    var
      Layer: TMufasaLayer;

    procedure SetupLayer;
    var
      W, H: Integer;
    begin
      GetClientDimensions(W, H);
      Layer.Init(GetNativeWindow, True, PluginPath);
      Layer.Bitmap.Init(Client.getMBitmaps());
      Layer.Bitmap.SetPersistentMemory(PtrUInt(Layer.GetBitmapPtr(W, H)), W, H);

      AddOnTerminate('FreeLayer');
    end;

    procedure FreeLayer;
    begin
      Layer.Bitmap.Free;
      Layer.Free;
    end;

    begin
      SetupLayer;

      while True do
      begin
        Layer.Bitmap.DrawClear(0);
        Layer.Bitmap.Rectangle(IntToBox(20, 80, 200, 200), Random($FFFFFF));
        Layer.Bitmap.DrawSystemText('The time is: ' + FormatDateTime('ttt', Now),
                                    'Arial', 40, Point(20, 20), False, Random($FFFFFF));

        Wait(500);
      end;
    end.
    Source: https://github.com/Olly-/mLayer
    Attached Files Attached Files
    Last edited by Olly; 04-17-2016 at 04:14 PM.

  2. #2
    Join Date
    Jan 2012
    Posts
    1,596
    Mentioned
    78 Post(s)
    Quoted
    826 Post(s)

  3. #3
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by Turpinator View Post
    Sure, it's just another alternative!

  4. #4
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default

    works great!

  5. #5
    Join Date
    Mar 2013
    Location
    Argentina
    Posts
    758
    Mentioned
    27 Post(s)
    Quoted
    365 Post(s)

    Default

    i was just thinking if this was possible yesterday , what a coincidence

  6. #6
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Similar to @bg5;'s utility, yeah?

    Cool. Very cool.
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

  7. #7
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Actually, this module accomplishes the same task but is completely different in every way.. The only similarity they both have is that they use a transparent window/form that sits on top of the target window.

    I like this one better because of the way you can target other windows (via Simba's crosshairs). This way you don't have to position the window manually. You don't have to pass it a handle either.

    It can be passed Simba bitmaps directly and doesn't use its own types (though you can modify the bg5's to do the same via a pointer to the raw memory). This also doesn't ship with its own include because it doesn't need one due to using Simba's internals (one of the things I like is the no-include option).

    Both of these use a transparent window that sits above the target window and don't actually draw on the target window itself. It literally draws above it or on its own window. Not on the target window directly.

    This one uses a separate process for that and communicates with that process just like how SMART communicates with Simba. I'm not sure that I like the external process idea but meh.. details..

    Same outcome, completely different implementation and ideas. API differs greatly.
    Last edited by Brandon; 10-22-2014 at 02:14 AM.
    I am Ggzz..
    Hackintosher

  8. #8
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    ...
    Ever tried to spawn a form in a fpc Simba plugin? I'm quite sure it's impossible please tell your wisdom me if you know how! It's annoyed me so much.

    e: There is one thing i could try, which i forgot was added.

    I am also trying to make it so the window isn't on-top of every window.. just the target window and it will minimize with it and such, again this is causing me trouble.. have crashed me pc a couple of times putting windows in never ending loops.
    Last edited by Olly; 10-21-2014 at 11:40 PM.

  9. #9
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    What how did you manage to crash it? You're in user-land mode.. not kernel mode :S. Must've done something terrible.

    I never tried FPC forms but I'm sure they are like WinAPI windows? If they block, they need to be non-modal OR created in a thread with a quit condition.

    Why exactly can't you create one in a plugin? I've done it in WinAPI for direct-x debugging.. Spawned a window from within a plugin injected into the RS client.


    To determine whether or not to hide your window, check if the target window handle is on screen (many ways to do this: IsIconic, GetWindowForeground, etc..) If it isn't, hide your window. Other option is to use "SetParent" and make your window a child of the target window. When the target is hidden, your window automatically gets hidden and stops drawing.
    Oh man, if SetParent worked it would be a dream but will take off all the 'magic things' to make the form transparent etc, or if i SetParent then call the 'magic things' it will apply to both windows.

  10. #10
    Join Date
    Mar 2007
    Posts
    5,125
    Mentioned
    275 Post(s)
    Quoted
    901 Post(s)

    Default

    Awesome work Olly, will be using this in the future when I'm going for 200m slayer (on-screen popups for when to re-pot ect)

    Forum account issues? Please send me a PM

  11. #11
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    @Brandon

    Here's the most simple example i can give.



    Yet what im doing is a exact copy of what is done in Simba for a 'regular' form.

    http://pastebin.com/a9gg4pye

  12. #12
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    Gimmie a sec to check it.. I got it working in C++ just fine: http://i.imgur.com/EKBgAEs.png I didn't make the baby form borderless because then you wouldn't recognise it in the picture but it has transparent background and sits on top of the parent window or any window..


    Code is: http://pastebin.com/7zCj4wKt Should also be doable in Pascal. I'll need to try this in PS to see..
    In raw win-api forms also, that's gonna suck going from nice Lazarus ones

  13. #13
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    @Olly;

    EDIT: It (creating forms in other threads) can't be done with VCL/Pascal/Delphi forms.. http://stackoverflow.com/questions/1...-processing-lo

    Turns out you'd have to use raw winapi to do it lol.. Ain't that something stupid. I guess, your solution of IPC (inter-process communication) really was the BEST solution there is..

    Time to clean up the above posts now
    Last edited by Brandon; 10-22-2014 at 02:15 AM.
    I am Ggzz..
    Hackintosher

  14. #14
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    @Olly;

    EDIT: It (creating forms in other threads) can't be done with VCL/Pascal/Delphi forms.. http://stackoverflow.com/questions/1...-processing-lo

    Turns out you'd have to use raw winapi to do it lol.. Ain't that something stupid. I guess, your solution of IPC (inter-process communication) really was the BEST solution there is..

    Time to clean up the above posts now
    Another thread is nice, but it's not needed...

    If you see this post (3 above) you can see that im syncing it, and it's still not working... weird :s

    As far as i know it's doing exactly the same as what Simba does for forms in Lape, If i could get this working i could do all this in a dll I think.

  15. #15
    Join Date
    Jun 2014
    Location
    Vancouver
    Posts
    150
    Mentioned
    1 Post(s)
    Quoted
    89 Post(s)

    Default

    Awesome stuff. Been wanting something like this recently. Love it!

  16. #16
    Join Date
    May 2012
    Location
    Moscow, Russia
    Posts
    661
    Mentioned
    35 Post(s)
    Quoted
    102 Post(s)

    Default

    Just remake it in Delphi via FMX Then you plugin can work in Win and In MacOS Also, you can implement TTransparentClientCanvas inbuilt in Simba and export it to Simba as part of TClient. I think that is much usefull then plugin.
    Last edited by CynicRus; 10-22-2014 at 06:59 AM.
    Per aspera ad Astra!
    ----------------------------------------
    Slow and steady wins the race.

  17. #17
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by CynicRus View Post
    Just remake it in Delphi via FMX Then you plugin can work in Win and In MacOS Also, you can implement TTransparentClientCanvas inbuilt in Simba and export it to Simba as part of TClient. I think that is much usefull then plugin.
    The thing thing i would do is add something like this to Simba, if i could get it working on linux but that would be very hard, if not impossible. :/

  18. #18
    Join Date
    May 2012
    Location
    Moscow, Russia
    Posts
    661
    Mentioned
    35 Post(s)
    Quoted
    102 Post(s)

    Default

    Quote Originally Posted by Olly View Post
    The thing thing i would do is add something like this to Simba, if i could get it working on linux but that would be very hard, if not impossible. :/
    Its possible, just create a transparent form with TPanel(align = alclient) as Inheriter of TGLCanvas Also you can make it in another thread...something like DrawingThread
    Last edited by CynicRus; 10-22-2014 at 05:35 PM.
    Per aspera ad Astra!
    ----------------------------------------
    Slow and steady wins the race.

  19. #19
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by CynicRus View Post
    Its possible, just create a transparent form with TPanel(align = alclient) as Inheriter of TGLCanvas Also you can make it in another thread...something like DrawingThread
    TGLCanvas = OpenGL? And you're still talking Dephi i guess.
    Last edited by Olly; 10-22-2014 at 06:20 PM.

  20. #20
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    This looks bad-ass do you think it will replace smart drawing?

  21. #21
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    Quote Originally Posted by KeepBotting View Post
    Similar to @bg5;'s utility, yeah?

    Cool. Very cool.
    From what I see in the source, mine is quite different. My util works in separated thread and it's totally independent from Simba, so you can use e.x. hotkeys and close it manually, also has more options :P Olly says it's alpha version so he will propably add some features in future.


    Quote Originally Posted by Brandon View Post
    I like this one better because of the way you can target other windows (via Simba's crosshairs). This way you don't have to position the window manually. You don't have to pass it a handle either.
    In ETL you don't position the window manually. You do it by include. However I agree that passing client window's handle directly to plugin to move/resize layer is a neat idea.

    It can be passed Simba bitmaps directly and doesn't use its own types (though you can modify the bg5's to do the same via a pointer to the raw memory). This also doesn't ship with its own include because it doesn't need one due to using Simba's internals (one of the things I like is the no-include option).
    Except that function, which helps user to fit window and 3 other function, which are actually wrappers ( so user can pass "bmp" instead of "GetMufasaBitmap(bmp).ToTBitmap.getBitmapHandl e" ), the rest of ETL include is merely addition created to repeat functionality of (old ?) paintsmart. So you can use my plugin alone aswell, if you wish... but includes make life easier ( I prefer doing things, if it's possible, outside of a plugin, because code is more accesible).

    IMHO Main point is that Olly's method should be a little bit faster.

    also his code is clean and tidy

  22. #22
    Join Date
    May 2012
    Location
    Moscow, Russia
    Posts
    661
    Mentioned
    35 Post(s)
    Quoted
    102 Post(s)

    Default

    Quote Originally Posted by Olly View Post
    TGLCanvas = OpenGL? And you're still talking Dephi i guess.
    C'mon Olly: http://orion.lcg.ufrj.br/RPMS/myrpms...e/GLCanvas.pas, crossplaform
    Per aspera ad Astra!
    ----------------------------------------
    Slow and steady wins the race.

  23. #23
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by CynicRus View Post
    My googling skills are weak!

  24. #24
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    @Olly;

    How do I draw text?

    Simba Code:
    bitmap.DrawText('Hello world', 'upchars07', point(10, 10), false, 255);

    I'm getting "Error: DrawText will not work unless the owner has been assigned at line 13"

  25. #25
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by Robert View Post
    @Olly;

    How do I draw text?

    Simba Code:
    bitmap.DrawText('Hello world', 'upchars07', point(10, 10), false, 255);

    I'm getting "Error: DrawText will not work unless the owner has been assigned at line 13"
    Yea, I never created the Bitmap with a owner I can fix that in a bit, otherwise you could just copy how text was drawn before i added them methods (see srl-6 drawing.simba).

    tip: Just include drawing.simba from srl-6, and you have alot more methods

Page 1 of 5 123 ... LastLast

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
  •