How to Write a MAKI Script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • J_Bloggs
    Major Dude
    • Jan 2002
    • 1778

    #31
    I've made it, now in true 'How to Write a MAKI Script' style, I'm going to try to explain it.

    code:
    #include
    Include the all important std.mi, I've inclosed it in '<' and '>' because that includes it from the compliers path rather than the scripts, that way you only have to remember that one line and not figure out how many folders up you should go.


    code:

    Global Layout NormalLayout;
    Global Button MinimizeB;
    Global Timer minTimer;

    these define every object you use, don't forget the ';' after each line.


    code:


    System.onScriptLoaded(){

    Layout NormalLayout = getContainer("main").getLayout("normal");

    MinimizeB = NormalLayout.getObject("minimize");

    minTimer = new Timer;
    minTimer.setDelay(100);
    minTimer.start();
    }

    code:
    System.onScriptLoaded(){
    defines that the events and fuctions between the following '{' and '}' will happen when the script is loaded.

    code:
    Layout NormalLayout = getContainer("main").getLayout("normal");
    this gets the layout normal in the container main, I could have used:
    code:

    MainContainer = getContainer("main")
    Layout NormalLayout = MainContainer.getLayout("normal");

    But the other way is shorter and sweeter, and gets rid of a Global line.

    code:
    MinimizeB = NormalLayout.getObject("minimize");
    since maki doesn't have a minimize function, this gets a minimize button from a container to use instead. a dummy minimize button looks like this:

    code:



    No need for images or x&y, since the button won't be shown in the container anyway.


    code:

    minTimer = new Timer;
    minTimer.setDelay(100);
    minTimer.start();
    }

    this is the last peice of the System.onScriptLoaded() event. It sets up a timer, the timer that will be used to check wether winamp is active. It sets the delay to 100 milliseconds and starts the timer. This means it will run every 100 miliseconds.


    code:

    minTimer.onTimer() {
    if(System.isAppActive() == 0)
    MinimizeB.LeftClick();
    }

    This is the code that the timer triggers, it is outside the System.onScriptLoaded(), because it is a event of it's own, and it has it's own '{' and '}'.

    It acts exactly as it reads, if the system active status equals 0 (false, not active) then run the following line of code. The then statment is implyed by the line not having a ';' at the end of it.
    the line of code 'MinimizeB.LeftClick();' says find the MinimizeB object, and click the left mouse on it.





    So there you have it, a long winded explanation of something you probaly already understood.


    Oh and by the way, it's an add-on, and it has no openable containers.
    Attached Files
    ¯¯¯¯Joe Bloggs____
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

    Comment

    • hammerhead
      The Shark
      (Forum King)
      • Jul 2002
      • 2537

      #32
      ummm, its not true that maki stops working if you select another window
      Well duh. I was talking about when winamp is off. Sorry, I probably misread the q.
      .:SharkWork::Deviantart::Breed:.

      Comment

      • iPlayTheSpoons
        Major Dude
        • Aug 2001
        • 1030

        #33
        silly hammer head

        hey, very cool JB. However, you might wanna think about adding some extra stuff to eliminate the CPU usage that timers can add.

        im working on a custom vis tut, but im gunna be busy, so i might be a few days
        Published: OvalAmp | Scythe | Simple Amp(code) | PAD(code) | Classix10k | LayerONE (code)
        WIP: Aeschere | Manta | Winamp 5 SingleGUI
        Need some help? How to write a MAKI script | Custom Vis Script | Add a Notifier to Your Skin

        Comment

        • Gonzotek
          Gunslinger
          • May 2000
          • 4694

          #34
          I don't think there's anything he could add to eliminate the use of a timer in this instance. There is no event for the app being made active/inactive, only a function to check the state. The timing could be longer, which would cause it to check less often and therefore may introduce a slightly longer delay than 100ms, but consider that anything under a 1000 is only a second anyway, so an acceptable number might be 500.

          -=Gonzotek=-
          I was away for a while.
          But I'm feeling much better now.

          Comment

          • iPlayTheSpoons
            Major Dude
            • Aug 2001
            • 1030

            #35
            wellllll, i dont know about that

            you could have it stop the timer when it minimizes, then do on onEnterArea for a layer like the main BG or something else prominent start it up again. not the best solution, but its a possibility.
            Published: OvalAmp | Scythe | Simple Amp(code) | PAD(code) | Classix10k | LayerONE (code)
            WIP: Aeschere | Manta | Winamp 5 SingleGUI
            Need some help? How to write a MAKI script | Custom Vis Script | Add a Notifier to Your Skin

            Comment

            • J_Bloggs
              Major Dude
              • Jan 2002
              • 1778

              #36
              Yeah, but I'd like to keep it an add on, and not everyone uses the id="main" for their main window.

              But, I am mainly doing this to learn maki, so I might give it idea a try.

              I tryed a longer amount of time, the delay was kinda annoying.

              I should also delete it when the script unloads.
              ¯¯¯¯Joe Bloggs____
              ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

              Comment

              • whatsitsname
                Senior Member
                • Nov 2002
                • 386

                #37
                in goodbye.m try changing
                CloseButton.onLeftClick{
                to
                CloseButton.onLeftButtonDown
                so that way it happens a bit before Winamp3 closes

                Q-Designs another brand new site
                My Skins:HUD-G2

                Comment

                • iPlayTheSpoons
                  Major Dude
                  • Aug 2001
                  • 1030

                  #38
                  i think you miss read the script...CloseButton doesnt actually close winamp, which i clarified up there...it starts a timer, so it changes the text to "GoodBye" for 5 second before tiggering another action. since there no maki command for close, youd have to have a hidden close button so that on timer, it gets clicked (which i didnt put into that script)
                  Last edited by iPlayTheSpoons; 9 February 2003, 23:22.
                  Published: OvalAmp | Scythe | Simple Amp(code) | PAD(code) | Classix10k | LayerONE (code)
                  WIP: Aeschere | Manta | Winamp 5 SingleGUI
                  Need some help? How to write a MAKI script | Custom Vis Script | Add a Notifier to Your Skin

                  Comment

                  • eh?one
                    Senior Member
                    • Feb 2003
                    • 296

                    #39
                    in your batch file used for compiling you can add a pause line right after the command. that will cause the window to wait for a key press b4 it closes.
                    ie:
                    "C:\Program Files\Winamp3\mc.exe" "C:\Program Files\Winamp3\Skins\MYSKIN\scripts\MYSCRIPT.m"
                    PAUSE

                    Comment

                    • iPlayTheSpoons
                      Major Dude
                      • Aug 2001
                      • 1030

                      #40
                      that was mentioned in another thread after i put that up, but forgot to add it in here...woops, and thanks
                      Published: OvalAmp | Scythe | Simple Amp(code) | PAD(code) | Classix10k | LayerONE (code)
                      WIP: Aeschere | Manta | Winamp 5 SingleGUI
                      Need some help? How to write a MAKI script | Custom Vis Script | Add a Notifier to Your Skin

                      Comment

                      Working...
                      X