Jump to content

Golf With Your Friends

Golf with accuracy!
Read more...

Bunker Punks

Sensitivity for this game has to be set in the registry.
Read more...

Quantum League

Added hipfire and zoom sensitivity. Use config file for best accuracy.
Read more...

Revulsion

Added with X and Y sensitivity.
Read more...

Zeal

Added, good luck finding a game!
Read more...
BobTheBuilder12

Program used to move mouse a set distance?

Recommended Posts

Hi mate!

To emulate mouse movement I mainly use Logitech's scripting through their G-series LUA API. This can be used with any Logitech G series mouse or keyboard with G-keys. The script can be something like this:

if (event == "G_PRESSED" and arg == 1) and GetMKeyState() == 1 then
	for i = 0, 799 do
		MoveMouseRelative(10,0)
		Sleep(10)
	end
end

This will make the G1 button on the keyboard execute the code when also the M1 button is selected.

The script will send 800 (0-799) packets to the operating system with a 10 ms delay between each. And each packet tells the OS to move the mouse 10 counts on the X+ axis (to the right). So in totalt the mouse will move 8000 counts to to right.

I also use a Teensy USB board which can emulate a mouse. This is doing the exact same thing with a slightly different scripting language, but this device is emulating the mouse movement exactly like mouse hardware before sending it through the USB port, while the Logitech solution emulates it in software on the computer. In some cases using the Teensy might be advantageous because it fires less processes on the computer.

In most cases though, using the Logitech solution works perfectly fine.

I also have a machine that physically moves the mouse with 0.1 mm accuracy that I use to test equipment and verify that the theory matches the fact.

Share this post


Link to post
Share on other sites
19 hours ago, DPI Wizard said:

Hi mate!

To emulate mouse movement I mainly use Logitech's scripting through their G-series LUA API. This can be used with any Logitech G series mouse or keyboard with G-keys. The script can be something like this:


if (event == "G_PRESSED" and arg == 1) and GetMKeyState() == 1 then
	for i = 0, 799 do
		MoveMouseRelative(10,0)
		Sleep(10)
	end
end

This will make the G1 button on the keyboard execute the code when also the M1 button is selected.

The script will send 800 (0-799) packets to the operating system with a 10 ms delay between each. And each packet tells the OS to move the mouse 10 counts on the X+ axis (to the right). So in totalt the mouse will move 8000 keyboard, to to right.

I also use a Teensy USB board which can emulate a mouse. This is doing the exact same thing with a slightly different scripting language, but this device is emulating the mouse movement exactly like mouse hardware before sending it through the USB port, while the Logitech solution emulates it in software on the computer. In some cases using the Teensy might be advantageous because it fires less processes on the computer.

In most cases though, using the Logitech solution works perfectly fine.

I also have a machine that physically moves the mouse with 0.1 mm accuracy that I use to test equipment and verify that the theory matches the fact.

5

I try the script, nothing move

I try to change a key by changing 

arg == 1 

to the number of the G key,  still nothing work

can u explain why, please :) btw i don't have Logitech keyboard, I have G600 mouse

this is what is the code

if (event == "G_PRESSED" and arg == 11) and GetMKeyState() == 1 then

 

Edited by Sngop

Share this post


Link to post
Share on other sites

Sorry, that was just the code snippet, and not the entire script :)

For keyboards this is the entire script:

function OnEvent(event, arg)
	if (event == "G_PRESSED" and arg == 1) and GetMKeyState() == 1 then
		for i = 0, 99 do
			MoveMouseRelative(10,0)
			Sleep(10)
		end
	end
end

And for a mouse, use this (assigning to button 5):

function OnEvent(event, arg)
	if (event == "MOUSE_BUTTON_PRESSED" and arg == 5) then
		for i = 0, 99 do
			MoveMouseRelative(10,0)
			Sleep(10)
		end
	end
end

The G keys on the mouse are targeted like this, and not with the G_PRESSED syntax.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...