Few Questions: Attach, Mouse

Discuss, ask for help, share ideas, give suggestions, read tutorials, and tell us about bugs you have found with MicroMacro in here.

Do not post RoM-Bot stuff here. There is a subforum for that.
Forum rules
This is a sub-forum for things specific to MicroMacro.

This is not the place to ask questions about the RoM bot, which uses MicroMacro. There is a difference.
Post Reply
Message
Author
Zero
Posts: 2
Joined: Mon Dec 19, 2011 3:33 pm

Few Questions: Attach, Mouse

#1 Post by Zero » Mon Dec 19, 2011 3:51 pm

I've been developing a script for a recent sci-fi mmo; I haven't programmed with mm/lua in a few years (since rombot was first released), so my memory is foggy on a few things:

1) Is there any lag between the script and issuing the command to an attached window? Ie. If you loop 1000 times and each time the mouse moves a pixel, is this infinitely small (ie. 0) or is there some sort of lag (ie. 10ms)?

2) mouseSet - when using absolute coordinates, is this absolute from the edge of the game window or absolute from the edge of the desktop?

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Few Questions: Attach, Mouse

#2 Post by Administrator » Mon Dec 19, 2011 9:23 pm

There will be some delay, but it will be small. There is no way around it, and has nothing to do with the language or software being used, but it is just a limitation of how computers work.

mouseSet should accept screen coordinates in attached mode. It will automatically convert them to client coordinates internally.

Zero
Posts: 2
Joined: Mon Dec 19, 2011 3:33 pm

Re: Few Questions: Attach, Mouse

#3 Post by Zero » Tue Dec 20, 2011 2:02 pm

Few more if you don't mind:

1) mouseMove doesn't appear to work correctly, it has some error when moving.
Example:
function main()
mouseSet(0,200);
for x=0,50 do
mouseMove(1,0);
rest(10);
xx,yy=mouseGetPos();
print(x..": "..xx..","..yy);
end
end
startMacro(main);

Returns something like
1: 0,200
..
9: 10,200
..
50: 59,200

It should be xx exactly equals x, but it seems as it somehow is rounding the pixel value up or something?


2) Attaching and MouseSet/Move: I've noticed that even when attached, the mouseset/move affects the mouse outside of the program. Does this mean the program that mm is attaching to doesn't work with mm? Even if the attach is successful, how can I make it such that only the mouse moves/sets/whatever is registered within the program and not the desktop?


Thanks

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Few Questions: Attach, Mouse

#4 Post by Administrator » Tue Dec 20, 2011 3:06 pm

Code: Select all

mouseMove doesn't appear to work correctly, it has some error when moving.
I suppose in part it is due to rounding problems (not sure how much I can do about this with how the Windows API is, but I'll look into it). I'm guessing the main problem is due to Windows itself. It may or may not be receiving and processing the messages fast enough. The events are probably still in queue while the OS is processing other, more important things, causing some latency between updates.

That code you have shown isn't using attached input. You aren't attaching to anything, so it is going to move the physical mouse cursor. The 'virtual mouse' that MicroMacro uses doesn't actually move anything; it only keeps track of coordinates and uses those only when passing events to the attached process.

Additionally, mouseGetPos() returns the coordinates of the actual mouse cursor, not the virtual mouse. I suppose that could be changed, but then that would add complications if you want to actually get the real mouse position in attached mode.

For accuracy and control reasons, it is better to use mouseSet() than mouseMove(). The only time you would really want to use mouseMove() is if the game is looking for movement events instead of the mouse position. I know it seems strange at first because, visually, they seem almost the same, however, they do send (slightly) different event IDs. You could accomplish what you are doing like so:

Code: Select all

function main()
	attach( findWindow("SomeGame*") );

	mouseSet(1, 200);
	for j = 0,50 do
		mouseSet(1 + j, 200);
		rest(10);
	end
end
startMacro(main, true);

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests