Lesson 2 - Where am I going.
In this lesson we will explore the features in iP to deal with location in a room.
Lets change "Program Test;" to "Program WhereAmI;" in the editor.
We will use our the first iP command that we learned in lesson 1, "TALK" to say where we are in the room.
We will also use three other iP commands, MyName, GetUserX, and GetUserY.
As we learned in Lesson 1, "MyName" returns our iP user name.
GetUserX, and GetUserY return the X or Y location of a user based on their name.
Program WhereAmI;
Var
X, Y : Integer;
begin
X:=GetUserX(MyName);
Y:=GetUserY(MyName);
Talk('I am at '+IntToStr(X)+','+IntToStr(Y));
end.
Next we will use "SendTextToLog" which we learned about in Lesson 1 to send the location of our mouse to the log.
We will also add a new command "PauseFor(ms)"; which pauses for ms miliseconds.
This will allow us time to move the mouse where we want to, lets use 2000 ms which is two seconds.
Program MouseLocator;
begin
PauseFor(2000);
SENDTEXTTOLOG('The mouse is at '+IntToStr(GetMouseX)+','+IntToStr(GetMouseY));
end.
We can now use the log to store locations that we need to remember for scripts.
Its all fine and good to know where we are, or where we are pointing in a room, but lets take things a step farther.
Lets use a new command "MoveMeTo(X,Y)" to move us to where the mouse is without clicking.
When you look at the script below you may wonder why there is a -75 in both the X and Y locations.
The reason is that in iP a user's X and Y cooresponds to the upper left corner of their AV area.
We want to move the middle of our AV to where the mouse is pointed.
Program LeapMouse;
Var
X,Y : Integer;
begin
PauseFor(2000);
X:=GetMouseX;
Y:=GetMouseY;
MoveMeTo(X-75,Y-75);
end.
Tutorials |
Home |