Jump to content

Twilight Town: A Cyberpunk FPS

Just added.
Read more...

Contain

See the game notes for instructions on how to disable smoothing.
Read more...

Vomitoreum

Just added.
Read more...

Double Action: Boogaloo

Just added.
Read more...

FOUNDRY

Just added!
Read more...

Program used to move mouse a set distance?


Recommended Posts

  • Wizard

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.

Link to comment
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
Link to comment
  • Wizard

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.

Link to comment
  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...