You can add a little more help for the user by setting the cursor’s position at will in a Liberty Basic program. This function can be used in tutorials and guides. Now, you’re probably wondering how the heck you can do this! Well, it is pretty simple.
First, open the window:
'This example demonstrates how to use user32 to set the ‘cursor at a given position'It is a function that may come in useful in tutorial and ‘guided tours'Use at will'Open the windowbutton#main.exit,"Push Me!",[push], UL,10,10open"An Example"forwindowas#main
Ok, now that our window is opened, lets declare our two variables; X and Y (yes it’s that simple)
'set the cursor position variables
x =500
y =500wait
Now, to make our program interesting, we will make a simple Do Loop with a timer to move the cursor slowly (and not instantly).
[push]'Set the timerdotimer1,[moveCursor]wait[moveCursor]
We’ve arrived to the fun part. Now, we will make the simple API call (user32) that will change the position of our cursor.
x = x -1
y = y -1calldll#user32,"SetCursorPos", _
x aslong, _ 'define x position
y aslong, _ 'define y position
result aslong
Finally, lets end the program and the loop.
loopwhile(x >250)and(y >250)timer0'CLOSE the Programclose#main
end
Here’s our demo:
'This example demonstrates how to use user32 to set the ‘cursor at a given position'It is a function that may come in useful in tutorial and ‘guided tours'Use at will'Open the windowbutton#main.exit,"Push Me!",[push], UL,10,10open"An Example"forwindowas#main
'set the cursor position variables
x =500
y =500wait[push]'Set the timerdotimer1,[moveCursor]wait[moveCursor]
x = x -1
y = y -1calldll#user32,"SetCursorPos", _
x aslong, _ 'define x position
y aslong, _ 'define y position
result aslongloopwhile(x >250)and(y >250)timer0'CLOSE the Programclose#main
end
Changing the cursor's position
By Daniel49
You can add a little more help for the user by setting the cursor’s position at will in a Liberty Basic program. This function can be used in tutorials and guides. Now, you’re probably wondering how the heck you can do this! Well, it is pretty simple.
First, open the window:
Ok, now that our window is opened, lets declare our two variables; X and Y (yes it’s that simple)
Now, to make our program interesting, we will make a simple Do Loop with a timer to move the cursor slowly (and not instantly).
We’ve arrived to the fun part. Now, we will make the simple API call (user32) that will change the position of our cursor.
Finally, lets end the program and the loop.
Here’s our demo: