开发者

Make a mouse pointer do a hyper-jump?

I run a dual monitor setup.

To get from monitor 1 to 2 (or vice-versa) requires lots of unnecessary mouse movement.

My thought was to leverage a extra mouse button (I have two) and have the mouse hyper-jump (apologies to Star T开发者_StackOverflowrek) from the XY coordinates on monitor 1 to the same XY coordinates on monitor 2.

How would I go about doing this?

Could it be done via C#?


Regarding to coordinates, the two monitors are glued together as one big area.

Using the Screen.AllScreens array you can inspect the working areas of both screens, and by setting Cursor.Position you can move the mouse around.


To do this in C#, I would set a system wide hot key. Then as deltreme says, use Cursor.Position to move the cursor where you want when that hotkey is pressed.

Another route you could take would be to use a language such as AutoHotkey, or AutoIt.

Here's an example script in AutoIt to make the cursor jump to a screen to the left of the main monitor:

HotKeySet("{F6}", "Jump")

While True
WEnd

Func Jump()
    MouseMove(-500, 500, 0)
EndFunc


You will need to set a WH_MOUSE_LL mouse hook with SetWindowsHookEx() so that you can monitor the mouse messages regardless of which program has the focus. Sample C# code is available here. Extend the MouseMessages declaration to add the messages generated for your extra mouse messages. The middle button down message is 0x207, X-button is 0x20b. You may have to experiment a bit to see what message is actually generated for your mouse.

From there, simply jump the cursor by assigning the Cursor.Position property. The Screen class gives you the location of the screens. Don't buy a 3rd monitor.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜