-
Notifications
You must be signed in to change notification settings - Fork 0
Documentation
This is the documentation on the methods within the MouseOperations
class and the InputOperations
class. Both are static classes, so there's no need to instantiate them to do the cool things.
The formatting of the methods goes like the following: MethodName
( [Paramaters, if there exists any] ) -> [Return type, or void if none]
. If you wish to get more information about a specific method, click on the linked part to see more information.
MouseOperations contains the following data types:
Data Types
- Enum
- MouseEventFlags (bit field)
Move = 0x0001
LeftDown = 0x0002
LeftUp = 0x0004
RightDown = 0x0008
RightUp = 0x0010
MiddleDown = 0x0020
MiddleUp = 0x0040
Absolute = 0x8000
- MouseEventFlags (bit field)
- Struct
- MousePoint
-
X
(int) -
Y
(int)
-
- Color
-
R
(byte) -
G
(byte) -
B
(byte) -
A
(byte)- Note: Win32 always sets this value to 0, so any other value means an error occurred.
-
- MousePoint
MouseOperations contains the following public methods:
Public Methods
-
FindWindowByCaption
( string ) -> IntPtr
-
GetPixelColor
( MouseOperations.MousePoint ) -> MouseOperations.Color
-
GetPixelColor
( IntPtr, MouseOperations.MousePoint ) -> MouseOperations.Color
-
GetPixelColor
( int, int ) -> MouseOperations.Color
-
GetPixelColor
( IntPtr, int, int ) -> MouseOperations.Color
-
SetCursorPosition
( int, int ) -> void
-
SetCursorPosition
( MouseOperations.MousePoint ) -> void
-
GetCursorPosition
() -> MouseOperations.MousePoint
-
MouseEvent
( MouseOperations.MouseEventFlags ) -> void
Finds a window using it's caption.
string caption
: The caption of the Window you need
Returns: A pointer to the window handle you want
Gets the pixel data on screen with the specified coordinate
MouseOperations.MousePoint mousePoint
: The coordinate for the pixel
Returns: The pixel's data at the given coordinate. If outside the clipping region, returns an error value of 0xFFFFFFFF
Gets the pixel data on the given window handle with the specified coordinate
IntPtr hWnd
: A handle to the window whose DC is to be retrieved. If this value is IntPtr.Zero, GetPixelColor is absolute. Otherwise, it is relative to the window.
MouseOperations.MousePoint mousePoint
: The relative coordinate for the pixel, depending on the value of hWnd
Returns: The pixel's data at the given coordinate. If outside the clipping region, returns an error value of 0xFFFFFFFF
Gets the pixel data on screen with the specified coordinate
int x
: The x coordinate of the pixel
int y
: The y coordinate of the pixel
Returns: The pixel's data at the given coordinate. If outside the clipping region, returns an error value of 0xFFFFFFFF
Gets the pixel data on the given window handle with the specified coordinate
IntPtr hWnd
: A handle to the window whose DC is to be retrieved. If this value is IntPtr.Zero, GetPixelColor is absolute. Otherwise, it is relative to the window.
int x
: The relative x coordinate of the pixel, depending on the value of hWnd
int y
: The relative y coordinate of the pixel, depending on the value of hWnd
Returns: The pixel's data at the given coordinate. If outside the clipping region, returns an error value of 0xFFFFFFFF
Sets the user's cursor position to the specified coordinate
int x
: The x coordinate to move the cursor to
int y
: The y coordinate to move the cursor to
Sets the user's cursor position to the specified coordinate
MouseOperations.MousePoint point
: The coordinate to move the cursor to
Gets the user's current cursor position
Returns: The coordinate of the mouse position
Sends the specified mouse input events at the current mouse position
MouseOperations.MouseEventFlags value
: The mouse events that need to be sent. To combine multiple events (e.g. LeftDown + LeftUp), just use bitwise or (|
). For example:
using JMVR;
MouseOperations.MouseEvent( MouseOperations.MouseEventFlags.LeftDown | MouseOperations.MouseEventFlags.LeftUp );
InputOperations contains the following data types:
Data Types
- Enum
- ClipboardFormat
- InputType
-
INPUT_MOUSE
for mouse input -
INPUT_KEYBOARD
for keyboard events -
INPUT_HARDWARE
for miscellaneous hardware events, only use if you know exactly what should be sent
-
- KEYEVENTF (bit field)
-
EXTENDEDKEY = 0x1
for use with Enhanced 101/102-key keyboards -
KEYUP = 0x2
to release the key -
UNICODE = 0x4
to send specific Unicode characters.INPUT.U.ki.wVk
must be set to 0, andINPUT.U.ki.wScan
should contain the Unicode character you want to send. It's easier to just useInputOperators.SendUnicode
for this purpose. -
SCANCODE = 0x8
to useScanCode
for keys instead ofVirtualKey
-
- ScanCode
- The hardware scancode for the key, should have similar values to VirtualKey.
- VirtualKey
- The virtual key codes, all of which can be found here.
- MOUSEEVENTF (bit field)
MOVE = 0x0001
LEFTDOWN = 0x0002
LEFTUP = 0x0004
RIGHTDOWN = 0x0008
RIGHTUP = 0x0010
MIDDLEDOWN = 0x0020
MIDDLEUP = 0x0040
XDOWN = 0x0080
XUP = 0x0100
WHEEL = 0x0800
HWHEEL = 0x1000
MOVE_NOCOALESCE = 0x2000
VIRTUALDESK = 0x4000
ABSOLUTE = 0x8000
- Struct
- INPUT
-
type
(InputType) for which input type to use -
U
(InputUnion) for different inputs' data -
Size
(static readonly int) for the size of the INPUT struct (necessary for Win32's SendInput)
-
- InputUnion
-
mi
(MOUSEINPUT) -
ki
(KEYBDINPUT) -
hi
(HARDWAREINPUT)
-
- MOUSEINPUT
-
dx
(int) for position change (relative or absolute depending on ifdwFlags
hasMOUSEEVENTF.ABSOLUTE
set) -
dy
(int) for position change (relative or absolute depending on ifdwFlags
hasMOUSEEVENTF.ABSOLUTE
set) -
mouseData
(int) for extra data:- If
MOUSEEVENTF.WHEEL
(supports Windows XP/2000) orMOUSEEVENTF.HWHEEL
(doesn't) is set, scrolls the mouse wheel. One click == 120 - If
MOUSEEVENTF.XDOWN
orMOUSEEVENTF.XUP
is set, changes which XButton is affected (1 == XBUTTON1, 2 == XBUTTON2)
- If
-
dwFlags
(MOUSEEVENTF) -
time
(uint) for a time stamp of the event. If 0, the system provides the time. -
dwExtraInfo
(UIntPtr) for additional info. UseInputOperations.GetExtraInfo
to obtain the info, then cast to UIntPtr.
-
- KEYBDINPUT
-
wVk
(VirtualKey) for virtual key codes to send. Needs to be 0 ifKEYEVENTF.UNICODE
is set. -
wScan
(ScanCode) for hardware scan codes to send. Only needed ifKEYEVENTF.SCANCODE
is set. -
dwFlags
(KEYEVENTF) for specific events. Refer toKEYEVENTF
above for more info. -
time
(uint) for a time stamp of the event. If 0, the system provides the time. -
dwExtraInfo
(UIntPtr) for additional info. UseInputOperations.GetExtraInfo
to obtain the info, then cast to UIntPtr.
-
- HARDWAREINPUT
-
uMsg
(int) for the message generated by the hardware. -
wParamL
(short) for the low-order word (short) of the lParam parameter foruMsg
. -
wParamR
(short) for the high-order word (short) of the lParam parameter foruMsg
.
-
- INPUT
InputOperations contains the following public methods:
Public Methods
-
GetLastError
( ) -> int
-
GetExtraInfo
( ) -> IntPtr
-
GetClipboardText
( ) -> string
-
InputEvent
( INPUT[] ) -> uint
-
SendUnicode
( string, uint ) -> uint
-
SendUnicode
( char, uint ) -> uint
-
SendUnicode
( char[], uint ) -> uint
-
SendKeypress
( VirtualKey, uint ) -> uint
-
SendKeypress
( VirtualKey[], uint ) -> uint
Gets the last error produced by Win32.
Returns: An integer representation of various error values. See this website for all error codes possible.
Gets extra info about the input, required by SendInput
when using KEYBDINPUT
or MOUSEINPUT
.
Returns: A pointer containing the extra information, which is device specific.
Gets text data from the clipboard.
Returns: A string containing the text information on the clipboard.
Sends any input events.
INPUT[] inputs
: An array of inputs to be sent.
Returns: The number of successful inputs. If 0, another thread has blocked the input. If blocked by UIPI, neither GetLastError
nor the return value will indicate such.
Sends a string of Unicode characters as input
string s
: The string you wish to input
uint millisecondDelay
: The delay between key press and release. This is not a delay between individual keys.
Returns: The number of successful inputs. If 0, another thread has blocked the input. If blocked by UIPI, neither GetLastError
nor the return value will indicate such.
Sends a single Unicode character as input
char c
: The character you wish to input
uint millisecondDelay
: The delay between key press and release. This is not a delay between individual keys.
Returns: The number of successful inputs. If 0, another thread has blocked the input. If blocked by UIPI, neither GetLastError
nor the return value will indicate such.
Sends an array of Unicode characters as input
char[] chars
: The array of characters you wish to input
uint millisecondDelay
: The delay between key press and release. This is not a delay between individual keys.
Returns: The number of successful inputs. If 0, another thread has blocked the input. If blocked by UIPI, neither GetLastError
nor the return value will indicate such.
Sends a virtual key as input
VirtualKey vk
: The virtual key you wish to input
uint millisecondDelay
: The delay between key press and release. This is not a delay between individual keys.
Returns: The number of successful inputs. If 0, another thread has blocked the input. If blocked by UIPI, neither GetLastError
nor the return value will indicate such.
Sends an array of virtual keys as input
VirtualKey[] virtualKeys
: The array of virtual keys you wish to input
uint millisecondDelay
: The delay between key press and release. This is not a delay between individual keys.
Returns: The number of successful inputs. If 0, another thread has blocked the input. If blocked by UIPI, neither GetLastError
nor the return value will indicate such.