AutoHotkey Community

It is currently May 26th, 2012, 2:04 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: December 9th, 2006, 8:07 pm 
I'll try to keep this brief.

Basically I need to adjust my mouse sensitivity for a certain game (not open source). I figured I'd try adjusting the Windows mouse sensitivity to compensate.

I did some hunting, and I went ahead and made a script that successfully changes the registry key "mousesensitivity" under the current user and then sends WM_SETTINGCHANGE.

The problem is that while the registry is updated (I see an hourglass pointer very briefly when it broadcasts), my mouse doesn't move any faster.

Now, I know I'm modifying the correct setting because I adjusted it using the control panel and refreshed RegEdit, and sure enough there it is: mousesensitivity value changes.

20 is the value I had set (the fastest Windows would allow through the control panel), and I was trying to set it to 60. I figured maybe 60 was out of bounds and just wasn't accepted (even though the key changed), so I tried changing it to 10. Well, again, the value changed, but the mouse movement didn't.

Maybe I'm missing something... or maybe I'm going about it the wrong way. Any ideas?

Thanks in advance, especially to Chris and the other very helpful guys here.

==============

highsensitivity := 10

;RegRead, normalsensitivity, HKEY_CURRENT_USER, Control Panel\Mouse, MouseSensitivity
normalsensitivity := 20

^!h::
RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Mouse, MouseSensitivity, %highsensitivity%
SendMessage, 0x1A,,,, ahk_id 0xFFFF ; 0x1A is WM_SETTINGCHANGE

return

^!n::
RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Mouse, MouseSensitivity, %normalsensitivity%
SendMessage, 0x1A,,,, ahk_id 0xFFFF ; 0x1A is WM_SETTINGCHANGE
return
==============


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2006, 9:02 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Esoteria wrote:
Maybe I'm missing something... or maybe I'm going about it the wrong way. Any ideas?


Some of these programmatic overrides we do to our system settings will not be effected until we log-off & log-in again. Sometimes, the nature of such a system-wide change might require a reboot too. User32.dll provides us a very useful function SystemParametersInfo() which we can use for such requirements.


This is what you need: Adjusting Mouse Sensitivity via hotkey
Code:
^!h::DllCall("SystemParametersInfo", Int,113, Int,0, UInt,10, Int,2)
^!n::DllCall("SystemParametersInfo", Int,113, Int,0, UInt,20, Int,2)


113 is SPI_SETMOUSESPEED
10 & 20 are values that indicate speed. ( Range: 1 to 20 )

Refer MSDN: SystemParametersInfo

Hope that makes you happy! :D

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2006, 11:33 pm 
Wow. Very wow. Fast reply and more clear than I could possibly have asked for. Even a link to more info on system parameters! You rock tremendously.

And it definitely works. The only problem is that it doesn't affect my mouse speed in the full screen application. I would normally pass this off as "Oh dang, the game doesn't let me change it in game. It's not in the source code, so there's no real way to do it except by switching out drivers" or something like that. The strange thing, though, is that it works normally on other machines. Now, I have the sensitivity at maximum here on the laptop, so maybe this program and other similar ones defaults to a certain sensitivity and ignores the Windows settings (actually, that would seem obvious at this point). In that case the question is why is my _default_ mouse sensitivity so low on this mouse/laptop combination, and... the real question...

...is there any way to up the mouse sensitivity beyond the threshold (perhaps by going to a lower level)?

Very helpful already, and thanks again.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 26th, 2006, 11:34 pm 
Offline

Joined: December 26th, 2006, 6:52 pm
Posts: 13
Location: Paris, France
Something to share on the subject with a simple script to toggle between low and user sensitivity:

Code:
; Autohotkey script "Toggle Mouse sensitivity"
;=================================================================================
SlowMouseSpeed      := 1
NormalMouseSpeed    := true ; State of Mouse pointer speed
UserMouseSpeed      := 0    ; Speed sensed before slow down
MouseThreshold1     := 6
MouseThreshold2     := 10
MouseEnhance        := 1

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

;=================================================================================
*F17::   toggleMouseSpeed()

;=================================================================================
toggleMouseSpeed() {
    global
    ; SET LOW SPEED
    if( NormalMouseSpeed )
    {
        ; SENSE BEFORE
        DllCall("SystemParametersInfo", UInt,SPI_GETMOUSESPEED, UInt,0, UIntP,prevSpeed, UInt,0)

        ; Temporarily reduces the mouse cursor's speed.
        ; Retrieve the current speed so that it can be restored later
        DllCall("SystemParametersInfo", UInt,SPI_GETMOUSESPEED, UInt,0, UIntP,UserMouseSpeed, UInt,0)
        ; Slow down mouse speed
        DllCall("SystemParametersInfo", UInt,SPI_SETMOUSESPEED, UInt,0, UInt,SlowMouseSpeed, UInt,0)

        ; SENSE AFTER
        DllCall("SystemParametersInfo", UInt,SPI_GETMOUSESPEED, UInt,0, UIntP,currentSpeed, UInt,0)
        ToolTip, Mouse slow: %currentSpeed%/20

        ; REMEMBER CURRENT STATE
        NormalMouseSpeed := false
    }
    ; RESTORE SPEED
    else {
        ; SENSE BEFORE
        DllCall("SystemParametersInfo", UInt,SPI_GETMOUSESPEED, UInt,0, UIntP,prevSpeed, UInt,0)

        ; Restore the original speed.
        DllCall("SystemParametersInfo", UInt, SPI_SETMOUSESPEED, UInt,0, UInt,UserMouseSpeed, UInt,0)

        ; Restore the original speed acceleration thresholds and speed
        VarSetCapacity(MySet, 32, 0)
        InsertInteger(MouseThreshold1, MySet, 0)
        InsertInteger(MouseThreshold2, MySet, 4)
        InsertInteger(MouseEnhance   , MySet, 8)
        DllCall("SystemParametersInfo", UInt,SPI_SETMOUSE, UInt,0, Str,MySet, UInt,1)

        ; SENSE AFTER
        DllCall("SystemParametersInfo", UInt,SPI_GETMOUSESPEED, UInt,0, UIntP,currentSpeed, UInt,0)
        ToolTip, Mouse restored: %currentSpeed%/20

        ; REMEMBER CURRENT STATE
        NormalMouseSpeed := true
    }
    SetTimer, RemoveToolTip, 1000
}
;=================================================================================
InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4) {
    ; Copy each byte in the integer into the structure as raw binary data.
    Loop %pSize%
    DllCall("RtlFillMemory", "UInt",&pDest + pOffset + A_Index-1, "UInt", 1, "UChar", pInteger >> 8*(A_Index-1) & 0xFF)
}
;=================================================================================
RemoveToolTip:
SetTimer, RemoveToolTip, Off
ToolTip
return

;=================================================================================



Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 27th, 2006, 11:09 am 
Offline

Joined: November 27th, 2006, 7:41 am
Posts: 222
Location: Queensland, Australia
You might also consider looking into "USB sample rate"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 27th, 2006, 10:42 pm 
Offline

Joined: December 26th, 2006, 6:52 pm
Posts: 13
Location: Paris, France
BETLOG wrote:
You might also consider looking into "USB sample rate"

This benchmark talks about this and it appears that results may depend on mouse technology. Anyway, this article is really worth reading!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 28th, 2006, 8:30 am 
Offline

Joined: November 27th, 2006, 7:41 am
Posts: 222
Location: Queensland, Australia
There are quite a few articles on this, just be aware that if you use some of them, even just the mouse analysis drivers, it's possible they can mess up your core OS mouse driver.... as i suspect happened to mine a while back, resuulting in a lot of double clicking when i only clicked once.
Completely removing the USB mouse device and it's driver, and reinstalling it and it's software wseems to have fixed it, but exercise a bit of caution.
Expect to need to reinstall mouse stuff.
(So learn how to navigate your OS without a mouse, or have a spare PS2 one on hand)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 28th, 2006, 9:00 am 
Offline

Joined: November 27th, 2006, 7:41 am
Posts: 222
Location: Queensland, Australia
I found this interface least painful for easily changing the driver and sampling rate:
http://files.filefront.com/usbmrs11exe/ ... einfo.html


MouseRateChecker is handy for a simple chekc of your mouse sampling rates:
http://tscherwitschke.de/mouseratechecker.html

..and MiceJudge shows a good graph so you can see how 'lossy' your mouse hardware is. (and is possibly what screwed up my drivers)
http://www.a4tech.com/en/micejudge-en.asp
Image

Before you change anything, check how much CPU you currently use by starting taskmanager (ctrl-shift-esc) and set :
view -> update speed -> high
then move your mouse around like crazy for a few seconds to see what kind of CPU impact there is.
Repeat for comparison after increasing USB sampling rates.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 14th, 2008, 1:25 pm 
Thanks ivanw your code worked great for me.


Report this post
Top
  
Reply with quote  
 Post subject: Super Sensitive
PostPosted: January 13th, 2009, 9:29 am 
Offline

Joined: October 30th, 2008, 10:13 pm
Posts: 27
is there a way to increase the sensitivity beyond 20?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Super Sensitive
PostPosted: January 12th, 2011, 2:49 am 
hi, first answer is simple:
Code:
3::DllCall("SystemParametersInfo", Int,113, Int,0, UInt,10, Int,1)
2::DllCall("SystemParametersInfo", Int,113, Int,0, UInt,3, Int,1)


but second (that long code)... i dont think its good idea.

smaller code is better (for me). it sould be very fast for changing sensitive in real time (in rush with sniper gun, there is no time for pauses).

the problem is about not working first program INGAME. in desktop - ok, in game menu - ok, but in game that program does nothing (only blocks binded keys ^^).

if anyone know "simple" solution, that could help all fpp games community.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 12th, 2011, 3:52 am 
Offline

Joined: April 4th, 2009, 9:20 pm
Posts: 5
przemo,

I've been using a bit of code that I found and modified (not really understanding it). It looks mostly like yours, and it works, but can you explain the difference between the "int" and the "uint"?

My code:
Code:
DllCall("SystemParametersInfo", UInt,113, UInt,0, UInt,10, UInt,0)


Your code:
Code:
3::DllCall("SystemParametersInfo", Int,113, Int,0, UInt,10, Int,1)


And what about the "Uint,0" at the end of mine, as compared to the "Int,1" at the end of yours?

Thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2011, 1:57 am 
"And what about the "Uint,0" at the end of mine, as compared to the "Int,1" at the end of yours? "
its a very good question :). i dont understand it too (just copy, paste and hope it works ^^), but "uint" doesnt work in my enviroment.

i used first answer in that topic (short with two lines of code). that longer version doesnt work (64 bit xp pro).


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 11th, 2011, 4:29 am 
uint stands for unsigned integer, where int stands for integer. If you're working with values between 0 and 20, it shouldn't make a difference.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 12th, 2012, 8:59 pm 
Ben Hill wrote:
przemo,

I've been using a bit of code that I found and modified (not really understanding it). It looks mostly like yours, and it works, but can you explain the difference between the "int" and the "uint"?

My code:
Code:
DllCall("SystemParametersInfo", UInt,113, UInt,0, UInt,10, UInt,0)


Your code:
Code:
3::DllCall("SystemParametersInfo", Int,113, Int,0, UInt,10, Int,1)


And what about the "Uint,0" at the end of mine, as compared to the "Int,1" at the end of yours?

Thanks


That 1 vs. 0 makes a lot of difference.

Go to: http://msdn.microsoft.com/en-us/library ... 85%29.aspx and find fWinIni [in] section.


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Exabot [Bot], poserpro, Tilter_of_Windmills and 9 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group