hello i tried to make one simple mouse movement to move from my current position (relative to my pos) 500 pixels to the left in 300 miliseconds
i tried in many ways and havent succeded. SADFACE
i tried, with:
Sendmode Event
MouseMove 0,0,0,r
this one moves not linear, starts slow and increases speed and writing 100 speed is still so fast for what i need, and i cannot reach one specific point in a certain number of miliseconds(the time is important),
also a function i found with the DLL line DllCall("User32.dll\SendInput", "UInt", 1, "UPtr", &INPUT, "Int", Size, "UInt") , there were some things i didnt understand.
, I just need to move at a certain speed(linear, same from start to end) for a period of time.
Will be really appreciated if someone can give me a hand.
MouseMove a certain distance in 300 ms Topic is solved
-
- Posts: 1472
- Joined: 05 May 2018, 12:23
Re: MouseMove a certain distance in 300 ms
Code: Select all
y::
MouseGetPos, posx,posy,,,
startpos := posx
starttime := A_TickCount
posx-=500
MouseMove, %posx%,%posy%, 5 ; play with the 5 or put it in some loop,
MouseGetPos, posx,posy,,,
MsgBox, % "I moved " abs(startpos - posx) " pixels in " Abs(starttime - A_TickCount) " ms."
return
Re: MouseMove a certain distance in 300 ms Topic is solved
Hallo,
try:
try:
Code: Select all
T := -A_TickCount
Loop, 10
Sleep, 1
Global Granularity:= (T+A_TickCount)/10
Return
q::
T := -A_TickCount
MouseMoveRelative(500,0,300)
ToolTip,% "Time: " T+A_TickCount " ms"
Return
MouseMoveRelative(Rx:=0,Ry:=0,Time:=0)
{
CoordMode, Mouse ,Screen
MouseGetPos, x, y
Loop,% No:=Max(Time//Granularity,1)
{
DllCall("SetCursorPos","int",x+=Rx/No,"int",y+=Ry/No)
Sleep, Granularity
}
}
Re: MouseMove a certain distance in 300 ms
Here is another one.
It's perhaps a bit complicated to follow, but it is highly adjustable and accurate.
It's perhaps a bit complicated to follow, but it is highly adjustable and accurate.
Code: Select all
#SingleInstance, Force
SetBatchLines, -1
;#Include <HB_Vector>
return
*ESC::ExitApp
*Numpad1::
STime := A_TickCount
CoordMode, Mouse , Screen
Count := 0
MouseGetPos, x, y
Distance := 500
Time := 300
Frames := 55
CurrentPos := New HB_Vector( x , y )
EndPos := New HB_Vector( x-Distance , y )
Dist := CurrentPos.Dist(EndPos)
ACC := New HB_Vector( 0 , 0 )
Loop, % Frames {
ACC.X := EndPos.X , ACC.Y := EndPos.Y
ACC.Sub(CurrentPos)
ACC.SetMag( ( Distance / Frames ) )
CurrentPos.Add(ACC)
DllCall("SetCursorPos", "int", CurrentPos.X, "int", CurrentPos.Y )
if( ( A_Index * ( Time / Frames ) ) > ( A_TickCount - STime ) )
sleep, ( A_Index * ( Time / Frames ) ) - ( A_TickCount - STime )
count++
}
DllCall("SetCursorPos", "int", EndPos.X, "int", EndPos.Y )
ToolTip,% "Time: " ( A_TickCount - STime ) " ms`nNumber Of Moves: " Count
return
Class HB_Vector {
__New(x:=0,y:=0){
This.X:=x
This.Y:=y
}
Add(Other_HB_Vector){
This.X+=Other_HB_Vector.X
This.Y+=Other_HB_Vector.Y
}
Sub(Other_HB_Vector){
This.X-=Other_HB_Vector.X
This.Y-=Other_HB_Vector.Y
}
mag(){
return Sqrt(This.X*This.X + This.Y*This.Y)
}
magsq(){
return This.Mag()**2
}
setMag(in1){
m:=This.Mag()
This.X := This.X * in1/m
This.Y := This.Y * in1/m
return This
}
mult(in1,in2:="",in3:="",in4:="",in5:=""){
if(IsObject(in1)&&in2=""){
This.X*=In1.X
This.Y*=In1.Y
}else if(!IsObject(In1)&&In2=""){
This.X*=In1
This.Y*=In1
}else if(!IsObject(In1)&&IsObject(In2)){
This.X*=In1*In2.X
This.Y*=In1*In2.Y
}else if(IsObject(In1)&&IsObject(In2)){
This.X*=In1.X*In2.X
This.Y*=In1.Y*In2.Y
}
}
div(in1,in2:="",in3:="",in4:="",in5:=""){
if(IsObject(in1)&&in2=""){
This.X/=In1.X
This.Y/=In1.Y
}else if(!IsObject(In1)&&In2=""){
This.X/=In1
This.Y/=In1
}else if(!IsObject(In1)&&IsObject(In2)){
This.X/=In1/In2.X
This.Y/=In1/In2.Y
}else if(IsObject(In1)&&IsObject(In2)){
This.X/=In1.X/In2.X
This.Y/=In1.Y/In2.Y
}
}
dist(in1){
return Sqrt(((This.X-In1.X)**2) + ((This.Y-In1.Y)**2))
}
dot(in1){
return (This.X*in1.X)+(This.Y*In1.Y)
}
cross(in1){
return This.X*In1.Y-This.Y*In1.X
}
Norm(){
m:=This.Mag()
This.X/=m
This.Y/=m
}
}
Re: MouseMove a certain distance in 300 ms
for the moment the second one is the one working fine, it still loses the distance sometimes it turns in my character different, not always same rotation. but now i understood how you used the time.
I wanted to thank you guys for your help.
I wanted to thank you guys for your help.
Who is online
Users browsing this forum: Draken, Google [Bot] and 284 guests