Announcement

Collapse
No announcement yet.

[EXAMPLE] Run a external program inside of your projects window.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [EXAMPLE] Run a external program inside of your projects window.

    Okay, so you want to run another program inside of your projects window, thus giving it the appearance of being embedded?
    This has been done before in 7.5 if I'm not mistaken but I haven't seen it done in 8 yet and thought I'd show you all how I accomplish this the easy way. Thanks to retesets WinAPI plugin and the Window actions of APMS I have created 3 little functions to handle the embedding/mounting, the resizing, and the termination of the external program.

    Here's a list of things you'll need to use these functions.
    1. AutoPlay Media Studio 8 (Obviously)
    2. retesets WinAPI Plugin v.22
    3. Some coding knowledge
    4. And an imagination


    Now that you know what you'll need, onto the functions

    Code:
    [COLOR="seagreen"]--Embed Code "Mounts an external program according to text/handle in the project window giving it the embedded appearance"[/COLOR]
    function Embed(Program) [COLOR="seagreen"]--the program argument is the keyword in the programs window title to search for.[/COLOR]
      Enum_Windows = Window.EnumerateTitles(true);
      for title,text in pairs(Enum_Windows) do
        Find_Window = String.Find(Enum_Windows[title], Program, 1, false);
        if Find_Window ~= -1 then
          Parent_Size = Window.GetSize(Application.GetWndHandle());
          Window_Handle = WinApi.FindWindow("", Enum_Windows[title]);
          Enum_Processes = System.EnumerateProcesses();
          for pid,filename in pairs(Enum_Processes) do
            if pid == Widow_Handle then
              Window_PID = pid
            end
          end
          Set_Parent = WinApi.SetParent(Window_Handle, Application.GetWndHandle());
          Window.SetSize(Window_Handle, Parent_Size.Width - 7, Parent_Size.Height - 13);
          Window.SetPos(Window_Handle, -5, -30);
          Page.Redraw();
          Window.Show(Window_Handle);
        end
      end
    end
    [COLOR="seagreen"]--Project On Size Event "Resizes the mounted window according to project size"[/COLOR]
    function EmbedSize()
      Parent_Size = Window.GetSize(Application.GetWndHandle());
      Window.SetSize(Window_Handle, Parent_Size.Width - 7, Parent_Size.Height - 13);
      Window.SetPos(Window_Handle, -5, -30);
      Page.Redraw();
      Window.Show(Window_Handle);
    end
    [COLOR="seagreen"]--Project On Shutdown Event "Terminates the process associated with the mounted window"[/COLOR]
    function EmbedDestroy()
      Enum_Processes = System.EnumerateProcesses();
      for pid,filename in pairs(Enum_Processes) do
        if pid == Window_PID then
           System.TerminateProcess(pid);
        end
      end
    end
    As you can see the first function (the embed/mount code) is relatively small as far as lines of code are concerned. :yes And thats pretty much it. ENJOY!

    Don't forget the program you pass to the embed/mount function must be running prior to calling it. As I said we aren't really embedding the program just merely giving it that appearance.

    Feel free to leave some feedback
    Last edited by TimeSurfer; 12-01-2010, 01:15 PM.

  • #2
    Here's a screenshot also...I gave my application the appearance of having google chrome embedded =p



    Just a little idea for you gfx guru's this could very easily be used to create a type of virtual shell interface for windows if you have the time and patience. (Granted you'll have to code re-size's for your application itself for just about every possible screen resolution "or just the more popular ones " and set the project to flat or bordered.)
    Last edited by TimeSurfer; 12-01-2010, 01:37 PM.

    Comment


    • #3
      Amazing. I just embeded AMS Personal in the app so now I can make another app with my app :P

      Awesome.

      Comment


      • #4
        I don't know how to impliment this?

        Comment


        • #5
          You can use it however you like but keep in mind that your users should have the program that its going to use installed unless you plan on using a portable version distributed with your project
          Last edited by TimeSurfer; 12-07-2010, 03:35 AM.

          Comment


          • #6
            Originally posted by Tone View Post
            I don't know how to impliment this?
            You just need to call the primary function and as the argument add the title of the window as a string in the example above

            Comment


            • #7
              Originally posted by TimeSurfer View Post
              You just need to call the primary function and as the argument add the title of the window as a string in the example above
              The functions above use the window title to mount the exe to your projects window. The newer functions below use the exe's pid in order to mount it to the project window.

              .::MOUNT CODE::.
              "Mounts an external program according to pid/filename in the project window giving it the embedded appearance."
              You must pass a string argument when calling the function which can be something like iexplore.exe which is the executable name for Internet Explorer or it can be any other program that is currently running. Yes you must run the executable first before calling this function. I would suggest running the application to be mounted as hidden or minimized.

              Code:
              function xMount(executable)
                xWindow = {}
                xWindow.PWnd = Application.GetWndHandle();
                xProcesses = Window.EnumerateProcesses(true);
                for handle,path in pairs(xProcesses) do
                  xWindow.Find = String.Find(path, executable, 1, false);
                  if xWindow.Find ~= -1 then
                    xPwndSize = Window.GetSize(xWindow.PWnd);
                    xWindow.CWnd = handle
                    repeat
                      Window.IsPWnd = WinApi.SetParent(handle, xWindow.PWnd);
                    until Window.IsPwnd ~= 0
                    Window.SetSize(handle, xPwndSize.Width - 6, xPwndSize.Height - 7);
                    Window.SetPos(handle, -8, -33);
                    WinApi.ShowWindow(handle, SW_NORMAL);
                    Page.Redraw();
                  end
                end
              end
              .::RESIZE MOUNTED WINDOW CODE::.
              "Resizes the mounted window according to project size."
              Call this function in your projects on size event.

              Code:
              function xSize()
                if xWindow then
                  xPwndSize = Window.GetSize(xWindow.PWnd);
                  Window.SetSize(xWindow.CWnd, xPwndSize.Width - 6, xPwndSize.Height - 7);
                  Window.SetPos(xWindow.CWnd, -8, -33);
                  WinApi.ShowWindow(xWindow.CWnd, SW_NORMAL);
                  Page.Redraw();
                end
              end
              .:ESTROY MOUNT CODE::.
              "Terminates the process passed to the function on call."
              This should be the same argument that was used in the xMount function.

              Code:
              function xDestroy(executable)
                xProc = System.EnumerateProcesses();
                for id,path in pairs(xProc) do
                  isRun = String.Find(xProc[id], executable, 1, false);
                  if isRun ~= -1 then
                    System.TerminateProcess(id);
                  end
                end
              end
              Last edited by TimeSurfer; 12-07-2010, 04:08 AM.

              Comment


              • #8
                I don't have time to restart my Shell program nor do I have the will lol but this does seem like a nice way to be able to embed the programs in to the shell long as we could multi react with the embederd sections and the way I can see this working means it should not be 2 hard to emebd all windows programs within your shell, long as there installed to the system like TimeSurfer said ,

                Comment


                • #9
                  Anyone got an .apz example please?

                  Comment


                  • #10
                    Ya hold on tone ill toss ya one. Im working on taking this even further and turning it into an action plugin (a little more involved then the code above gotta love the backend of lua lol let me tell you lol. with all the error checking with returns. and dont even lemme start on the debugging HAHA!)

                    Comment


                    • #11
                      Nice man, I think I might even have a play with this when you done great idea bud keep up the great work.

                      Comment


                      • #12
                        sim, you really do need to have a word with that plastic surgeon bud. Although he's done a nice job on your face, he's put your ears on upside down.

                        Comment


                        • #13
                          Do you have a project file for us?

                          Comment


                          • #14
                            @Tone and tamer1009:

                            I really can not understand how a guy can be so lazy: you are asking for an APZ when you could simply copy and paste the code from this thread and add 2 function calls in your project!

                            Shame!
                            We are slowly invading your planet to teach lazy humans to read the user manual.
                            But don't be scared: we are here to help.

                            Comment


                            • #15
                              Cyber they not really lazy, I would like to see this as plugin like he said as I think it would be useful to a few, the code for use is great I like he offered but code first with no apz means people that have the time to play about can, but I do see people might find it little easier as a apz they did ask nicely well tamer was little more lazy in as request lol.

                              @Tone, my surgeon was eaten by my cousin the yellow one that makes sandwichs he thought he would make a good sandwich but said he was little rubbery lol ....... so I think the upside down ears are in this year

                              (P.S I note gone nuts read up on lilo and stitch and my reply will make little more sense lol.)

                              Comment

                              Working...
                              X