Tuesday, December 3, 2013

Cursor Lock, Keep the Mouse Within the Application Window

If you have played any RTS(Real Time Strategy, ie. Starcraft, Age of Empires, Command & Conquer, etc.) game it's common knowledge you mainly move around the map by dragging your mouse to the edges of the window.  Well, I recently started playing an older RTS game, in windowed mode, and the mouse wasn't being locked within the application window which was really annoying.  Even when the game was fullscreen it wouldn't work because I have a dual screen setup.  After a quick Google search I stumbled upon an app called Cursor Lock.  The idea is simple, it locks your mouse cursor within the application window.  In my case I use a hotkey to turn on/off the cursor lock.  Below are the steps on how I set it up:

First download it from here and install it.

The first thing I did was set a hotkey to turn on/off the cursor lock.  I set it to something I wouldn't normally press during a game which is the Pause key.
Next go to Shortcut and select User Mode.  Then make sure to select the Lock Region checkbox and set it to Window Interior.
Again, this is for setting it up for a Windowed Mode game.  A fullscreen game when using more than one monitor may not use the same settings.

The Window option, as opposed to Window Interior, would allow you to resize the window since your mouse can move to the edges of the window, while the Window Interior option will just keep the mouse within the window which would prevent any resizing misclicks.

Once you have that setup you can test it to make sure it works.  Remember to trigger your hotkey if it doesn't lock within the Cursor Lock window.

Now that it works you click the Create Shortcut button and name it whatever you wish.  I saved the shortcut to my Desktop which I then copied over to my Startup folder (You can access the Startup folder by going to Start>All Programs>Right click the Startup folder and drag the shortcut into that folder).  Now when I boot into Windows the application will automatically run and I can trigger the hotkey whenever I want to lock the cursor.

Older Games:
I have recently been playing an older RTS, C&C Generals Zero Hour, and unfortunately the cursor lock program did not work when in Windowed Mode.  The cursor was being locked to the window but wouldn't pan the camera at all.

There still is an issue with full screen mode when using 2 monitors.  The current fix I am using is to just disable to 2nd monitor with Windows.  It's a lot better than unplugging it.  Below are the steps on how to easily accomplish this:

Right click on your Desktop and go to Screen Resolution.

Then choose to Show desktop only on X on the Multiple displays option.
This will disable the 2nd monitor and allow you pan around the map correctly within the game.

Hope this helps.

*The Program Mode allows you to create a shortcut which will also open whichever game you assign.  I prefer to use a hotkey instead of having multiple game shortcuts.


  1. Thank you for sharing the App

  2. Can't get it to work. No matter what hotkey I assign, it doesn't trigger. I followed the instructions above and the only thing I achieve is permanently locking the mouse inside the initial Cursor Lock program by clicking the Test button. I have to Alt+Tab out to get the cursor to unlock. The hotkey won't lock it to any window and it won't unlock after initiating a test. Clicking Test again only results in the Error window asking me if I want to close the previous instance before opening another. During this time I can move my mouse outside the window, but clicking Yes locks it back in the Cursor Lock window while clicking No unlocks the cursor. Creating a shortcut, as above, achieves nothing as the hotkey does not trigger cursor locking after running the shortcut.

    1. I haven’t used the program in some time so I’ll have to do some testing myself and report back.

    2. So I gave it a test again and I didn't have any issues. I followed the instructions above and set the hotkey and then clicked the window I wanted to keep the cursor within then activated cursor lock by pressing the hotkey. Make sure the window that you want to restrict your cursor in is on top.