Module: Win::Gui::Input
Overview
Contains constants and Win32API functions related to end user input
Constant Summary collapse
- KEYEVENTF_KEYDOWN =
Key down keyboard event (the key is being depressed)
0
- KEYEVENTF_KEYUP =
Key up keyboard event (the key is being released)
2
- KEYEVENTF_EXTENDEDKEY =
Extended kb event. If specified, the scan code was preceded by a prefix byte having the value 0xE0 (224).
1
- VK_CANCEL =
Control-break processing
0x03
- VK_BACK =
Backspace? key
0x08
- VK_TAB =
Tab key
0x09
- VK_SHIFT =
Shift key
0x10
- VK_CONTROL =
Ctrl key
0x11
- VK_RETURN =
ENTER key
0x0D
- VK_ALT =
ALT key
0x12
- VK_MENU =
ALT key alias
0x12
- VK_PAUSE =
PAUSE key
0x13
- VK_CAPITAL =
CAPS LOCK key
0x14
- VK_ESCAPE =
ESC key
0x1B
- VK_SPACE =
SPACEBAR
0x20
- VK_PRIOR =
PAGE UP key
0x21
- VK_NEXT =
PAGE DOWN key
0x22
- VK_END =
END key
0x23
- VK_HOME =
HOME key
0x24
- VK_LEFT =
LEFT ARROW key
0x25
- VK_UP =
UP ARROW key
0x26
- VK_RIGHT =
RIGHT ARROW key
0x27
- VK_DOWN =
DOWN ARROW key
0x28
- VK_SELECT =
SELECT key
0x29
- VK_PRINT =
PRINT key
0x2A
- VK_EXECUTE =
EXECUTE key
0x2B
- VK_SNAPSHOT =
PRINT SCREEN key
0x2C
- VK_INSERT =
INS key
0x2D
- VK_DELETE =
DEL key
0x2E
- VK_HELP =
HELP key
0x2F
- VK_OEM_1 =
US semicolon
0xBA
- VK_OEM_102 =
US backslash
0xE2
- VK_OEM_PERIOD =
US period (point)
0xBE
- VK_OEM_COMMA =
US comma
0xBC
- MOUSEEVENTF_ABSOLUTE =
dwFlags: Specifies that the dx and dy parameters contain normalized absolute coordinates. If not set, those parameters contain relative data: the change in position since the last reported position. This flag can be set, or not set, regardless of what kind of mouse or mouse-like device, if any, is connected to the system. For further information about relative mouse motion, see mouse_event Remarks section.
0x8000
- MOUSEEVENTF_MOVE =
Specifies that movement occurred.
0x01
- MOUSEEVENTF_LEFTDOWN =
Specifies that the left button is down.
0x02
- MOUSEEVENTF_LEFTUP =
Specifies that the left button is up.
0x04
- MOUSEEVENTF_RIGHTDOWN =
Specifies that the right button is down.
0x08
- MOUSEEVENTF_RIGHTUP =
Specifies that the right button is up.
0x010
- MOUSEEVENTF_MIDDLEDOWN =
Specifies that the middle button is down.
0x20
- MOUSEEVENTF_MIDDLEUP =
Specifies that the middle button is up.
0x040
- MOUSEEVENTF_WHEEL =
Windows NT/2000/XP: Specifies that the wheel has been moved, if the mouse has a wheel. The amount of movement is specified in dwData
0x80
- MOUSEEVENTF_XDOWN =
Windows 2000/XP: Specifies that an X button was pressed.
0x100
- MOUSEEVENTF_XUP =
Windows 2000/XP: Specifies that an X button was released.
0x200
- WHEEL_DELTA =
dwData: One wheel click is defined as WHEEL_DELTA, which is 120.
120
- XBUTTON1 =
Set if the first X button was pressed or released.
1
- XBUTTON2 =
Set if the second X button was pressed or released.
2
- INPUT_MOUSE =
Indicates NO data if dwFlags are NOT any of MOUSEEVENTF_WHEEL, MOUSEEVENTF_XDOWN, or MOUSEEVENTF_XUP
0
Constants included from Library
Instance Method Summary collapse
-
#keybd_event ⇒ Object
The keybd_event function synthesizes a keystroke.
-
#mouse_event ⇒ Object
The mouse_event function synthesizes mouse motion and button clicks.
Methods included from Library
callback, define_api, define_snake_method, enforce_count, extended, function, generate_names, generate_signature, generate_snake_method_body, try_function
Instance Method Details
#keybd_event ⇒ Object
The keybd_event function synthesizes a keystroke. The system can use such a synthesized keystroke to generate a WM_KEYUP or WM_KEYDOWN message. The keyboard driver’s interrupt handler calls the keybd_event function.
!! Windows NT/2000/XP/Vista:This function has been superseded. Use SendInput instead.
- Syntax
-
VOID keybd_event( BYTE bVk, BYTE bScan, DWORD dwFlags, PTR dwExtraInfo);
- bVk
-
<in> Specifies a virtual-key code. The code must be a value in the range 1 to 254. For a complete list, see Virtual-Key Codes.
- bScan
-
<in> Specifies a hardware scan code for the key.
- dwFlags
-
<in> Specifies various aspects of function operation. This parameter can be one or more of the following values: KEYEVENTF_EXTENDEDKEY, KEYEVENTF_KEYUP, KEYEVENTF_KEYDOWN
- dwExtraInfo
-
<in> Specifies an additional value associated with the key stroke.
NO Return Value
Remarks:
-
An App can simulate a press of the PRINTSCRN key in order to obtain a screen snapshot and save it to the clipboard. To do this, call keybd_event with the bVk parameter set to VK_SNAPSHOT.
-
Windows NT/2000/XP: The keybd_event function can toggle the NUM LOCK, CAPS LOCK, and SCROLL LOCK keys.
-
Windows 95/98/Me: The keybd_event function can toggle only the CAPS LOCK and SCROLL LOCK keys.
:call-seq:
keybd_event( virtual_key, scan_code, flags, extra_info )
165 |
# File 'lib/win/gui/input.rb', line 165 function :keybd_event, [:char, :char, :ulong, :ulong], :void |
#mouse_event ⇒ Object
The mouse_event function synthesizes mouse motion and button clicks.
!! Windows NT/2000/XP/Vista:This function has been superseded. Use SendInput instead.
- Syntax
-
VOID mouse_event( DWORD dwFlags, DWORD dx, DWORD dy, DWORD dwData, ULONG_PTR dwExtraInfo );
- dwFlags
-
<in> Specifies various aspects of mouse motion and button clicking. This parameter can be certain combinations of the following values. The values that specify mouse button status are set to indicate changes in status, not ongoing conditions. For example, if the left mouse button is pressed and held down, MOUSEEVENTF_LEFTDOWN is set when the left button is first pressed, but not for subsequent motions. Similarly, MOUSEEVENTF_LEFTUP is set only when the button is first released. You cannot specify both MOUSEEVENTF_WHEEL and either MOUSEEVENTF_XDOWN or MOUSEEVENTF_XUP simultaneously, because they both require use of the dwData field: MOUSEEVENTF_ABSOLUTE, MOUSEEVENTF_MOVE, MOUSEEVENTF_LEFTDOWN, MOUSEEVENTF_LEFTUP, MOUSEEVENTF_RIGHTDOWN, MOUSEEVENTF_RIGHTUP, MOUSEEVENTF_MIDDLEDOWN, MOUSEEVENTF_MIDDLEUP, MOUSEEVENTF_WHEEL, MOUSEEVENTF_XDOWN, MOUSEEVENTF_XUP
- dx
-
<in> Specifies the mouse’s absolute position along the x-axis or its amount of motion since the last mouse event was generated, depending on the setting of MOUSEEVENTF_ABSOLUTE. Absolute data is specified as the mouse’s actual x-coordinate; relative data is specified as the number of mickeys moved. A mickey is the amount that a mouse has to move for it to report that it has moved.
- dy
-
<in> Specifies the mouse’s absolute position along the y-axis or its amount of motion since the last mouse event was generated, depending on the setting of MOUSEEVENTF_ABSOLUTE. Absolute data is specified as the mouse’s actual y-coordinate; relative data is specified as the number of mickeys moved.
- dwData
-
<in>
-
If dwFlags contains MOUSEEVENTF_WHEEL, then data specifies the amount of wheel movement. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user. One wheel click is defined as WHEEL_DELTA, which is 120.
-
If dwFlags contains MOUSEEVENTF_WHEEL, then data specifies the amount of wheel movement. A positive value indicates that the wheel was rotated to the right; a negative value indicates that the wheel was rotated to the left. One wheel click is defined as WHEEL_DELTA (= 120).
-
Windows 2000/XP: If flags contains MOUSEEVENTF_XDOWN or MOUSEEVENTF_XUP, then data specifies which X buttons were pressed or released. This value may be any combination of the following flags.
-
If flags is not MOUSEEVENTF_WHEEL, MOUSEEVENTF_XDOWN, or MOUSEEVENTF_XUP, then data should be zero.
XBUTTON1 - Set if the first X button was pressed or released. XBUTTON2 - Set if the second X button was pressed or released.
-
- dwExtraInfo
-
<in> Specifies an additional value associated with the mouse event. An App calls GetMessageExtraInfo to obtain this extra information.
NO Return Value
Remarks:
-
If the mouse has moved, indicated by MOUSEEVENTF_MOVE being set, dx and dy hold information about that motion. The information is specified as absolute or relative integer values.
-
If MOUSEEVENTF_ABSOLUTE value is specified, dx and dy contain normalized absolute coordinates between 0 and 65,535. The event procedure maps these coordinates onto the display surface. Coordinate (0,0) maps onto the upper-left corner of the display surface, (65535,65535) maps onto the lower-right corner.
-
If the MOUSEEVENTF_ABSOLUTE value is not specified, dx and dy specify relative motions from when the last mouse event was generated (the last reported position). Positive values mean the mouse moved right (or down); negative values mean the mouse moved left (or up). Relative mouse motion is subject to the settings for mouse speed and acceleration level. An end user sets these values using the Mouse App in Control Panel. An App obtains and sets these values with the SystemParametersInfo function.
-
The system applies two tests to the specified relative mouse motion when applying acceleration. If the specified distance along either the x or y axis is greater than the first mouse threshold value, and the mouse acceleration level is not zero, the operating system doubles the distance. If the specified distance along either the x- or y-axis is greater than the second mouse threshold value, and the mouse acceleration level is equal to two, the operating system doubles the distance that resulted from applying the first threshold test. It is thus possible for the operating system to multiply relatively-specified mouse motion along the x- or y-axis by up to four times.
-
Once acceleration has been applied, the system scales the resultant value by the desired mouse speed. Mouse speed can range from 1 (slowest) to 20 (fastest) and represents how much the pointer moves based on the distance the mouse moves. The default value is 10, which results in no additional modification to the mouse motion.
-
The mouse_event function is used to synthesize mouse events by Apps that need to do so. It is also used by Apps that need to obtain more information from the mouse than its position and button state. For example, if a tablet manufacturer wants to pass pen-based information to its own Apps, it can write a DLL that communicates directly to the tablet hardware, obtains the extra information, and saves it in a queue. The DLL then calls mouse_event with the standard button and x/y position data, along with, in the dwExtraInfo parameter, some pointer or index to the queued extra information. When the App needs the extra information, it calls the DLL with the pointer or index stored in dwExtraInfo, and the DLL returns the extra information.
:call-seq:
mouse_event( flags, dx, dy, data, extra_info )
242 |
# File 'lib/win/gui/input.rb', line 242 function :mouse_event, [:ulong, :ulong, :ulong, :ulong, :ulong, ], :void |