Adblock breaks this site

Advanced Applet Embedding in .NET

Discussion in 'Programming General' started by hackersrage, Oct 25, 2012.

  1. hackersrage

    hackersrage Newcomer

    Joined:
    Oct 25, 2012
    Posts:
    3
    Referrals:
    0
    Sythe Gold:
    0
    Advanced Applet Embedding in .NET

    I have seen a lot of variations on embedding a web control (or web browser using SetParent), however, I have not seen any examples on how to load a Java applet directly on a .NET form.

    Currently rocking out with VS 2012, as an experienced developer, however I know nothing of Java (except to read it).

    I have toyed with the Java for .NET kit, and really, I am curious about two things:

    1. How can you load/embed an applet directly. (injection ? etc ...)
    2. How can you emulate multiple keyboards/mouse devices. I am not talking about SendKeys or the API equivalent, or even using DirectInput as those all override the primary keyboard, so please don't suggest those unless you have some radical method that breaks the API into multi-touch/multi-keyboard (seperate from main control). As it stands, those API's are all wrapped around a single user input. SendKeys also has a great disadvantage in that it requires focus on the element it is sending to. I am looking to interact with controls regardless of their visibility state.

    I have also found some .NET source for using CEF framework in .NET, however it has some serious issues in VB.NET 2012, not to mention it was written in C# which seems to be missing objects necessary for it to load on the form.

    Any assistance would be greatly appreciated. I know this can be done in .NET, yes have not found any source examples. Java has an abundant amount of examples, but I simply can't work in a coding evironment that requires nearly every function to be in a separate file, and the language is not as verbose as .NET is (nor as fast -- please save the flames on this comment or we can debate it in private).

    Looking forward to intelligent (and hopefully helpful) responses.
     
  2. Raid500

    Raid500 Forum Addict

    Joined:
    Feb 11, 2007
    Posts:
    592
    Referrals:
    1
    Sythe Gold:
    0
    Advanced Applet Embedding in .NET

  3. Terrankiller

    Terrankiller Ex-Administrator
    Retired Administrator Visual Basic Programmers

    Joined:
    May 7, 2005
    Posts:
    1,286
    Referrals:
    1
    Sythe Gold:
    1
    Advanced Applet Embedding in .NET

    Wow, someone actually asks an interesting question for once.

    I'll post an example when I figure it out.
     
  4. hackersrage

    hackersrage Newcomer

    Joined:
    Oct 25, 2012
    Posts:
    3
    Referrals:
    0
    Sythe Gold:
    0
    Advanced Applet Embedding in .NET

    This would be fantastic my friend. It is essentially my only barrier. I know with ikvm, you can convert a jar to a .net library if that helps. Perhaps the "loader" could be a JAR canvas with exposed properties of mouse-click, mouse move, keydown, key up, etc (mouse movement x/y would be local to the component rather than other stuff. The main trick with loading the JAR from Runescape for example, is that it asks for encoded data to be passed along with it.

    Just need the bugger accessible in a more direct fashion from inside .NET

    I have some good java sources if needed. (pm for em if u want em)

    That is the Java kit I spoke of in my OP. It doesn't make anything clearer about how to load a live Java Applet from a URL directly into the form. It was a good answer though. I do see this as being potentially the most viable bridge to embedding a custom jar in .NET, however it doesn't appear (or my lack of Java knowledge doesn't permit) to embed an external JAR.
     
  5. Raid500

    Raid500 Forum Addict

    Joined:
    Feb 11, 2007
    Posts:
    592
    Referrals:
    1
    Sythe Gold:
    0
    Advanced Applet Embedding in .NET

    Well I know that is what you need, but how to do it, I'm not sure since I've never done it.
     
  6. Blupig

    Blupig BEEF TOILET
    $5 USD Donor

    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant
    Advanced Applet Embedding in .NET

    The reason why Java bots can interact with applets "silently" is because they're not emulating a control (like a keyboard, mouse) but are actually communicating directly with the applet. I assume that once you're able to embed an applet right into a .NET application that you'd be able to do the same thing relatively easily.
     
  7. Blupig

    Blupig BEEF TOILET
    $5 USD Donor

    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant
    Advanced Applet Embedding in .NET

    The reason why Java bots can interact with applets "silently" is because they're not emulating a control (like a keyboard, mouse) but are actually communicating directly with the applet. I assume that once you're able to embed an applet right into a .NET application that you'd be able to do the same thing relatively easily.
     
  8. Terrankiller

    Terrankiller Ex-Administrator
    Retired Administrator Visual Basic Programmers

    Joined:
    May 7, 2005
    Posts:
    1,286
    Referrals:
    1
    Sythe Gold:
    1
    Advanced Applet Embedding in .NET

    I have some time tomorrow to work on finding a solution for this.
     
  9. Blupig

    Blupig BEEF TOILET
    $5 USD Donor

    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant
    Advanced Applet Embedding in .NET

    Just look at the old ScionBot source, they did it. I plan on using it to figure out a loader if nobody else does lol :p
     
  10. Terrankiller

    Terrankiller Ex-Administrator
    Retired Administrator Visual Basic Programmers

    Joined:
    May 7, 2005
    Posts:
    1,286
    Referrals:
    1
    Sythe Gold:
    1
    Advanced Applet Embedding in .NET

    Send me the source on MSN, I don't want to start from scratch.
     
  11. iJava

    iJava .Previously known as RSGoldRush
    $200 USD Donor New

    Joined:
    Nov 21, 2011
    Posts:
    1,197
    Referrals:
    11
    Sythe Gold:
    485
    Discord Unique ID:
    220055593568829441
    Advanced Applet Embedding in .NET

    Taken from ScionBot :

    Code:
     //Use the Process class in order to load the bot. Redirect the Standard I/O to two streams located
            //in Stub.
            public void Load()
            {
                Process p = new Process();
                p.StartInfo.WorkingDirectory = System.Windows.Forms.Application.StartupPath;
                //We're executing the JVM here.
                p.StartInfo.FileName = Misc.ScionSettings.JavaDirectory + @"\*********";
                //Tell the JVM to run Bot.class with these arguments. Also, tell the JVM to add the runescape.jar
                //into the stack.
                p.StartInfo.Arguments = @"-cp .;loader; Bot " + super.botNumber + " " + super.botAccount.world + " " + DetermineBool(super.botAccount.members) + " " + super.port;
                //This is used to redirect the I/O.
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.RedirectStandardInput = true;
                //p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                p.StartInfo.CreateNoWindow = true;
                //Start the bot.
                p.Start();
                //Push the Standard I/O streams to the botOutput & botInput objects in Stub.cs.
                botProcess = p;
                botBasicOutput = botProcess.StandardOutput;
                botBasicInput = botProcess.StandardInput;
                //Run a loop until the Java-end tells us that the bot's GUI fully intialized.
                while (true)
                {
                    string message = botBasicOutput.ReadLine();
                    if (message.IndexOf("Initialized") > -1)
                        break;
                    //Makes the CPU very low consumption.
                    Thread.Sleep(100);
                }
                while (true)
                {
                    string message = botBasicOutput.ReadLine();
                    if (message.IndexOf("WaitingHandshake") > -1)
                        break;
                    Thread.Sleep(100);
                }
                botSocket = new TcpClient("localhost", super.port);
                botInput = new StreamWriter(botSocket.GetStream());
                botOutput = new StreamReader(botSocket.GetStream());
                while (true)
                {
                    string message = botBasicOutput.ReadLine();
                    if (message.IndexOf("HandshakeAccepted") > -1)
                        break;
                    Thread.Sleep(100);
                }
            }
    Somewhat easy to follow.
     
  12. Terrankiller

    Terrankiller Ex-Administrator
    Retired Administrator Visual Basic Programmers

    Joined:
    May 7, 2005
    Posts:
    1,286
    Referrals:
    1
    Sythe Gold:
    1
    Advanced Applet Embedding in .NET

    I can do that. Anyone got the runescape.jar file? And all other related files?
     
  13. Blupig

    Blupig BEEF TOILET
    $5 USD Donor

    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant
    Advanced Applet Embedding in .NET

    You'd have to actively download it and check it for updates if I'm right, or else you'll constantly be using an outdated jar
     
  14. Terrankiller

    Terrankiller Ex-Administrator
    Retired Administrator Visual Basic Programmers

    Joined:
    May 7, 2005
    Posts:
    1,286
    Referrals:
    1
    Sythe Gold:
    1
    Advanced Applet Embedding in .NET

    Oh great. Time to load up Runescape.
     
  15. iJava

    iJava .Previously known as RSGoldRush
    $200 USD Donor New

    Joined:
    Nov 21, 2011
    Posts:
    1,197
    Referrals:
    11
    Sythe Gold:
    485
    Discord Unique ID:
    220055593568829441
    Advanced Applet Embedding in .NET

  16. Blupig

    Blupig BEEF TOILET
    $5 USD Donor

    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant
    Advanced Applet Embedding in .NET

  17. iJava

    iJava .Previously known as RSGoldRush
    $200 USD Donor New

    Joined:
    Nov 21, 2011
    Posts:
    1,197
    Referrals:
    11
    Sythe Gold:
    485
    Discord Unique ID:
    220055593568829441
    Advanced Applet Embedding in .NET

    You never asked/needed it.
     
< how would i.. | Listen .v2m module music in VB .NET >


 
 
Adblock breaks this site