How do I keep the mouse inside the window and make it invisible?

Posted By: AlexH

How do I keep the mouse inside the window and make it invisible? - 10/20/09 04:51

So far I have set mouse_mode to 0 and enable_mouse to 0 but the mouse still is visible and can move outside the window.

How can I capture the mouse and make it invisible.

Edit:
Okay I just found out that mouse_pointer must be 0 to make the mouse invisible, any ways to trap the mouse inside the window?
Posted By: AlexH

Re: How do I keep the mouse inside the window and make it invisible? - 10/21/09 16:17

Shameless bump.
Posted By: Superku

Re: How do I keep the mouse inside the window and make it invisible? - 10/21/09 19:36

Impossible, sry.
Posted By: flits

Re: How do I keep the mouse inside the window and make it invisible? - 10/21/09 20:33

this isnt impossible but you need to use some winapi function and that isnt that easy for beginners.
i have much problems myself with it.

ClipCursor is the thing you search (never tested if it works)

also i belief i tought there was a dll that can do the job

hope someone better in winapi can help you

flits
Posted By: AlexH

Re: How do I keep the mouse inside the window and make it invisible? - 10/22/09 21:22

Sorry but, what the hell? Virtually every game and its grandma has this functionality. Is this some sort of crude joke?

Originally Posted By: H.F.Pohl
Impossible, sry.

Thanks for the useless post.
Posted By: Superku

Re: How do I keep the mouse inside the window and make it invisible? - 10/23/09 00:57

I know a lot about C-Script and much about lite-C pure mode and it's not possible without advanced commands, you wanted an answer.
Code your one mouse script by moving a PANEL according to mouse_force inside the window or simply switch to fullscreen.
Posted By: Quad

Re: How do I keep the mouse inside the window and make it invisible? - 10/23/09 01:14

you can either use SetCursorPos and get the coordinates of the window on the screen, and set your cursor somewhere inside your window or

you could use ClipCursor and GetWindowRect duo.(ClipCursor need a RECT, you get RECT of engine window with GetWindowRect)

edit: i.e. this will trap mouse in the middle as long as you keep pressing space.

Code:
#include <acknex.h>
#include <windows.h>

void main(){
	RECT* window_rect;
	while(1){
		if(key_space){
			GetWindowRect(hWnd,window_rect);
			SetCursorPos(window_rect.left+screen_size.x/2,window_rect.top+screen_size.y/2);
		}
		wait(1);
	}	
}


Posted By: DJBMASTER

Re: How do I keep the mouse inside the window and make it invisible? - 10/23/09 02:04

I'd prefer the ClipCursor way...
Code:
#include <acknex.h>
#include <windows.h>

void main()
{
mouse_pointer = 0;
RECT* rect;
GetWindowRect(hWnd,rect);
ClipCursor(rect);
}


Posted By: AlexH

Re: How do I keep the mouse inside the window and make it invisible? - 10/25/09 17:24

Thanks for the replies, I figured out how to get clip cursor working.

I'd like to point out that GetWindowRect() returns the entire window's box (including the window title bar with the X close button).

Also you must reactivate the cursor clip when the window is moved/minimized.

I will make a wiki page on how to do this and post the link here.
© 2023 lite-C Forums