View Single Post
Old 17th January 2003, 11:36   #31
J_Bloggs
Major Dude
 
J_Bloggs's Avatar
 
Join Date: Jan 2002
Posts: 1,778
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
File Type: zip minimize on inactive.zip (2.1 KB, 1741 views)

¯¯¯¯Joe Bloggs____
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
J_Bloggs is offline   Reply With Quote