Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Rims Flames
11
Years of Service
User Offline
Joined: 5th Apr 2014
Location:
Posted: 9th Aug 2014 14:13
Hello community,

How can i force the cursor to stay in the middle of the screen until i press another button and disable this feature?

Thank You very much!

Rims Flames
MrValentine
AGK Backer
14
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 9th Aug 2014 15:56
Hoping I understood this correctly...

POSITION MOUSE X,Y

POSITION MOUSE SCREEN WIDTH()/2, SCREEN HEIGHT()/2

Should get you in the right direction, hopefully someone else will have time to fill in the lock mechanism for you... but it is best to try it yourself

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 9th Aug 2014 20:52
I will try to avoid posting any actual code but I will explain what you need to do.
You don't want to use any loops or anything that will halt the program.
You will need to use a variable as a flag to tell the program when to freeze the mouse and when to release it.
Use a condition to check that the flag is true and put Valentine's code in there.
Then you need a small routine to turn the flag on/off.

Here is a useful function for managing input:

You use it like this: [variable a] = silkey([key to monitor], [variable a]).
For example: spacebar = silkey(spacekey(), spacebar).
Place this code in a loop and the variable 'spacebar' will have the value 0 by default, then when the spacekey() is pressed 'spacebar' will have the value 1 for one loop after which it will change value to 3. When the spacekey() is released 'spacebar' will have the value 2 for one loop before returning to 0.

Formerly OBese87.
Rims Flames
11
Years of Service
User Offline
Joined: 5th Apr 2014
Location:
Posted: 9th Aug 2014 23:03
The positioning helped what i needed! Thank You very much Mr. Valentine and also Libervurto!

Rims Flames
MrValentine
AGK Backer
14
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 9th Aug 2014 23:41


Thank you



TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 10th Aug 2014 06:35


Doesn't that just simplify to the following?



Or am I missing something?

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 10th Aug 2014 06:45 Edited at: 10th Aug 2014 06:46
@Cometh
Yep. The 'AND 3' is there to keep the value two-bits-long. The smaller bit is the key's current state and the larger bit is its previous state. They get shifted along each loop and the oldest bit is cut off. With these two bits we can tell not just when a key is pressed but if it is the first detection of a key press, or if the key is being held down, or if has just been released, or if it has been idle for at least two loops.

Formerly OBese87.

Login to post a reply

Server time is: 2025-05-16 11:12:32
Your offset time is: 2025-05-16 11:12:32