Is there a Win7 shortcut to position mouse in center of primary screen?

26

6

I have a three monitor set up on Windows 7 and I sometimes lose track of where my cursor is. Is there any Windows shortcut to reset the mouse position? I'm guessing there is not, but might there be a way to set up a simple macro I could bind to a key combination to set my cursor to a default location, such as the center of the primary display?

tehDorf

Posted 2012-01-30T21:17:31.730

Reputation: 697

6I could write you a program that does this when you click - but you would have to find the mouse cursor and move it to the program icon to click. :-( – Dave Becker – 2012-01-30T21:53:46.460

1@DaveBecker, how about a program that does it on execute? Then you can launch it with a shortcut-key. – Hand-E-Food – 2012-01-30T22:05:38.327

1I personally think everyone should turn on the position cursor to the default button. Everyone always looks for the program window first, then thinks about moving the cursor to such. Also I believe everyone should change their cursor scheme to the Extra Large Black cursor, since there is a plague of white/light colored backgrounds. – surfasb – 2012-01-31T06:00:19.250

Answers

28

Combining a few of the above ideas, I came up with this script. It's tested and working.

CentreCursor.ps1

[System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") | out-null
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | out-null
$bounds = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds
$center = $bounds.Location
$center.X += $bounds.Width / 2
$center.Y += $bounds.Height / 2
[System.Windows.Forms.Cursor]::Position = $center

Save this script in a convenient folder, and create a shortcut in your All Programs menu:

Target: %systemroot%\system32\windowspowershell\v1.0\powershell.exe -ExecutionPolicy RemoteSigned -File "C:\Path To Script\CentreCursor.ps1"

Shortcut key: Ctrl + Alt + Shift + C

Run: Minimized

Now whenever you press Ctrl+Alt+Shift+C, your cursor will return home.

Edit: While it doesn't seem to be a requirement on my computer, I've added Patrick's suggestion to the shortcut.

Hand-E-Food

Posted 2012-01-30T21:17:31.730

Reputation: 4 711

FYI, Windows 10 would not accept a path with spaces, and %systemroot% is not set. I had to run the command in the directory with the file, and run it as C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy RemoteSigned .\CenterCursor.ps1 – simpleuser – 2016-03-17T18:57:41.857

@user1663987, to use spaces in the path, put quotes around the command: "C:\My Path\My Command.cmd" – Hand-E-Food – 2016-03-17T23:04:32.797

@Hand-E-Food first thing I tried. Didn't work. Got errors from powershell about missing files because it still split the quoted path into two parts. Reproduced error in a powershell window. – simpleuser – 2016-03-18T00:16:45.243

@Hand-E-Food screen capture at http://i.imgur.com/KNDuFyY.png showing that quotes do not fix the issue

– simpleuser – 2016-03-18T23:39:28.737

@user1663987, I see now. You need the -File switch. I've edited my answer to include this. Thanks! – Hand-E-Food – 2016-03-21T05:27:57.783

This is awesome. I came here by searching for "hot key to move mouse pointer to known location". And if you are somewhat visually challenged -- which is likely if you are here -- and this does not work at first attempt note the two different spellings "CentreCursor.ps1" and "CenterCursor.ps1". – Miserable Variable – 2016-06-17T21:05:16.990

@MiserableVariable Thanks for pointing that out - I've reverted the file name for the first snippit back to the author's original naming so they both match now. – tehDorf – 2016-09-22T17:08:21.553

Before anyone says, "this does not work" you first have to understand "C:\Path To Script\CentreCursor.ps1" is just an example. If your path to the script, contains spaces, you must handle it correctly otherwise it won't work. – Ramhound – 2019-01-16T20:48:27.373

3PowerShell scripts require the execution policy to be changed, if you haven't done so already. You would need to change it permanently or run PowerShell.exe with the "-ExecutionPolicy RemoteSigned" argument. – Patrick Seymour – 2012-01-31T00:28:09.937

@Hand-E-Food You must have changed the execution policy on your machine or something because I was unable to get your answer to work as written. I had to change the target to %systemroot%\system32\windowspowershell\v1.0\powershell.exe -ExecutionPolicy RemoteSigned "C:\PathToScript\CentreCursor.ps1" to get it to work. I re-ordered the arguments, Patrick's command had to come before the file. I've updated your answer to reflect this. – tehDorf – 2012-02-10T22:51:52.737

Oh, yeah. Thank you @Hand-E-Food and everyone else who's answer was combined into this one! – tehDorf – 2012-02-10T23:14:25.510

Glad to help! It taught me something new. (And "centre" is perfectly acceptable spelling outside of the US.) ;-) – Hand-E-Food – 2012-02-11T11:03:44.010

13

Turning on "Show location of pointer when I press the CTRL key" is one option. This is especially useful if it is currently changed to some custom mouse pointer by an application, like a paint brush, that is harder to see.

enter image description here

Brian

Posted 2012-01-30T21:17:31.730

Reputation: 8 439

2Pointer Trails is also very helpful, makes a much bigger target to see when you wiggle the mouse around. – Scott Chamberlain – 2012-01-31T14:40:10.427

8

You can do this fairly easily with a software program called UltraMon.

In the options section there is a place to specify HotKeys. You can see screenshot where I've setup a hot key for Crtl + Shift + C

enter image description here

quickcel

Posted 2012-01-30T21:17:31.730

Reputation: 4 203

Its not FREE, can you share FREE tools too. – YumYumYum – 2015-06-01T06:37:32.507

+1 In my company, there is Ultramon installed on every computer by default, any already many of my coworkers owe you one for this (delivered by me) :) – Pavel – 2015-11-12T12:55:16.257

1Looks good but $40US is a bit much if this is all a user wants to do. – Brian – 2012-01-31T01:22:24.740

7

The following AutoHotkey command sequence will instantly move the mouse to the center of the primary display:

CoordMode, Mouse, Screen
MouseMove, A_ScreenWidth/2, A_ScreenHeight/2, 0

For example, compile the following script:

CoordMode, Mouse, Screen
MouseMove, A_ScreenWidth/2, A_ScreenHeight/2, 0
ExitApp

You can then create a shortcut (.lnk) to it with a shortcut key of your choice. :)

iglvzx

Posted 2012-01-30T21:17:31.730

Reputation: 21 611

3

Here's an AutoIt script to do it. AutoIt can compile its scripts to .exe, which you could then assign a hotkey.

Dim Const $SPI_GETWORKAREA = 0x0030

$rect = DllStructCreate("long left;long top;long right;long bottom")

DllCall("user32.dll", "BOOL", "SystemParametersInfo", "UINT", $SPI_GETWORKAREA, "UINT", 0, "ptr", DllStructGetPtr($rect), "UINT", 0)

Dim $left = DllStructGetData($rect, 1)
Dim $top = DllStructGetData($rect, 2)
Dim $right = DllStructGetData($rect, 3)
Dim $bottom = DllStructGetData($rect, 4)

MouseMove($left + (($right - $left) / 2), $top + (($bottom - $top) / 2))

Patrick Seymour

Posted 2012-01-30T21:17:31.730

Reputation: 7 662

1

Using WMIC and Powershell (both of which should already be installed under Windows 7) this should be doable.

Using WMIC, you can get the screen width and height:

C:\>wmic desktopmonitor get screenheight, screenwidth
ScreenHeight  ScreenWidth
900           1440

and Powershell can set the mouse position (replacing <X> and <Y> with the actual coordinates):

PS C:\>[system.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | out-null
PS C:\>[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point(<X>,<Y>)

So, a little trial and error (and basic math) ought to give you a script which, when run, centers the mouse pointer.

Andrew Lambert

Posted 2012-01-30T21:17:31.730

Reputation: 7 136

1PowerShell scripts require the execution policy to be changed, if you haven't done so already. You would need to change it permanently or run PowerShell.exe with the "-ExecutionPolicy RemoteSigned" argument. – Patrick Seymour – 2012-01-31T00:28:26.257

0

Nircmd by Nir Sofer has the following option..

nircmd setcursor x y

You can create a shortcut to this command line and assign any hotkey to it. There are a lot of other options for mouse cursor as detailed in the nircmd.chm file.

user38660

Posted 2012-01-30T21:17:31.730

Reputation: 1

This is a good method except it seems to be slow(takes about 3 seconds for windows to run it). But doesn't require much else. I had to use elevate shortcut to prevent the windows security popup. – None – 2017-08-05T06:31:04.063

0

Another AutoIt3 program:

<!--  --!>
;;; Define variables according to you
$speed  = 1        ; 0=instantly, 1=fastest, 100=slowest
$delay  = 100      ; milliseconds
$hotkey = "^+!c"   ; ^=Ctrl, +=Shift, !=Alt

;;; Hotkey function
Func GetMyMouse()
    MouseMove(@DesktopWidth / 2, @DesktopHeight / 2, $speed)
EndFunc

;;; Register hotkey
HotKeySet($hotkey, "GetMyMouse")

;;; Program body (busy wait)
While True
    Sleep($delay)
WEnd

mmdemirbas

Posted 2012-01-30T21:17:31.730

Reputation: 359

-1

uhh...I dont think so

but on the issue of finding your mouse you CAN turn on "pointer sonar" so your pointer will be honed into when you press the control key. (currently on a mac but I will try and get screen shots in a moment and edit it in)

regarding macro idea. I guess its plausible...but I dont know of any app that has this already programed, or how to program this myself

mjrider

Posted 2012-01-30T21:17:31.730

Reputation: 529