|
Poolee
|
 |
« on: April 09, 2006, 02:52:02 PM » |
|
Hi there oh-guru-of-coding-snacks!  I have two monitors on my system, which I find REALLY useful (if haven't tried this setup, I REALLY recommend it!) and sometimes have the situation where I don't want the mouse going anywhere near the second monitor, e.g. when playing some full-screen games on monitor 1, the mouse will travel onto monitor 2, and make the game window inactive. So, is it possible to put together a little proggie to make the mouse stay on the current monitor (1 or 2 or whatever the current monitor ID is) through a key-combo toggle? Question: if it's a system setting (i.e. a mouse hook) will all programs respect the confinement rule? Anyway, REALLY looking forward to hearing from you about this!  Many thanks in advance Poolee
|
|
|
|
|
Logged
|
|
|
|
|
JeffK
|
 |
« Reply #1 on: April 09, 2006, 07:10:30 PM » |
|
I would be interested in this too. We have a set up at church where one monitor has Powerpoint Presenter running and the other feed is to a data projector showing the presentation. Often the mouse disappears into the presentation and requires a huge amount of horizontal scrolling to get it back. A way of limiting it to the first monitor would be good.
Jeff
|
|
|
|
|
Logged
|
|
|
|
|
Carol Haynes
|
 |
« Reply #2 on: April 09, 2006, 07:19:27 PM » |
|
I haven't got multi monitors to check but I assume that the X,Y coordinates just continue increasing/decreasing across the monitors as you move the mouse.
If this is the case it should be easy to write an AHK script using MouseGetPos and MouseMove that monitors the mouse position and if it goes outside certain boundaries it moves it back to the edge of the area.
It's too late at night here now but if noone else wants to do it I give it a stab tomorrow.
Can you confirm my first assumption is correct and if so give me the monitor size you are using where you want the mouse confined. (ie. the smallest and largest XY coordinates for the monitor,eg. my single monitor goes for X=0, Y=0 to X=1280, Y=1024)
|
|
|
|
|
Logged
|
|
|
|
|
|
jgpaiva
|
 |
« Reply #3 on: April 09, 2006, 07:30:36 PM » |
|
As Carol mentioned, this is possible in AHK. But it won't work exactlly as Poolee asked for. Notice that the mouse can be moved only after it passes from one screen to the other. It needs to pass to the other screen for it to be detected and moved back. So, it'll still make the games minimize, Poolee. On the other hand, it's easy to do what JeffK asked for. The following code should do it: [ copy or print] CoordMode,Mouse,Screen loop { Mousegetpos,MouseX,MouseY If MouseX > %A_ScreenWidth% MouseMove,%A_ScreenWidth%,%MouseY%,0 } [edit]the code above restricts the mouse to the primary screen. To restrict the mouse to the secondary screen (located on the right), replace '>' with '<'.[/edit]
|
|
|
|
« Last Edit: April 09, 2006, 07:32:39 PM by jgpaiva »
|
Logged
|
|
|
|
|
Carol Haynes
|
 |
« Reply #4 on: April 09, 2006, 07:37:26 PM » |
|
How about changing it to screenwidth-2 (when restricting to the primary screen) that way it should never reach the edge and so can't move to the other screen at all (+2 for the other monitor). A 2 pixel buffer shouldn't affect what you can do on the screen anyway.
|
|
|
|
|
Logged
|
|
|
|
|
jgpaiva
|
 |
« Reply #5 on: April 09, 2006, 07:43:26 PM » |
|
I'm afraid that doesn't work too, if you move the mouse fast enough, you can get to almost 1/4th of the other screen... 
|
|
|
|
|
Logged
|
|
|
|
|
Carol Haynes
|
 |
« Reply #6 on: April 10, 2006, 03:35:14 AM » |
|
 - at least if you get to 1/4 of the way across the other screen it should snap straight back. I wonder if it is possible in AHK to make a boundary box?
|
|
|
|
|
Logged
|
|
|
|
|
skrommel
|
 |
« Reply #7 on: April 10, 2006, 07:36:40 AM » |
|
 What you could try is to move your monitors around in the Desktop properties' Settings window, placing them side by side, the one above the other. If they are barely touching, the intersection is the only place where your mouse can travel from the one monitor to the other. Skrommel
|
|
|
|
|
Logged
|
|
|
|
|
skrommel
|
 |
« Reply #8 on: April 10, 2006, 07:40:55 AM » |
|
 Or if you don't need to absolutely lock the mouse to one monitor, try this, it just moves it back. ConfineMouse - Confine the mouse to one monitor. Features: - DoubleClick the tray icon to Disable/Enable. You'll find the downloads and more info at 1 Hour Software by Skrommel. Skrommel
|
|
|
|
|
Logged
|
|
|
|
|
skrommel
|
 |
« Reply #9 on: April 10, 2006, 08:13:41 AM » |
|
 Updated ConfineMouse to v1.1. Made it change to the monitor chosen in the settings without a restart. Skrommel
|
|
|
|
|
Logged
|
|
|
|
|
Poolee
|
 |
« Reply #10 on: April 10, 2006, 06:36:02 PM » |
|
Wow, that's awesome, and works really well!  Can you please add a setting to turn the tooltip on and off? Also, I got caught a couple of times with the mouse on the second monitor and couldn't get it back to the first, so had to tab, tab, cursor, tab, cursor until I got the icon in the systray then right-mouse click on the keyboard and disable the icon... so is there any chance of a key combo to toggle it on and off? One last thing... if I click as I move the mouse off the edge, the window in that monitor becomes de-activated... is there a way to suppress clicks outside the monitor's boundary? Thanks for the awesome work!!  Poolee
|
|
|
|
|
Logged
|
|
|
|
|
JeffK
|
 |
« Reply #11 on: April 11, 2006, 03:47:30 AM » |
|
Haven't tried them yet but thanks for the hints above. I'll give them a go.
Jeff
|
|
|
|
|
Logged
|
|
|
|
|
skrommel
|
 |
« Reply #12 on: April 11, 2006, 03:08:39 PM » |
|
 Sorry, the tooltip was for debugging. Download the one I just uploaded. Skrommel
|
|
|
|
|
Logged
|
|
|
|
|
skrommel
|
 |
« Reply #13 on: April 11, 2006, 04:17:21 PM » |
|
 Uploaded ConfineMouse v1.2. Added hotkey for disabling. Skrommel
|
|
|
|
|
Logged
|
|
|
|
|
skywalka
|
 |
« Reply #14 on: May 10, 2006, 04:05:28 AM » |
|
Would it be possible to stop the cursor leaving the 1st desktop at all? At the moment it encroaches on the "extended" monitor & has to be brought back (though, not very much). Can you force ConfineMouse's functionality to act as though there was no second monitor at all.
|
|
|
|
|
Logged
|
|
|
|
|
skrommel
|
 |
« Reply #15 on: May 11, 2006, 08:37:35 AM » |
|
 The only way I've found for this is to move the second monitor so it barely touches the first one in the Desplay settings. Skrommel
|
|
|
|
|
Logged
|
|
|
|
|
jgpaiva
|
 |
« Reply #16 on: May 11, 2006, 09:13:31 AM » |
|
 The only way I've found for this is to move the second monitor so it barely touches the first one in the Desplay settings. This might be the solution, it's definitelly worth trying. It has a very interesting effect with the mouser positioning. Just test it, you'll be amazed at the place your mouse comes up 
|
|
|
|
|
Logged
|
|
|
|
|
skywalka
|
 |
« Reply #17 on: May 11, 2006, 09:33:58 AM » |
|
 I never even knew it was possible to rearrange the monitors like that.  I've moved the extra monitor to the left which greatly minimises the problems I was having with scrollbars. Thanx.
|
|
|
|
|
Logged
|
|
|
|
|
darklight_tr
|
 |
« Reply #18 on: August 15, 2007, 12:29:36 AM » |
|
Love the program, but I have one suggestion. Could you allow the hotkey to toggle the confinement on and off instead of just turning the confinement off?
Thanks!
|
|
|
|
« Last Edit: August 15, 2007, 12:45:10 AM by darklight_tr »
|
Logged
|
|
|
|
|
|
|
mouser
|
 |
« Reply #20 on: October 23, 2009, 06:05:36 PM » |
|
Nice work snouffelaire, and welcome to the site 
|
|
|
|
|
Logged
|
|
|
|
|
lanux128
|
 |
« Reply #21 on: October 23, 2009, 10:54:44 PM » |
|
cool! this is quite an useful program. thanks snouffelaire. 
|
|
|
|
|
Logged
|
|
|
|
|
BaNDiToS
|
 |
« Reply #22 on: October 29, 2009, 03:21:27 PM » |
|
This code is what probably everybody in this thread is looking for and its a pure AHK solution without .NET-Frameworks. Just start and hit Win+C to enable / disable. Formatted for AutoIt with the GeSHI Syntax Highlighter [ copy or print] #SingleInstance,Force #NoEnv ; Mouse Rectangle Lock / Release #c:: { SetTimer, KeepLock, Off VarSetCapacity(Rect, 16) ; Define var size NumPut(0, Rect, 0) ; Left NumPut(0, Rect, 4) ; Top NumPut(1600, Rect, 8) ; Right NumPut(1200, Rect, 12) ; Bottom SetTimer, KeepLock, 50 } KeepLock: { ActiveOld := Active }
Bye
|
|
|
|
|
Logged
|
|
|
|
|
mouser
|
 |
« Reply #23 on: October 29, 2009, 03:58:20 PM » |
|
Welcome to the site BaNDiToS  Are we right in assuming you wrote this code?
|
|
|
|
|
Logged
|
|
|
|
|
BaNDiToS
|
 |
« Reply #24 on: October 29, 2009, 04:07:15 PM » |
|
Thanks for welcome.  Yes, I wrote the code. If something isn't clear, I can explain it.
|
|
|
|
|
Logged
|
|
|
|
|