Module: Vigilem::Win32API::Rubyized Abstract
Overview
Constant Summary
Constants included from Constants
Constants::BACKGROUND_BLUE, Constants::BACKGROUND_GREEN, Constants::BACKGROUND_INTENSITY, Constants::BACKGROUND_RED, Constants::CONSOLE_TEXTMODE_BUFFER, Constants::DOUBLE_CLICK, Constants::ENABLE_ECHO_INPUT, Constants::ENABLE_LINE_INPUT, Constants::ENABLE_MOUSE_INPUT, Constants::ENABLE_PROCESSED_INPUT, Constants::ENABLE_PROCESSED_OUTPUT, Constants::ENABLE_WINDOW_INPUT, Constants::ENABLE_WRAP_AT_EOL_OUTPUT, Constants::FILE_SHARE_READ, Constants::FILE_SHARE_WRITE, Constants::FOREGROUND_BLUE, Constants::FOREGROUND_GREEN, Constants::FOREGROUND_INTENSITY, Constants::FOREGROUND_RED, Constants::FROM_LEFT_1ST_BUTTON_PRESSED, Constants::FROM_LEFT_2ND_BUTTON_PRESSED, Constants::FROM_LEFT_3RD_BUTTON_PRESSED, Constants::FROM_LEFT_4TH_BUTTON_PRESSED, Constants::GENERIC_READ, Constants::GENERIC_WRITE, Constants::INVALID_HANDLE_VALUE, Constants::MOUSE_MOVED, Constants::MOUSE_WHEELED, Constants::MapVK, Constants::RIGHTMOST_BUTTON_PRESSED, Constants::STD_ERROR_HANDLE, Constants::STD_INPUT_HANDLE, Constants::STD_OUTPUT_HANDLE
Constants included from Constants::MapType
Constants::MapType::MAPVK, Constants::MapType::MAPVK_VK_TO_CHAR, Constants::MapType::MAPVK_VK_TO_VSC, Constants::MapType::MAPVK_VSC_TO_VK, Constants::MapType::MAPVK_VSC_TO_VK_EX
Constants included from Constants::Events
Constants::Events::CTRL_BREAK_EVENT, Constants::Events::CTRL_CLOSE_EVENT, Constants::Events::CTRL_C_EVENT, Constants::Events::CTRL_LOGOFF_EVENT, Constants::Events::CTRL_SHUTDOWN_EVENT, Constants::Events::FOCUS_EVENT, Constants::Events::KEY_EVENT, Constants::Events::MENU_EVENT, Constants::Events::MOUSE_EVENT, Constants::Events::WINDOW_BUFFER_SIZE_EVENT
Constants included from Constants::DWControlKeys
Constants::DWControlKeys::CAPSLOCK_ON, Constants::DWControlKeys::ENHANCED_KEY, Constants::DWControlKeys::LEFT_ALT_PRESSED, Constants::DWControlKeys::LEFT_CTRL_PRESSED, Constants::DWControlKeys::NUMLOCK_ON, Constants::DWControlKeys::RIGHT_ALT_PRESSED, Constants::DWControlKeys::RIGHT_CTRL_PRESSED, Constants::DWControlKeys::SCROLLLOCK_ON, Constants::DWControlKeys::SHIFT_PRESSED
Instance Method Summary collapse
- #get_std_handle(handle = Vigilem::Win32API::STD_INPUT_HANDLE) ⇒ Integer
-
#map_virtual_key(code, conversion) ⇒ Integer
Translates (maps) a virtual-key code into a scan code or character value, or translates a scan code into a virtual-key code.
- #peek_console_input(opts = {}) ⇒ PINPUT_RECORD
- #read_console_input(opts = {}) ⇒ PINPUT_RECORD
Instance Method Details
#get_std_handle(handle = Vigilem::Win32API::STD_INPUT_HANDLE) ⇒ Integer
13 14 15 |
# File 'lib/vigilem/win32_api/rubyized.rb', line 13 def get_std_handle(handle=Vigilem::Win32API::STD_INPUT_HANDLE) win32_api_rubyized_src.GetStdHandle(handle) end |
#map_virtual_key(code, conversion) ⇒ Integer
Translates (maps) a virtual-key code into a scan code or character value, or translates a scan code into a virtual-key code.
63 64 65 66 67 68 69 70 71 |
# File 'lib/vigilem/win32_api/rubyized.rb', line 63 def map_virtual_key(code, conversion) conversion_value = if conversion.is_a? Symbol raise ArgumentError, "`#{conversion}' is not an available uMapType name" unless MapType.constants.include? conversion API::Rubyized.const_get(conversion) elsif not (@uMapeTypes ||= MapType.constants.map {|const| Vigilem::Win32API::Rubyized.const_get(const) }).include? conversion raise ArgumentError, "`#{conversion}' is not an available uMapType" end win32_api_rubyized_src.MapVirtualKey(code, conversion_value || conversion) end |
#peek_console_input(opts = {}) ⇒ PINPUT_RECORD
24 25 26 27 28 |
# File 'lib/vigilem/win32_api/rubyized.rb', line 24 def peek_console_input(opts={}) (opts) win32_api_rubyized_src.PeekConsoleInput(opts[:hConsoleInput], opts[:lpBuffer], opts[:nLength], opts[:lpNumberOfEventsRead]) opts[:lpBuffer] end |
#read_console_input(opts = {}) ⇒ PINPUT_RECORD
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/vigilem/win32_api/rubyized.rb', line 39 def read_console_input(opts={}) (opts) lp_buffer = [] if (default = (blocking = opts[:blocking]).nil?) or blocking begin win32_api_rubyized_src.ReadConsoleInput(opts[:hConsoleInput], opts[:lpBuffer], opts[:nLength], opts[:lpNumberOfEventsRead]) lp_buffer += opts[:lpBuffer] end while (not default) and lp_buffer.size < opts[:nLength] opts[:lpBuffer].replace(lp_buffer) elsif not peek_console_input.empty? win32_api_rubyized_src.ReadConsoleInput(opts[:hConsoleInput], opts[:lpBuffer], opts[:nLength], opts[:lpNumberOfEventsRead]) opts[:lpBuffer] end end |