This example shows how the functionality of AutoPlay Media Studio 5.0 Professional can be expanded. In this case, one of Worm's infamous DLL's is used to track the movement of the mouse cursor. Using the Image.SetPos action, an image 'follows' the mouse cursor around the application.
Attached are two files:
Insert the following function into the global functions of your AutoPlay project:
Insert the following code into the On Timer event of your page:
Note: Change the object name to reflect the image that you want to follow the mouse. Change the false to true if you want the image to 'stop' at the 'bounds' of your application window
Insert the following code into the On Show event of your page:
Note: Change the 50 to any other number value that you want. If this is not performing as you want it to, play with this value.
Thanks to Worm for this excellent DLL. Please note that this example will not work with the standard version of AutoPlay Media Studio 5.0, as it does not support DLL function calls.
Attached are two files:
- Example Project
- Worm's 'Mouse Position' DLL
Insert the following function into the global functions of your AutoPlay project:
Code:
-- ****************************************************************** -- Name: ImageToMouse -- Purpose: Sets an image's position to the current mouse pointer's location -- Values: bBound: A boolean value, set to true if the image should stop -- at the 'bounds' of the application window, or false if it should not -- sImage: The object name of the image object to follow the mouse -- ****************************************************************** function ImageToMouse (sImage, bBound) -- ****( INITIALIZE LOCAL VARIABLES )**** local sPos = ""; local split_pos = 0; local XPos = 0; local YPos = 0; local nHandle = 0; local WPos = {}; local ISize = {}; local WSize = {}; -- ****( GET THE POSITION OF THE MOUSE POINTER )**** -- ****( THANKS TO WORM FOR THIS DLL )**** sPos = DLL.CallFunction("AutoPlay\\Docs\\CursorPos.dll", "GetMouseXY", "", DLL_RETURN_TYPE_STRING, DLL_CALL_STDCALL); -- ****( SPLIT THE RESULT FROM ABOVE INTO TWO USEABLE NUMBERS )**** split_pos = String.Find(sPos, ";;", 1, false); XPos = String.ToNumber(String.Left(sPos, split_pos-1)); YPos = String.ToNumber(String.Mid(sPos, split_pos+2, -1)); -- ****( GET THE WINDOW POSITION )**** nHandle = Application.GetWndHandle(); WPos = Window.GetPos(nHandle); -- ****( IF THE IMAGE SHOULD BE BOUND TO THE WINDOW DIMENSIONS )**** if bBound then -- ****( GET THE IMAGE SIZE AND WINDOW SIZE )**** ISize = Image.GetSize("Image1"); WSize = Window.GetSize(nHandle); -- ****( IF THE MOUSE POINTER IS INSIDE THE APPLICATION )**** if (XPos >= WPos.X) and (XPos + ISize.Width <= WPos.X + WSize.Width) and (YPos >= WPos.Y) and (YPos + ISize.Height <= WPos.Y + WSize.Height) then -- ****( SET THE IMAGE TO THE MOUSE POINTER POSITION )**** Image.SetPos("Image1", XPos - WPos.X, YPos - WPos.Y); end else -- ****( SET THE IMAGE TO THE MOUSE POINTER POSITION )**** Image.SetPos("Image1", XPos - WPos.X, YPos - WPos.Y); end end
Code:
ImageToMouse("Image1", false);
Insert the following code into the On Show event of your page:
Code:
Page.StartTimer(50);
Thanks to Worm for this excellent DLL. Please note that this example will not work with the standard version of AutoPlay Media Studio 5.0, as it does not support DLL function calls.