Switch mouse DPI with keyboard?
Switch mouse DPI with keyboard?
Hey, I need a script that would let me to switch mouse DPI with keyboard. I do have a mouse that can switch DPI by own key, but I want to be able to do it with keyboard. Is it possible? Mouse is Logitech G203 and it's using Logitech Gaming Software(not SetPoint).
Re: Switch mouse DPI with keyboard?
Little bump, got way behind without answer. I've seen many scripts being posted here but I would like it know if there's anything for changing DPI directly, not windows mouse sensitivity or using workaround like great "evilC's" script.
Re: Switch mouse DPI with keyboard?
No, to my knowledge this is not technically feasible.
To which of my scripts are you referring? The demo on the MouseDelta thread can only add DPI when the script is activated, however I have a new script which can effectively subtract DPI
To which of my scripts are you referring? The demo on the MouseDelta thread can only add DPI when the script is activated, however I have a new script which can effectively subtract DPI
Re: Switch mouse DPI with keyboard?
Yeah I was talking about mousedelta. This is the problem, top is delta, middle is delta in sniper mode and bottom is same mouse with DPI switch. From left to right DPI400/800/1200/1600.
Re: Switch mouse DPI with keyboard?
I would be really interested to see the results of a similar test with the C# version of MouseDelta, I think it may be a fair bit better.
Re: Switch mouse DPI with keyboard?
I got problems with launching it, CLR library missing.
Re: Switch mouse DPI with keyboard?
See the comment in the first post:
evilC wrote:FOR ALL DEMOS IN THIS THREAD:
The SharpDX DLLs from SharpDX.zip in this post are required for the demos in all posts in this thread
You will need CLR.ahk from here
For each demo, extract the SharpDX DLLs from this post, plus the MouseDelta zip for that post into the same folder
Re: Switch mouse DPI with keyboard?
Yes, it doesn't work this way. CLR.ahk doesn't launch, MouseDelta.ahk drops CLR error. Also even if it would launch, not sure how to change DPI.
Re: Switch mouse DPI with keyboard?
You are not meant to launch CLR.ahk, it is an include for the script.
You want this demo, and you want to play around with this function in that script:
ie something like the following should halve the sensitivity of your mouse:
You want this demo, and you want to play around with this function in that script:
Code: Select all
MoveEvent(x, y, mouseId){
Global mdw
if (mdw.SelectedMouse == 0 || mdw.SelectedMouse == mouseId){
DllCall("mouse_event",uint,1,int, x ,int, y,uint,0,int,0)
}
}
Code: Select all
MoveEvent(x, y, mouseId){
x := round(x / 2)
y := round(y / 2)
Global mdw
if (mdw.SelectedMouse == 0 || mdw.SelectedMouse == mouseId){
DllCall("mouse_event",uint,1,int, x ,int, y,uint,0,int,0)
}
}
Re: Switch mouse DPI with keyboard?
I'm not sure what I am doing wrong, but it throws me error: "0x2002000E invalid number of paramaters", "specifically SubsribeWheel" in current state:
; ================= USER SCRIPT ================
#SingleInstance force
#NoEnv
#include CLR.ahk
OnExit, UnhookAndClose
GoSub, Hook
Gui, Add, Text, , Select Mouse:
mdw := new MouseDeltaWrapper("x+5 yp-3 w200")
mdw.SubscribeMove(Func("MoveEvent"))
mdw.SubscribeWheel(Func("WheelEvent"))
Gui, Show
return
^Esc::
UnhookAndClose:
GuiClose:
GoSub, UnHook
ExitApp
Hook:
hHookMouse := SetWindowsHookEx(WH_MOUSE_LL := 14, RegisterCallback("MouseMove", "Fast"))
return
UnHook:
UnhookWindowsHookEx(hHookMouse)
return
MoveEvent(x, y, mouseId){
x := round(x / 2)
y := round(y / 2)
Global mdw
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)
}
}
}
MouseMove(nCode, wParam, lParam)
{
Critical
SetFormat, Integer, D
If !nCode && (wParam = 0x200){
; Mouse movement - process
if (NumGet(lParam+0, 12, "int")){
; if the LLMHF_INJECTED flag is set, this is "injected" input (Came from mouse_event)
; Let this input through
Return CallNextHookEx(nCode, wParam, lParam)
} else {
; Block the input
Return 1
}
} else {
; Other mouse message - let through
Return CallNextHookEx(nCode, wParam, lParam)
}
}
SetWindowsHookEx(idHook, pfn)
{
;Return DllCall("SetWindowsHookEx", "int", idHook, "Uint", pfn, "Uint", DllCall("GetModuleHandle", "Uint", 0), "Uint", 0)
return DllCall("SetWindowsHookEx", "int", idHook, "Uint", pfn, "Uint", 0, "Uint", 0)
}
UnhookWindowsHookEx(hHook)
{
Return DllCall("UnhookWindowsHookEx", "Uint", hHook)
}
CallNextHookEx(nCode, wParam, lParam, hHook = 0)
{
Return DllCall("CallNextHookEx", "Uint", hHook, "int", nCode, "Uint", wParam, "Uint", lParam)
}
Re: Switch mouse DPI with keyboard?
This is the error.
Re: Switch mouse DPI with keyboard?
Hmm, will look into this and let you know.
Can you not disable the wheel code for now? All we really need to know is whether you get smoother movement with this technique...
Can you not disable the wheel code for now? All we really need to know is whether you get smoother movement with this technique...
Re: Switch mouse DPI with keyboard?
Grr, there is defo something wrong still with some of the attachments on that thread.
The Multi-Mouse version of MouseDelta.dll is still trying to load version 4..0.0.0 of SharpDX
Gimme a min, will see if I can sort it the hell out.
The Multi-Mouse version of MouseDelta.dll is still trying to load version 4..0.0.0 of SharpDX
Gimme a min, will see if I can sort it the hell out.
Re: Switch mouse DPI with keyboard?
Fixed it.
To be 100% clear - you want MouseDelta-MultiMouse.zip from this post
Plus SharpDX.zip from the first post.
Plus CLR.ahk
To be 100% clear - you want MouseDelta-MultiMouse.zip from this post
Plus SharpDX.zip from the first post.
Plus CLR.ahk
Re: Switch mouse DPI with keyboard?
Thanks, no errors anymore but mouse sensitivity ain't changing, tried user and admin modes.
; ================= 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
GuiClose:
ExitApp
MoveEvent(x, y, mouseId){
x := round(x / 4)
y := round(y / 4)
Global mdw
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)
}
}
}
Re: Switch mouse DPI with keyboard?
That's the wrong code - there is no hook in that code.
You need the script from this post
You need the script from this post
Re: Switch mouse DPI with keyboard?
Tested now and it works good. But I can only do 1/2 mouse speed
Also some toggle/hold button would be good. I guess for this extra script would be needed that would just enable/disable current one?
Anything higher like 3,4 causes mouse to move in squares.x := round(x / 2)
y := round(y / 2)
Also some toggle/hold button would be good. I guess for this extra script would be needed that would just enable/disable current one?
Re: Switch mouse DPI with keyboard?
Nah, we can just add toggle functionality to the script, it's easy.
The likely reason why it does not work properly with higher values is that the majority of the values coming from the mouse will be low values. If dividing by 4, then if the mouse reports a move of 1,2,3 or 4 then it will be converted to 1.
You wanna set the DPI as high as possible, then turn down the sensitivity in the game. That way, it gives it more to work with.
To allow turning it on / off via a toggle, add this code:
Then adjust your MouseMove func like so:
The likely reason why it does not work properly with higher values is that the majority of the values coming from the mouse will be low values. If dividing by 4, then if the mouse reports a move of 1,2,3 or 4 then it will be converted to 1.
You wanna set the DPI as high as possible, then turn down the sensitivity in the game. That way, it gives it more to work with.
To allow turning it on / off via a toggle, add this code:
Code: Select all
F1::
toggle := !toggle
return
Code: Select all
MoveEvent(x, y, mouseId){
Global mdw
Global toggle
if (toggle){
x := round(x / 4)
y := round(y / 4)
}
if (mdw.SelectedMouse == 0 || mdw.SelectedMouse == mouseId){
DllCall("mouse_event",uint,1,int, x ,int, y,uint,0,int,0)
}
}
Re: Switch mouse DPI with keyboard?
For a "hold for DPI shift", you could use this instead:
Code: Select all
F1::
toggle := 1
return
F1 up::
toggle := 0
return
Who is online
Users browsing this forum: slishnevsky, yabab33299 and 127 guests