Hey guys,

First post here. This community looks create.

I'm working on a final school project and we must move the cursor to a designated position without the use of:

mouse_event()
SetCursorPos()

we then need to perform a check to say if the position is correct with the numbers we were given.

I am completely stumped. I've been googling for hours and this project is due monday :(.

Thanks Guys,

Jeff Pody

Dani AI

Generated

Short summary and realistic options for (Windows XP): the professor has banned the usual user-mode injection APIs (the ones and others mentioned), so there are two practical routes left — do a visual, in-process cursor (easy, safe) or inject at a lower level (hard, risky). Posting a fake cursor overlay is what most students use when SetCursorPos/mouse_event/SendInput are off-limits; writing a kernel/driver or virtual-HID to inject real hardware events is possible but far beyond a quick project.

How an overlay approach works (recommended for a school deadline):

  • Hide the system cursor for your app, create a topmost, transparent, click-through window that covers the screen, and draw your own cursor sprite at screen coordinates you control.
  • Move that sprite from A to B (linear interpolation or easing) when the key is pressed, and compare its screen coordinates to the target numbers to determine a hit.
  • Use a global hotkey or a keyboard hook to catch the designated key. Make sure you use the same coordinate space (screen coordinates) for both the target and your overlay.
    Example startup pattern (conceptual C++):
    ShowCursor(FALSE);
    HWND overlay = CreateWindowEx(WS_EX_LAYERED|WS_EX_TRANSPARENT, "MyClass", NULL,
      WS_POPUP, 0,0,screenW,screenH, NULL, NULL, hInst, NULL);
    SetWindowPos(overlay, HWND_TOPMOST, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE|SWP_SHOWWINDOW);
    SetLayeredWindowAttributes(overlay, COLORKEY, 0, LWA_COLORKEY);

    Draw the sprite in WM_PAINT and update its position on a timer for smooth motion.

If the professor insists on moving the real OS cursor: the only reliable ways are driver-level (mouse filter driver or virtual HID) or allowed input-injection APIs. Both require admin rights, WDK/driver work, and are not recommended for a last-minute assignment. Ask the instructor whether a visual overlay that demonstrably moves to the numeric target will satisfy the spec — it meets the stated goal without unsafe system changes.

Troubleshooting tips: be explicit about screen vs client coordinates, test on single- and multi-monitor setups, and log coordinates while debugging so you can show the professor exact values used.

Recommended Answers

All 12 Replies

jeffpro,

Welcome to DaniWeb!

SetCursorPos() seems reasonable, too bad you can't use it! Which operating system are you using? That is definitely going to dictate how you need to go about this.

Dave

Ya I know right :(

Windows XP.

Thanks for prompt response!

Well you can use SendInput() but it kinda works the same way as mouse_event() so may be considered cheating.

Yea, sendinput is not allowed professor said.

I don't understand what he is expecting you to do, then? Make a little 2D treadmill for a mouse with a ball that you control to physically move the cursor??

I don't understand what he is expecting you to do, then? Make a little 2D treadmill for a mouse with a ball that you control to physically move the cursor??

Lol! Maybe he happens to know something atrociously tedious which sane people do NOT prefer to use & is trying to leave a mark on his students of his "superiority".
jeffpro, kindly ask him what's his "way" of over-complicating a simple task & if in the end it turns out to be insanely moronic act of complete ignorance, kindly ask him to punch himself in the face to knock some sane sense into him. Period.
P.S. Is he by any chance the descendant of Rube Goldberg?

Hey, sorry I was away from PC for a period of time.

No we need to move the cursor from point A to point B which the use of those functions :(

You want the mouse just to appear somewhere or do you want it to magically move across the screen?

We place cursor on point a

Press designated key and must hit point b

Any ideas?

bump :( please guys 1 week left

To me it's unclear what the program actually is about precisely, but would ClipCursor() be accepted?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.