Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Mouse Acceleration (Enhance Pointer Precision)


  • Please log in to reply
15 replies to this topic
  • Guests
  • Last active:
  • Joined: --
Correcting code from the last post (sorry):

SPI_GETMOUSE      := 0x03
SPI_SETMOUSE      := 0x04
SPI_GETMOUSESPEED := 0x70
SPI_SETMOUSESPEED := 0x71

getMouseSpeed() {
  local curSpeed, result
  if ( result := DllCall("SystemParametersInfo", UInt,SPI_GETMOUSESPEED, UInt,0, UIntP,curSpeed, UInt,0) ) {
  } else {
    MsgBox, DllCall SPI_GETMOUSESPEED Failed - Result: "%Result%"`nErrorLevel: "%ErrorLevel%"`nA_LastError: "%A_LastError%"
  }
  return curSpeed
}

setMouseSpeed(newSpeed) {
  local result
  if ( result := DllCall("SystemParametersInfo", UInt,SPI_SETMOUSESPEED, UInt,0, UInt,newSpeed, UInt,0) ) {
  } else {
    MsgBox, DllCall SPI_SETMOUSESPEED Failed - Result: "%Result%"`nErrorLevel: "%ErrorLevel%"`nA_LastError: "%A_LastError%"
  }
}

getMouseParams(ByRef accelThreshold1, ByRef accelThreshold2, ByRef accelEnabled) {
  local lpParams, result
  VarSetCapacity(lpParams, 3 * 4, 0) ; set capacity to 12 bytes (three 32-bit integers)
  if ( result := DllCall("SystemParametersInfo", UInt,SPI_GETMOUSE, UInt,0, UInt,&lpParams, UInt,0) ) {
    accelThreshold1 := NumGet(lpParams, 0, "UInt")
    accelThreshold2 := NumGet(lpParams, 4, "UInt")
    accelEnabled    := NumGet(lpParams, 8, "UInt") ; accelEnabled is the "Enhance pointer precision" setting
  } else {
    MsgBox, DllCall SPI_GETMOUSE Failed - Result: "%Result%"`nErrorLevel: "%ErrorLevel%"`nA_LastError: "%A_LastError%"
  }
}

setMouseParams(accelThreshold1, accelThreshold2, accelEnabled) {
  local lpParams, result
  VarSetCapacity(lpParams, 3 * 4, 0)
  NumPut(accelThreshold1,      lpParams, 0, "UInt")
  NumPut(accelThreshold2,      lpParams, 4, "UInt")
  NumPut(accelEnabled ? 1 : 0, lpParams, 8, "UInt")
  if ( result := DllCall("SystemParametersInfo", UInt,SPI_SETMOUSE, UInt,0, UInt,&lpParams, UInt,1) ) {
  } else {
    MsgBox, DllCall SPI_SETMOUSE Failed - Result: "%Result%"`nErrorLevel: "%ErrorLevel%"`nA_LastError: "%A_LastError%"
  }
}