DLLCall("mouse_event"): How do I use continous values?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
pigy33
Posts: 11
Joined: 15 Dec 2016, 00:34

DLLCall("mouse_event"): How do I use continous values?

19 Feb 2018, 21:02

I've been working on a script that utilizes the DLLCall("mouse_event")

here is an example:
DllCall("mouse_event", uint, 1, int, 0, "UInt", 2, uint, 0, int, 0)
Sleep, 2

but the problem is I want to do more precise mouse movements ex: 2.5 down in the y direction but considering the value is an integer I can't do that. Also I can't change the sleep time because I made my program in a stupid way that would make me have to redo a lot of it if I were to change it.

So is there anyway to turn these integer values into a decimal type of value? Or another way to do these types of mouse movements in games?

If so then it would really save me a lot of time, thanks!
User avatar
tomoe_uehara
Posts: 213
Joined: 05 Oct 2013, 12:37
Contact:

Re: DLLCall("mouse_event"): How do I use continous values?

19 Feb 2018, 21:35

I'm afraid you can't use a float value because it's stated on the MSDN page that it only accepts integer value.
However, if you want to refine your mouse movement, you can try to change your mouse's DPI.
You can refer to this topic
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: DLLCall("mouse_event"): How do I use continous values?

20 Feb 2018, 09:50

There are absolutely no windows settings which alter the behaviour of the mouse in mouse-aim games.
Windows "Sensitivity" is utterly unrelated, that is to do with mouse cursor.
The ONLY thing that will alter it is changing the DPI setting in the software that came with your mouse. If your mouse did not come with any software, then it is technically impossible to move a fraction of a unit.
Secondly, Sleep 2 IS NOT sleeping for 2ms. Minimum granularity of sleep on a windows system is 10-15ms.

If you are sending a move of 1 @ 10ms and it is twice as much movement as you want, you have 3 options:
1) Halve the sensitivity setting IN GAME (NOT in windows)
2) Double the amount of time you wait between sending updates (ie sleep 20 instead of sleep 10).
This will result in less smooth movement.
3) Halve the DPI setting in the mouse's software (if it exists)

BTW, if you really do want to send moves at a faster rate than 10ms, you need a more accurate timing system such as QPX, or my MicroTimer library
pigy33
Posts: 11
Joined: 15 Dec 2016, 00:34

Re: DLLCall("mouse_event"): How do I use continous values?

02 Mar 2018, 00:25

evilC wrote: BTW, if you really do want to send moves at a faster rate than 10ms, you need a more accurate timing system such as QPX, or my MicroTimer library
Sorry to keep asking you for help but I tried using your MicroTimer example in the same folder I downloaded MicroTimer in and I couldn't get it to work.

I modified your script to move down 1 unit every 1ms:

Code: Select all

#SingleInstance force
#NoEnv

#include CLR.ahk
/*
Demo Script for MicroTimer

Converts Arrow Keys to mouse cursor, with 1ms move time for the mouse
*/

#SingleInstance force

dllfile := "MicroTimer.dll"

if (!FileExist(dllfile)){
	MsgBox DLL Not found
	ExitApp
}
asm := CLR_LoadLibrary(dllfile)
; Use CLR to instantiate a class from within the DLL
mt := asm.CreateInstance("MicroTimer")

YState := 0
YTimer := mt.Create(Func("MoveY"), 1)
return

MoveY(){
	global YState
	DllCall("user32.dll\mouse_event", "UInt", 0x0001, "UInt", 0, "UInt", YState, "UInt", 0, "UPtr", 0)
}

YEvent(evt){
	global YState, YTimer
	YState := evt
	YTimer.SetState(abs(YState))
}

~LButton::
	YEvent(1)
	return
	
^Esc::
	ExitApp
but like the example, I couldn't get the code to work
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: DLLCall("mouse_event"): How do I use continous values?

02 Mar 2018, 05:53

Did youever get MicroTimer to do anything?
I have seen issues before where there is some problem loading the DLL or something, but you get no errors, it just does not work.
Would advise trying to get the example MT scripts to run, just to make sure the MT dll is loading for you.
pigy33
Posts: 11
Joined: 15 Dec 2016, 00:34

Re: DLLCall("mouse_event"): How do I use continous values?

02 Mar 2018, 13:24

evilC wrote:Did youever get MicroTimer to do anything?
I have seen issues before where there is some problem loading the DLL or something, but you get no errors, it just does not work.
Would advise trying to get the example MT scripts to run, just to make sure the MT dll is loading for you.
I guess it just does not work because I tried running the example script and I get no errors but it doesn't work. Is there any fixes for it or should I try the other method?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: haomingchen1998, mikeyww and 239 guests