Sign in to follow this  

SendInput Mouse Coordinates

This topic is 4747 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm having a problem with SendInput where it doesnt seem to be going to the correct coordinates. I made a primitive algorithm to convert the screen coordinates to the 0-65,535 "normalized absolute coordinates" that Windows takes in the SendInput function, but it doesn't seem to be working. Right now I have mi.dy=y*(65535/768). I think there's something wrong with this, but I can't pin it down.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
here are the methods that i use to work with the two (btw, those coords are called mickey's)

#define MOUSE_MICKEYS   65535
#define TT_X 0
#define TT_Y 1
//--------------------------------------------------------------------------------------------------------

// Returns the screen size in pixels or, optionally,
// in others scalemode styles
void GetScreenRes(DWORD& x, DWORD& y)
{
x = (unsigned long)GetSystemMetrics(SM_CXSCREEN);
y = (unsigned long)GetSystemMetrics(SM_CYSCREEN);
}
//--------------------------------------------------------------------------------------------------------

// Convert//s the mouses coordinate system to
// a pixel position.
DWORD MickeyToPixel(DWORD _mouse,int XORY)
{
DWORD x = 0L,y = 0L;
float t,tmouse,tMickeys;

GetScreenRes(x, y);
if(XORY==0) t = (float)x;
else t = (float)y;

tMickeys = MOUSE_MICKEYS;
tmouse = float(_mouse);

return(DWORD(tmouse / (tMickeys / t)));
}

//--------------------------------------------------------------------------------------------------------

// Converts pixel X coordinates to mickeys
DWORD PixelToMickey(DWORD pix,int XORY)
{
DWORD x = 0L,y = 0L;
float t,tpix,tMickeys;

GetScreenRes(x,y);
tMickeys = MOUSE_MICKEYS;
if(XORY == TT_X)
t = float(x);
else t = float(y);

tpix = float(pix);

return(DWORD)((tMickeys / t) * tpix);
}


pretty easy to adapt and use, hopefully this will work for you, ifnot, id suggest you take a look at your SendInput usage.

Share this post


Link to post
Share on other sites
Quote:
Original post by LlamaFood
Right now I have mi.dy=y*(65535/768). I think there's something wrong with this, but I can't pin it down.

I think you might have better luck with dy = (y * 65535) / 768. (Though of course, you're better off with a GetSystemMetrics() call to determine screen resolution.)

Share this post


Link to post
Share on other sites

This topic is 4747 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

Sign in to follow this