Scripting introduction Beginner Lessons Advanced Lessons Conclusion

 

Let’s make a button appear and disappear.

 

Scripts used in this chapter, lesson1-2.zip.

 

You can do a variety of things with scripts. We will start with using one button to make another button appear. After you have created both buttons, one needs to be set to not be visible initially for this to work; it is time to make the script. Open up notepad to a new text file.

 

Now a script needs some information to work on.

 

                          This tells the script to go get some info to work on

 

                          The button to get the info from

GET

16            The trait we want from the button

VISIBILITY

T1            This puts the info into a variable named T1

 

“I thought that visibility was something like ‘always show’. A variable can hold text?” If you open up the skin’s .UIS file in notepad you will see that all those states actually correspond to a number that we will use.

 

We use a variable because most of the commands in scripts wouldn’t understand ‘visibility of button 16’. You have 2 options for variables, T1-4 and TEMP1-4. The difference is the T type can be worked on by other commands but are only used by the current script and the TEMP kind can pass information between scripts but can’t be worked on. For example, you want to add to the alpha setting of a button and set it to be ‘on’ using variables. You would use the T type for the adding sections but TEMP type to let other buttons know that it is ‘on’.

 

The TEMP type only applies to that button. TEMP1 for button 12 is not the same as TEMP1 for button 13. In the same way T only applies inside the current script, even if more then one script is working on the same button. Be sure to keep this in mind! It can lead to “head pounding keyboard syndrome” if you don’t.

 

 

Correct use of TEMP

Cause for headaches

Get

16

TEMP1

T2

IF

TEMP1

0

=

END

Correct use of T

Cause for hair pulling

MATHS   

T1  

ADD  

15  

 

GET

21

T1

T2    

 

 

 

 

 

Now that we know what the visibility is for the button we can decide what to do.

 

                          

 

 

                           This tells the script we need to make a choice

 

IF                       This is the variable we already set

T1  

0                         What we are going to compare the variable to

=  

END             How we are going to compare them

 

What to do if they are equal. If they aren’t equal it skips this. In this case the script ends.

 

A real world way of saying this: If T1 (visibility of button 16) is 0 (always show) then end the script.

 

We can then assume that the button is not visible otherwise the script would have ended. Now we set the button to be visible.

 

 

 

 

 

                                    We use this to set a button trait or variable to something new

 

SET                               The button we are changing

16  

0                                  The value we are setting the trait to. This could also

VISIBILITY                   be a variable.

                                   

                                    The trait we are we are setting. This could also be a variable.

 

 

So now we have a button that started invisible that is now visible.

 

It is a good idea to tell WindowBlinds to repaint the button after you have made a change like this.

 

REPAINT

 

Our finished script would look like this:

 

; This is a comment. ;-)

 

; Get visibility of button 16

 

GET

16

VISIBILITY

T1

 

; Decisions 

 

IF

T1

0

=

END

 

; Make it visible

 

SET

16

0

VISIBILITY

 

REPAINT

 

 

Save this as a .wbs file in your skin’s directory. In our case we will use VisiButton.wbs. We need a way to trigger the script. In SkinStudio, go to the button that we want to click to make the other button visible.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

First enable scripting for the button.

For our example we want to use mouse press.

Set mouse press to use VisiButton.wbs.

If the script is not listed try going to the image and telling SkinStudio to refresh the image list.

When you go back to choosing a script yours should now be listed.

 

 

If you would like to see working examples look at “xpBlues lesson 1”.

 

“Great. Now the button is visible, now how do I make it go away?”

With a more complex script.

 

Let’s go back to our original script and make a few changes

(xpBlues lesson2)

 

; Get visibility of button 16

 

GET

16

We are using brackets this time to allow our IF commands to do more things. Everything inside the bracket is considered part of the IF command. Just make sure that there is a closing bracket!

 

We set the visibility to 16 here but you can use whatever setting works best for your button.

 

We still end the script here because otherwise you can run into trouble when it goes to the next command.

 

 

 
VISIBILITY

T1

 

; Make it invisible 

 

IF

T1

0

=

{

SET

16

16

VISIBILITY

 

REPAINT

 

END

}

 

; Make it visible

 

We don’t really need to have brackets or the extra END’s but as your scripts get more complex it can be a good habit to get into.

 

 

 
IF

T1

16

=

{

SET

16

0

VISIBILITY

 

REPAINT

 

END

}

 

END

 

 

“Why doesn’t the button show up on other windows?”

That is a limitation of WB. The script can only affect the current window.

 

 

“Wonderful. Now what was that you mentioned about changing the alpha?”

That means it is a good time to start the next chapter “lesson 3 " only affect the curraurrant windowok at XP Blues  Advanced scripting”.