Jump to content

Recommended Posts

Posted (edited)

Looking at changing mouse speed in C/++

This code  however does not work, meaning the new speed is not set.

unsigned int speed = 2;
void *pvoid;
pvoid = &speed;

SystemParametersInfo(SPI_SETMOUSESPEED,
    0,
    pvoid,
    SPIF_SENDCHANGE);

That is short code, the return from SystemParametersInfo is 1.

The autoit code works fine.

#Include <WinAPI.au3>

$SPI_SETMOUSESPEED = 113
$SPIF_SENDCHANGE = 2

$Speed = 2 

_WinAPI_SystemParametersInfo($SPI_SETMOUSESPEED, 0, $Speed, $SPIF_SENDCHANGE)

I've tried using int * instead of void * and a number of other alterations.

I'm a little confused, can anyone see my error?

EDIT:

Just so you don't have to go looking if you're interested.

Here is winapi function

; #FUNCTION# ====================================================================================================================
; Name...........: _WinAPI_SystemParametersInfo
; Description ...: Retrieves or sets the value of one of the system-wide parameters
; Syntax.........: _WinAPI_SystemParametersInfo($iAction[, $iParam = 0[, $vParam = 0[, $iWinIni = 0]]])
; Parameters ....: $iAction     - The system-wide parameter to be retrieved or set
;                  $iParam      - A parameter whose usage and format depends on the parameter being queried or set
;                  $vParam      - A parameter whose usage and format depends on the parameter being queried or set
;                  $iWinIni      - If a system parameter is being set, specifies whether the user profile is to be  updated,  and
;                  +if so, whether the $WM_SETTINGCHANGE message is to be broadcast. This parameter can be zero if you don't want
;                  +to update the user profile or it can be one or more of the following values:
;                  |$SPIF_UPDATEINIFILE - Writes the new setting to the user profile
;                  |$SPIF_SENDCHANGE    - Broadcasts the $WM_SETTINGCHANGE message after updating the user profile
; Return values .: Success      - True
;                  Failure      - False
; Author ........: Paul Campbell (PaulIA)
; Modified.......: jpm
; Remarks .......:
; Related .......:
; Link ..........: @@MsdnLink@@ SystemParametersInfo
; Example .......:
; ===============================================================================================================================
Func _WinAPI_SystemParametersInfo($iAction, $iParam = 0, $vParam = 0, $iWinIni = 0)
    Local $aResult = DllCall("user32.dll", "bool", "SystemParametersInfoW", "uint", $iAction, "uint", $iParam, "ptr", $vParam, "uint", $iWinIni)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0]
EndFunc   ;==>_WinAPI_SystemParametersInfo 

and msdn link

http://msdn.microsoft.com/en-us/library/windows/desktop/ms724947%28v=vs.85%29.aspx

EDIT2:

never mind, solved.

unsigned int speed = 2;
//void *pvoid;
//pvoid = &speed;

SystemParametersInfo(SPI_SETMOUSESPEED,
    0,
    (void*)speed,
    SPIF_SENDCHANGE);
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...