Mapping Mouse Axis Movement to Keyboard Keys (need Help)

Ask gaming related questions (AHK v1.1 and older)
vosined
Posts: 32
Joined: 15 Jun 2017, 02:48

Mapping Mouse Axis Movement to Keyboard Keys (need Help)

31 Jul 2021, 00:09

Hi guys. I am trying to emulate my keyboard keys numpad2, numpad4, numpad6, numpad8 as mouse movement. I've spend long time to search for the code, but still didn't find it. I have the following code, but the mouse arrow is moving very slow:

Code: Select all

SetDefaultMouseSpeed, 0 ; 
numpad2::MouseMove, 0, -1, 100, R ; when you press w, mouse will move up 25 pixels
numpad4::MouseMove, 0, 1, 100, R ; when you press s, mouse will move down 25 pixels
numpad6::MouseMove, -1, 0, 100, R ; when you press a, mouse will move left 25 pixels
numpad8::MouseMove, 1, 0, 100, R ; when you press d, mouse will move right 25 pixels
How can I adjust the movement speed? Someone on the forum suggested the following code, but it is not working:

Code: Select all

sen := 3
numpad2::
loop %sen%
send numpad2
return

numpad4::
loop %sen%
send numpad4
return

numpad6::
loop %sen%
send numpad6
return

numpad8::
loop %sen%
send numpad8
return
Also is it possible to assign keys for numpad1,3,7,9 so they are moving mouse by diagonal?

I really appreciate if somebody can help and post the full correct code here.
vosined
Posts: 32
Joined: 15 Jun 2017, 02:48

Re: Mapping Mouse Axis Movement to Keyboard Keys (need Help)

31 Jul 2021, 05:27

I've read it already, but still confused, I am new to programming. To read and learn it more in depth it would take days just for this little script. Maybe someone already have it and can share with me. Here is one more script that I found:

Code: Select all

ui, 93:+ToolWindow

Sensitivity = 7 ; lower = more sensitive

LCtrl:: ; the left control key is the hotkey

Gui, 93:Show, x-1 y-1 w1 h1 +NoActivate, % (Toggle := !Toggle) 

	? "Mouse to Keys On" : "Mouse to Keys Off"

SetTimer, WatchMouse, % Toggle ? 5 : "off"

MouseGetPos, ox, oy

Keywait, %A_ThisHotkey%

return



WatchMouse:

MouseGetPos, nx, ny

If ( Sensitivity < Abs( nx - ox ) )

{

	Send, % "{blind}" ( nx < ox ? "{Left}" : "{Right}" )

	MouseMove, ox, ny+1-2*(ny > oy), 0

}

If ( Sensitivity < Abs( ny - oy ) )

{

	Send, % "{blind}" ( ny < oy ? "{Up}" : "{Down}" )

	MouseMove, nx+1-2*(nx > ox), oy, 0

}

return



#IfWinExist, Mouse to Keys On

	LButton::z

	MButton::x

	RButton::c

	XButton1::space

	XButton2::LAlt

#IfWinExist
But it gives an error after I run it "Line 93 does not contain a recognized action"
User avatar
boiler
Posts: 16911
Joined: 21 Dec 2014, 02:44

Re: Mapping Mouse Axis Movement to Keyboard Keys (need Help)

31 Jul 2021, 05:33

I don't think you read that error message right. There is no line 93. Line 1 (which contains the number 93) does not contain a recognized action because you left the "G" off the "Gui" command.

I guess I was thinking you would just use that script directly from the script showcase. Doesn't it do what you are looking for without modification?
vosined
Posts: 32
Joined: 15 Jun 2017, 02:48

Re: Mapping Mouse Axis Movement to Keyboard Keys (need Help)

31 Jul 2021, 06:41

Yes, you are right, the script works correct. But the movement of the arrow is very slow and it starts with a delay of 0,5 sec. I tried to decrease the Sensitivity to 1, but doesn't help. I found the script to increase the mouse sensitivity, but it works for mouse directly, not for the script written above. Any suggestions how to make the movement as fast as possible and start right away you push the key without delay?

Tnanks 🙂
User avatar
boiler
Posts: 16911
Joined: 21 Dec 2014, 02:44

Re: Mapping Mouse Axis Movement to Keyboard Keys (need Help)

31 Jul 2021, 06:47

Did you try the script from the script showcase? You said you read it, but I was thinking you would just try it as is.
vosined
Posts: 32
Joined: 15 Jun 2017, 02:48

Re: Mapping Mouse Axis Movement to Keyboard Keys (need Help)

31 Jul 2021, 07:25

Yes I've tried the Showcase script from deguix. Actually I found it before on one of the Threads, but was too scary to change anything in it as it is so huge and complex :oops: .
But it moves the arrow in all directions! So the only thing left is how to increase the speed of the arrow and make it to start without delay. I tried to change this numbers in the script, but nothing happens^

Code: Select all

MouseSpeed = 1
MouseAccelerationSpeed = 1
MouseMaxSpeed = 5
for example I tried:

Code: Select all

MouseSpeed = 15
MouseAccelerationSpeed = 10
MouseMaxSpeed = 500
still very slow movement with a starting lag, actually exactly like in Ease of Access from Microsoft control panel.
Maybe something else can be changed. Down below the script there are also "Speed" mentioned, but don't no anything about it.
vosined
Posts: 32
Joined: 15 Jun 2017, 02:48

Re: Mapping Mouse Axis Movement to Keyboard Keys (need Help)

31 Jul 2021, 08:28

Actually for me would be enough just one key: "Numpad6" emulates the right mouse movement with the fastest speed as possible and without any delay from the start. The rest keys I would figure myself. I would really appreciate if someone can suggest the code.
User avatar
boiler
Posts: 16911
Joined: 21 Dec 2014, 02:44

Re: Mapping Mouse Axis Movement to Keyboard Keys (need Help)

31 Jul 2021, 09:47

Well, in the first script you posted, you have 100 for the speed, which is the slowest instead of 0 which is the fastest, although that doesn't make much of a difference when moving only one pixel at a time. But it does when you make it move more pixels at a time, like 10. That's what this script does, which can be changed by changing the Sens variable, along with correcting the directions, which were messed up.

Code: Select all

Sens := 10
Numpad2::MouseMove, 0, Sens, 0, R
Numpad4::MouseMove, -Sens, 0, 0, R
Numpad6::MouseMove, Sens, 0, 0, R
Numpad8::MouseMove, 0, -Sens, 0, R
vosined
Posts: 32
Joined: 15 Jun 2017, 02:48

Re: Mapping Mouse Axis Movement to Keyboard Keys (need Help)

31 Jul 2021, 21:27

I've tried the code above, but still the same speed as before. Here I recorded the video of it:
https://drive.google.com/file/d/1I5SQ8R3qlai1ZBj0ws9ioHswgkRDtPAf/view?usp=sharing

On the video first I gave an example how my mouse arrow is moving, then after launching the code, I pressed numpad keys and it can be seen how slow the movement is and there is a big lag at the start of the moving. Maybe I am doing something wrong?

Thanks for your support)
User avatar
boiler
Posts: 16911
Joined: 21 Dec 2014, 02:44

Re: Mapping Mouse Axis Movement to Keyboard Keys (need Help)

31 Jul 2021, 21:38

I doubt it’s moving at the same speed as before. It is just a lot slower than when you move your actual mouse, but if you compare them back-to-back, I think you’ll see this one moving quite a bit faster. And to move it even faster, change Sens from 10 to 20 or 50 or whatever. You just won’t have the ability to move it in fine increments.

You should recognize the lag at the start of its moving as the lag you see when typing, such in as Notepad, and you hold down a key for a bit before it starts repeating more quickly.

But I think you should revisit the script by deguix. You say that it's too complex for you to modify, but you shouldn't have to modify it. The ability to change the acceleration and the initial speed are built-in features. Since you say you would need to change it to get it to work the way you want tells me that you didn't try changing it's operating parameters. Did you read the instructions and try changing those things (by pressing the correct keys while it's running, not by changing the code)? It seems to do exactly what you want if you learn how to use it. I learned how to use it in about a minute, and I found it very user-friendly and powerful.
vosined
Posts: 32
Joined: 15 Jun 2017, 02:48

Re: Mapping Mouse Axis Movement to Keyboard Keys (need Help)

01 Aug 2021, 01:05

Yesterday I wrote that this Showcase script was working, but actually it was Windows "Ease to Access utility" was on and I confused it with the Showcase.
The problem with the Showcase is that I don't have Numeric Up, Down, Left, Right on my Razer keyboard. When I try to map this keys to the keyboard, it gives me regular Up, Down, Left, Right keys and not numeric ones.
Clicks and other staff are working fine, but I can't assign this Numeric Movements to the keyboard.

I just recently bought a Razer Keyboard with a D-Stick on side (attached the picture). The reason I bought it is because I don't use the mouse in my right hand and want to emulate the mouse function with this D-Stick. Unfortunately the razer preprogramming does not have this function, that is why I started to look outside for solution. Also as I said above the Razer does not allow to map Numeric Arrows to the keys. The program see it as regular arrows. I also tried Atnsoft to substitute Num *,/,+ etc. for Num Arrows, but it also considers Num Arrows as regular Arrows.

Boiler, thanks for your suggestions!🙂
Attachments
65d7-ab3f-543f-a8ab-690fb07cf1bc.jpg
65d7-ab3f-543f-a8ab-690fb07cf1bc.jpg (70 KiB) Viewed 845 times
vosined
Posts: 32
Joined: 15 Jun 2017, 02:48

Re: Mapping Mouse Axis Movement to Keyboard Keys (need Help)

01 Aug 2021, 01:35

🌞 My Dear friend Boiler! Finally! I replaced in the code all the Numpad Up, Down etc. with NumpadDiv, Mult, Add etc. Increased the speed with the Num8 key and finally it works perfectly like a mouse!

Thanks a lot! 🤗🍂✨

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: Shoobis and 48 guests