I have found following:
/*
AutoHotkey Version: 1.x
Language: English
Platform: WinXP
Title: Laptop Mouse Monitor
Author: Wesley Treat, www.wesleytreat.com
Date: May 2006
Script Function:
If a USB mouse is plugged into the laptop, optimize the pointer speed and
precision settings for the mouse. If it's not, optimize the settings
for 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 = 10
MouseSpeed = 12
; Enhance Pointer Precision
PadEnhance = 1
MouseEnhance = 0
; Precision Thresholds
PadThreshold1 = 6
PadThreshold2 = 10
MouseThreshold1 = 0
MouseThreshold2 = 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.cpl
MouseIconGroup = 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 = Mouse
PadName = 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%5D
SPI_GETMOUSE = 0x0003
SPI_SETMOUSE = 0x0004
SPI_GETMOUSESPEED = 0x0070
SPI_SETMOUSESPEED = 0x0071
; Watch for hardware changes
OnMessage(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)
Return
It 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.