Mouse Module

From SolarStrike wiki
Revision as of 18:26, 3 June 2014 by Elverion (talk | contribs) (Created page with "Most mouse functions will expect a virtual key code. Use the Key Module for getting the proper VK. == pressed == '''boolean mouse.pressed(number vk)''' Returns true if ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Most mouse functions will expect a virtual key code. Use the Key Module for getting the proper VK.


pressed

boolean mouse.pressed(number vk)

Returns true if the given mouse button was pressed in this logic cycle. It does not continually return true when a button is held down, only once when it is initially pressed.


released

boolean mouse.released(number vk)

Returns true if the given mouse button was released in this logic cycle. It does not continually return true when a button not held down, only once when it is initially released.


isDown

boolean mouse.isDown(number vk)

Returns true if the given mouse button is held down. This will continue to return true as long as the button is held down.


press

mouse.press(number vk)

Attempts to send a synthetic press for the given button. If async is true (default), it is queued for automatic release. Otherwise, execution is blocked while waiting for release.

This will send the input to whichever window has input focus at the time.


hold

mouse.hold(number vk)

Attempts to send a synthetic hold for the given button. As there is no automatically-paired release, the async flag is not accepted in this function.

This will send the input to whichever window has input focus at the time.


release

mouse.release(number vk)

Attempts to send a synthetic release for the given button. You should typically use mouse.hold() on the button first to give it something to release.

This will send the input to whichever window has input focus at the time.


move

mouse.move(number x, number y)

Attempts to move (not set to a position) the physical mouse cursor. 'dx' and 'dy' are the amount to move in pixels in the x and y axis, respectively.


wheelMove

mouse.wheelMove(number delta)

Attempts to move the physical mouse wheel. 'delta' specified the amount to move; 120 = 1 wheel click. If 'delta' is positive, moves the wheel up (away from user). If 'delta' is negative, moves the wheel down (towards user).


setPosition

mouse.setPosition(number x, number y)

Attempts to set the physical mouse wheel to the given coordinates. 'x' and 'y' are specified in pixels.

NOTE: Microsoft, in their infinite wisdom, decided to use some goofy, brain-dead system for this and we lose accuracy when normalizing the screen coordinates. As a result, the actual cursor may be 1 or 2 pixels off our target.


getPosition

number x, number y mouse.getPosition()

Returns the position of the physical mouse cursor, in pixels.


getConsolePosition

number x, number y mouse.getConsolePosition()

Returns the position of the physical mouse cursor in console characters.

NOTE: This returns the position inside the window, not globally. Therefor, if the mouse is to the left or above the console window, you can receive negative numbers.


virtualPress

mouse.virtualPress(number hwnd, number vk[, boolean async])

Attempts to send a synthetic press for the given button, and sends that input directly to the given window. If async is true (default), it is queued for automatic release. Otherwise, execution is blocked while waiting for release.

The position that the mouse is "clicked" is wherever the virtual mouse is positioned to (use mouse.virtualMove()).

As virtual functions send the input directly to the specified window's input queue, this can be used to control windows that are in the background without interrupting the user.


virtualHold

mouse.virtualHold(number hwnd, number vk)

Attempts to send a synthetic hold for the given button, and sends that input directly to the given window.

The position that the button is held is wherever the virtual mouse is positioned to (use mouse.virtualMove() or mouse.setVirtualPosition()).


virtualRelease

mouse.virtualRelease(number hwnd, number vk)

Attempts to send a synthetic release for the given button, and sends that input directly to the given window.

The position that the button is release is wherever the virtual mouse is positioned to (use mouse.virtualMove() or mouse.setVirtualPosition()).


virtualMove

mouse.virtualMove(number dx, number dy)

Moves the virtual mouse cursor by dx, dy. This does not affect the physical mouse cursor. See mouse.move() for more details. Note that this does not accept the window; it only temporarily holds a position to be used later but does not actually send any input.


virtualWheelMove

mouse.virtualWheelMove(number hwnd, number delta)

Moves the virtual mouse wheel by 'delta'. See mouse.wheelMove() for more details.


setVirtualPosition

mouse.setVirtualPosition(number x, number y)

Sets the virtual mouse cursor to x, y. This does not affect the physical mouse cursor. See mouse.setPosition() for more details.


getVirtualPosition

number x, number y mouse.getVirtualPosition()

Returns the position of the virtual mouse cursor. See mouse.getPosition() for more details.