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

26
2013-08
  • tehDorf

    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?

  • Answers
  • tehDorf

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

    CenterCursor.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 "C:\PathToScript\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.

  • Brian

    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

  • quickcel

    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

  • Patrick S.

    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))
    
  • iglvzx

    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. :)


    Download: CenterMouse.exe, 784KB, ahk.igalvez.net

  • Amazed

    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.

  • mjrider

    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

  • mmdemirbas

    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
    

  • Related Question

    windows 7 - Microsoft mouse side buttons (on the left and right) don't work in win7-64
  • Matt

    Microsoft mouse side buttons (on the left and right) don't work in win7-64

    I have installed Intellipoint and mapped the buttons to specific actions. They don't work in most applications and I'm thinking it may have something to do with WoW64.

    Can anyone confirm they are experiencing similar issues and if they fixed it, how?


  • Related Answers
  • o.k.w

    I just installed for my Notebook Optical Mouse 3000 on Win7-64 and it works.

    I assume you installed the Intellipoint 7 64-bit version from here?

    Also check that the mouse/pointer properties in the control panel.