Switch mouse DPI with keyboard?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Galvatron
Posts: 16
Joined: 11 Jun 2017, 09:52

Re: Switch mouse DPI with keyboard?

26 Jul 2017, 02:53

Thanks, script works fine. Sadly I am still getting this not-so precise movement like upper row on the picture I've posted.
; ================= USER SCRIPT ================
#SingleInstance force
#NoEnv
#include CLR.ahk

Gui, Add, Text, , Select Mouse:
mdw := new MouseDeltaWrapper("x+5 yp-3 w200")
mdw.SubscribeMove(Func("MoveEvent"))
mdw.SubscribeWheel(Func("WheelEvent"))
Gui, Show
return

F1::
toggle := 1
return

F1 up::
toggle := 0
return

GuiClose:
ExitApp

MoveEvent(x, y, mouseId){
Global mdw
Global toggle
if (toggle){
x := round(x / 2)
y := round(y / 2)
}
if (mdw.SelectedMouse == 0 || mdw.SelectedMouse == mouseId){
DllCall("mouse_event",uint,1,int, x ,int, y,uint,0,int,0)
}
}

WheelEvent(value, mouseId){
ToolTip % "Wheel: " value ", ID: " mouseId
}

; ================= WRAPPER LIBRARY ================
class MouseDeltaWrapper {
SeenMice := {}
SelectedMouse := 0
MoveCallback := 0

__New(guiOptions := "", dllPath := "MouseDelta.dll"){
this.Callback := callback

Gui, +HwndHwnd
this.GuiHwnd := Hwnd

Gui, Add, DDL, % "hwndhDDL " guiOptions, Any||
this.hDDL := hDDL

fn := this._UserSelectedMouse.Bind(this)
GuiControl, +g, % this.hDDL, % fn

asm := CLR_LoadLibrary(dllPath)
md := asm.CreateInstance("MouseDelta")

md.SubscribeRelativeMove(this._MoveEvent.Bind(this))
md.SubscribeWheel(this._WheelEvent.Bind(this))
this.md := md

this._UserSelectedMouse()
}

SubscribeMove(callback){
this.MoveCallback := callback
}

SubscribeWheel(callback){
this.WheelCallback := callback
}

_UserSelectedMouse(){
GuiControlGet, mouseId, , % this.hDDL
this.SelectedMouse := mouseId == "Any" ? 0 : mouseId
if (this.MoveCallback != 0)
this.md.SubscribeRelativeMove(this._MoveEvent.Bind(this), this.SelectedMouse)
if (this.WheelCallback != 0)
this.md.SubscribeWheel(this._WheelEvent.Bind(this), this.SelectedMouse)
}

_AddMouseToDDL(mouseId){
GuiControl, , % this.hDDL, % mouseId
}

_UpdateMice(mouseId){
if (!this.SeenMice.HasKey(mouseId)){
this.SeenMice[mouseId] := 1
this._AddMouseToDDL(mouseId)
}
}

_MoveEvent(x, y, mouseId){
this._UpdateMice(mouseId)
if (this.MoveCallback != 0 && (this.SelectedMouse == 0 || this.SelectedMouse == mouseId)){
this.MoveCallback.Call(x, y, mouseId)
}
}

_WheelEvent(value, mouseId){
this._UpdateMice(mouseId)
if (this.WheelCallback != 0 && (this.SelectedMouse == 0 || this.SelectedMouse == mouseId)){
this.WheelCallback.Call(value, mouseId)
}
}
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], oktavimark and 363 guests