Jump to content

Mouse Accelerator


Markus
 Share

Recommended Posts

As bad old vista isn't able too make the mouse movement speed independent of my touchpad movement speed I had to write that little script.

Hotkeys:

Ctrl + arrow up = faster

Ctrl + arrow down = slower

Ctrl + q = exit

Ctrl + o = on/off

Thus i can easily accelerate my touchpad movement speed without changing it every time in the system control. And there are some funny effects for exampe if you slow it down till -1 you have an inverted mouse movement.

Global $FAKTOR = 2
Global $on = 1
HotKeySet("^q", "quit")
HotKeySet("^{DOWN}", "down")
HotKeySet("^{UP}", "up")
HotKeySet("^o", "on")
$oldpos = MouseGetPos()

While 1
    Sleep(25)
    ToolTip("Mouse Acceleration: " & $FAKTOR, 0, 0)
    If $on Then
        $pos = MouseGetPos()
        $xdif = $pos[0] - $oldpos[0]
        $ydif = $pos[1] - $oldpos[1]
        MouseMove($oldpos[0] + $FAKTOR * $xdif, $oldpos[1] + $FAKTOR * $ydif, 0)
        $pos = MouseGetPos()
        $oldpos = $pos
    EndIf
WEnd
Func quit()
    Exit
EndFunc  ;==>quit
Func down()
    $FAKTOR -= 0.1
EndFunc  ;==>down
Func up()
    $FAKTOR += 0.1
EndFunc  ;==>up
Func on()
    If $on Then
        $on = 0
    Else
        $on = 1
    EndIf
EndFunc  ;==>on

"It's easier to disintegrate an atom than a prejudice." (A.Einstein)---------------------------------------------------------------------------My C++ - tools:Tidy tool-->indents your c++ sourceCleanscript --> cleans autoit-code before compiling (co-author: peethebee)My tools:GUIBuilder-->build your window and get the source; german versionMy Games:OnlineGameCenter-->Online Chess and Connect4 with a rtf-chatSnake-->including a level editor to build your own levelsTetris-->the well known game, big funOther things:Tower of Hanoi-->perfect riddler with graphic output

Link to comment
Share on other sites

Hmm, I can't test this becuase I am at school, but does this actually work? Looks like it would only work when moving the mouse up.. Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Link to comment
Share on other sites

Hmm, I can't test this becuase I am at school, but does this actually work? Looks like it would only work when moving the mouse up..

Yes it actually works :)

the calculation of the movement that has been done is independent of the direction.

"It's easier to disintegrate an atom than a prejudice." (A.Einstein)---------------------------------------------------------------------------My C++ - tools:Tidy tool-->indents your c++ sourceCleanscript --> cleans autoit-code before compiling (co-author: peethebee)My tools:GUIBuilder-->build your window and get the source; german versionMy Games:OnlineGameCenter-->Online Chess and Connect4 with a rtf-chatSnake-->including a level editor to build your own levelsTetris-->the well known game, big funOther things:Tower of Hanoi-->perfect riddler with graphic output

Link to comment
Share on other sites

Nice! I like the idea :)

I made a small(?) UDF from that, using CallBacks and timer:

#include <GuiConstantsEx.au3>
#include <Constants.au3>
#include <EditConstants.au3>
#include <MouseAcceleration_UDF.au3>
;

#NoTrayIcon

_MouseSetAcceleration(10)

HotKeySet("^q", "_QuitApp")
HotKeySet("^o", "_OnOffAcceleration")
HotKeySet("^{Up}", "_FactorUp")
HotKeySet("^{Down}", "_FactorDown")

;===== Tray Items Creation Part =====
Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode", 1)

TraySetClick(16)

$EnableAcceleration_TrayItem = TrayCreateItem("Enable Acceleration  (CTRL + O)")
TrayItemSetOnEvent(-1, "_MainTrayEvents")
TrayItemSetState(-1, $GUI_CHECKED)

TrayCreateItem("")

$ShowGUI_TrayItem = TrayCreateItem("Show Main Window")
TrayItemSetOnEvent(-1, "_MainTrayEvents")
TrayItemSetState(-1, $TRAY_DEFAULT)

$Exit_TrayItem = TrayCreateItem(">> Exit << (CTRL + Q)")
TrayItemSetOnEvent(-1, "_MainTrayEvents")

TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "_MainTrayEvents")
;===== Tray Creation Part =====

;===== GUI Creation Part =====
$hGUI = GUICreate("_MouseSetAcceleration - Demo", 300, 200)

GUISetIcon("main.cpl", 0)

$EnableAcceleration_CheckBox = GUICtrlCreateCheckbox("Enable Acceleration", 20, 10)
GUICtrlSetState(-1, $GUI_CHECKED)

GUICtrlCreateLabel( _
                    "CTRL + Q       = Exit the program" & @LF & _
                    "CTRL + O       = On / Off Acceleration" & @LF & _
                    "CTRL + UP      = Increese Acceleration" & @LF & _
                    "CTRL + DOWN        = Decreese Acceleration", _
                    20, 50, 260, 50)
GUICtrlSetColor(-1, 0x0000FF)

GUICtrlCreateLabel("Set Mouse Acceleration:", 20, 120)

$Factor_Input = GUICtrlCreateInput($iMOUSE_ACCEL_FACTOR, 20, 140, 110, 20, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $ES_READONLY))
$Set_UpDown = GUICtrlCreateUpdown($Factor_Input)

$Close_Button = GUICtrlCreateButton(">> Exit <<", 20, 170, 60, 20)

GUISetState()
;===== GUI Creation Part =====

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $Close_Button
            _QuitApp()
        Case $GUI_EVENT_MINIMIZE
            GUISetState(@SW_HIDE)
            TraySetIcon("main.cpl", 0)
            TraySetState(1)
        Case $EnableAcceleration_CheckBox
            _OnOffAcceleration()
        Case $Set_UpDown
            If Number(GUICtrlRead($Factor_Input)) > $iMOUSE_ACCEL_FACTOR Then
                _FactorUp()
            Else
                _FactorDown()
            EndIf
    EndSwitch
WEnd

Func _MainTrayEvents()
    Switch @TRAY_ID
        Case $Exit_TrayItem
            _QuitApp()
        Case $EnableAcceleration_TrayItem
            _OnOffAcceleration()
        Case $TRAY_EVENT_PRIMARYDOUBLE, $ShowGUI_TrayItem
            TraySetState(2)
            GUISetState(@SW_SHOW)
            GUISetState(@SW_RESTORE)
    EndSwitch
EndFunc

Func _OnOffAcceleration()
    If $hCallBack = 0 Then
        _MouseSetAcceleration(10)
        GUICtrlSetState($EnableAcceleration_CheckBox, $GUI_CHECKED)
        TrayItemSetState($EnableAcceleration_TrayItem, $TRAY_CHECKED)
    Else
        _MouseSetAcceleration(0)
        GUICtrlSetState($EnableAcceleration_CheckBox, $GUI_UNCHECKED)
        TrayItemSetState($EnableAcceleration_TrayItem, $TRAY_UNCHECKED)
    EndIf
EndFunc

Func _FactorUp()
    $iMOUSE_ACCEL_FACTOR += 0.1
    
    ;Strage bug :(
    If StringLen($iMOUSE_ACCEL_FACTOR) > 4 Then $iMOUSE_ACCEL_FACTOR = Round($iMOUSE_ACCEL_FACTOR, 2)
    
    GUICtrlSetData($Factor_Input, $iMOUSE_ACCEL_FACTOR)
EndFunc

Func _FactorDown()
    $iMOUSE_ACCEL_FACTOR -= 0.1
    
    ;Strage bug :(
    If $iMOUSE_ACCEL_FACTOR > 0 Or StringLen($iMOUSE_ACCEL_FACTOR) > 4 Then $iMOUSE_ACCEL_FACTOR = Round($iMOUSE_ACCEL_FACTOR, 2)
    
    GUICtrlSetData($Factor_Input, $iMOUSE_ACCEL_FACTOR)
EndFunc

Func _QuitApp()
    _MouseSetAcceleration(0)
    Exit
EndFunc

The UDF itself and this example attachment:

_MouseAcceleration_UDF.zip

With Tray Minimization option: _MouseAcceleration_UDF.zip

Edit: Added option minimize to System Tray.

Edited by MrCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

  • 2 weeks later...

wow thanks i was wondering if i could make my mouse go faster than windows allows a while ago i donwnloaded this and it actually works i like my mouse to move very fast, its a pain because i dont think windows allows you to move it enough, im using an acceleration speed of 3 its great

thanks

F@T3oYCG

Interpreters have great power!Although they live in the shadow of compiled programming languages an interpreter can do anything that a compiled language can do, you just have to code it right.

Link to comment
Share on other sites

lol my screen is only small im only allowed 9.09999999999998

autoit is cool its like a mix of all of the languages that i know, but it helps me to make more advanced stuff with its capabilities, or it will eventually.

the best thing i have made is an edited version of a volume bar display / adjuster which is great but not going to get me very far, i hope to learn the autoit syntax quite quick, i have only been doing it for about 3 hours lol

Interpreters have great power!Although they live in the shadow of compiled programming languages an interpreter can do anything that a compiled language can do, you just have to code it right.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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