ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Coding Snacks

mouse speed switcher

(1/1)

czb:
Hi,
what I really would like to have is a tiny program which would stay in tray and after clicking on it, it would change speed of mouse (so that I can switch between usb mouse and touchpad). Two predefined speeds of mouse would be fine. Also ability to assign some key to it would be great. Is that possible with autohotkey? If so, just tell me pls the function which changes mouse speed and I will code it by myself. There exists already mouseswitcher, but it is paid.
Thanks for any ideas ;)

czb:
I have found:
http://www.autohotkey.com/forum/viewtopic.php?t=5605
So I will play a little with it and see :up:

mouser:
nice idea.  :up:

czb:
I have found following:

--- Code: AutoIt ---/*AutoHotkey Version: 1.xLanguage:   EnglishPlatform:   WinXP Title:      Laptop Mouse MonitorAuthor:      Wesley Treat, www.wesleytreat.comDate:      May 2006 Script Function:If a USB mouse is plugged into the laptop, optimize the pointer speed andprecision settings for the mouse. If it's not, optimize the settingsfor the touch pad. Monitor for changes in mouse's presence.*/  ; ============================================================; CONFIGURATION; ============================================================ ; ------------------------------------------------------------; USER POINTER SETTINGS ; Mouse ID; Check HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Mouclass\Enum; to determine the ID of your mouse. This should be the value of the key that; appears and disappears when you plug in and unplug your mouse. You can; probably just use "HID." MouseID = HID  ; Pointer Speed (1-20)PadSpeed = 10MouseSpeed = 12 ; Enhance Pointer PrecisionPadEnhance = 1MouseEnhance = 0 ; Precision ThresholdsPadThreshold1 = 6PadThreshold2 = 10MouseThreshold1 = 0MouseThreshold2 = 0 ; For details on precision and threshold settings, see; http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceui40/html/cerefSystemParametersInfo.asp; under SPI_SETMOUSE. By default, thresholds 1 and 2 are "6" and "10" respectively.  ; Use a tray icon?TrayIcon = 1 ; Tray Icons; If you want the tray icon to reflect the current settings, enter a valid; PadIcon and PadIconGroup. To use the only standard AutoHotkey icon, comment; out all the icon locations. MouseIcon = %A_WinDir%\system32\main.cplMouseIconGroup = 1 ; The likely location of the Alps Touch Pad icon.; PadIcon = %ProgramFiles%\Apoint\Apoint.exe; PadIconGroup = 1 ; The likely location of the Synaptics Touch Pad icon.; PadIcon = %ProgramFiles%\Synaptics\SynTP\SynTPEnh.exe; PadIconGroup = 1  ; If you like, you can change the names for your devices. These names are; reflected in the tooltips.MouseName = MousePadName = Touch Pad ; ------------------------------------------------------------; SCRIPT SETTINGS - YOU SHOULDN'T NEED TO CHANGE ANYTHING BELOW THIS LINE. If !TrayIcon   Menu, Tray, NoIcon ; Constants; Read more at the following:; http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/systemparametersinfo.asp; http://www.pinvoke.net/search.aspx?search=SPI&namespace=%5BAll%5DSPI_GETMOUSE =      0x0003SPI_SETMOUSE =      0x0004SPI_GETMOUSESPEED =   0x0070SPI_SETMOUSESPEED =   0x0071 ; Watch for hardware changesOnMessage(0x219, "HardwareUpdate") ; Check whether or not the mouse exists to begin with and make sure the pointer; settings match.   Gosub, MouseCheck   Gosub, ChangeSettings   If !MousePresent and !FileExist(PadIcon) and FileExist(MouseIcon)      Menu, Tray, Icon, %MouseIcon%, %MouseIconGroup%   MouseLast = %MousePresent%   ToolTip, Pointer Settings Set To: %CurrentName%   Sleep, 2000   ToolTip   Return  Exit ; Everything above this line is run when the script is loaded.  ; ============================================================; FUNCTIONS & SUBROUTINES; ============================================================ HardwareUpdate(){   Global MouseLast   Global MousePresent   Global CurrentName   Gosub, MouseCheck   ; We might get phantom hardware-change messages, so make sure the status   ; of the mouse has actually changed before changing any settings.   If MousePresent = %MouseLast%      Exit   Else   {      Gosub, ChangeSettings      MouseLast = %MousePresent%   ; Update mouse status.      ToolTip, Pointer Settings Changed To: %CurrentName%      Sleep, 2000      ToolTip   }   Return} MouseCheck:   MousePresent = 0   Sleep, 1000   ; Give the registry a moment to update.   Loop, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Services\Mouclass\Enum, 0, 0   {      RegRead, CurrentValue      IfInString, CurrentValue, %MouseID%      {         MousePresent = 1         Break   ; Don't check any more values.      }   }   Return ChangeSettings:   If MousePresent   {      CurrentName = %MouseName%      DeviceSpeed = %MouseSpeed%      DeviceEnhance = %MouseEnhance%      DeviceThreshold1 = %MouseThreshold1%      DeviceThreshold2 = %MouseThreshold2%      If TrayIcon and FileExist(MouseIcon)         Menu, Tray, Icon, %MouseIcon%, %MouseIconGroup%      Menu, Tray, Tip, Current Pointer Settings: %CurrentName%   }   Else   {      CurrentName = %PadName%      DeviceSpeed = %PadSpeed%      DeviceEnhance = %PadEnhance%      DeviceThreshold1 = %PadThreshold1%      DeviceThreshold2 = %PadThreshold2%      If TrayIcon and FileExist(PadIcon)         Menu, Tray, Icon, %PadIcon%, %PadIconGroup%      Menu, Tray, Tip, Current Pointer Settings: %CurrentName%   }    VarSetCapacity(DeviceArray, 12, 0)   InsertInteger(DeviceThreshold1, DeviceArray, 0)   ; Reg. Value MouseThreshold1   InsertInteger(DeviceThreshold2, DeviceArray, 4)   ; Reg. Value MouseThreshold2   InsertInteger(DeviceEnhance, DeviceArray, 8)      ; Reg. Value MouseSpeed    InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4)   ; The caller must ensure that pDest has sufficient capacity.  To preserve any existing contents in pDest,   ; only pSize number of bytes starting at pOffset are altered in it.   {      Loop %pSize%  ; Copy each byte in the integer into the structure as raw binary data.         DllCall("RtlFillMemory", "UInt", &pDest + pOffset + A_Index-1, "UInt", 1, "UChar", pInteger >> 8*(A_Index-1) & 0xFF)   }    ; Keep this here for future reference.   ; DllCall("SystemParametersInfo", UInt, SPI_GETMOUSESPEED, UInt, 0, UIntP, SpeedCurrent, UInt, 0)    ; Change the pointer speed.   DllCall("SystemParametersInfo", UInt, SPI_SETMOUSESPEED, UInt, 0, UInt, DeviceSpeed, UInt, 1)   ; Change the pointer precision settings.   DllCall("SystemParametersInfo", UInt, SPI_SETMOUSE, UInt, 0, Str, DeviceArray, UInt, 1)   ReturnIt changes mouse/touchpad setting according to if USB mouse is present or not. It would be even better if anyone could add option to switch mouse/touchpad manualy through program menu. Unfortunately I do not know autohotkey to do it by myself.

lanux128:
czechboy, would this script (or the original one) be helpful with this problem i'm having here?

Navigation

[0] Message Index

Go to full version