Module: AutoItFFI::AutoIt
- Extended by:
- FFI::Library
- Defined in:
- lib/autoit-ffi.rb
Constant Summary collapse
- AU3_INTDEFAULT =
“Default” value for some int parameters (largest negative number)
-2147483647 # Used when constructing strings consumed by AutoIt
- UTF_16LE_NULL =
Used when constructing strings consumed by AutoIt
"\0".encode("UTF-16LE")
Class Method Summary collapse
- .admin? ⇒ Boolean
- .auto_it_set_option(option, value) ⇒ Object
- .block_input(flag) ⇒ Object
- .cd_tray(drive, action) ⇒ Object
-
.clip_get ⇒ Object
TODO: currently this method allocates a buffer that can hold 10000 utf16 characters to which the clipboard data is read to.
- .control_click(title, text, control, button, num_clicks, x = AU3_INTDEFAULT, y = AU3_INTDEFAULT) ⇒ Object
- .error ⇒ Object
- .get_mouse_pos_x ⇒ Object
- .get_mouse_pos_y ⇒ Object
- .mouse_wheel(direction, clicks) ⇒ Object
- .move_mouse(x, y, speed = 10) ⇒ Object
- .send(text, mode = :special) ⇒ Object
- .shutdown(*args) ⇒ Object
- .sleep(milliseconds) ⇒ Object
- .tool_tip(tip, x = AU3_INTDEFAULT, y = AU3_INTDEFAULT) ⇒ Object
- .win_close(title, text = "") ⇒ Object
- .win_exists?(title, text = "") ⇒ Boolean
- .win_kill(title, text = "") ⇒ Object
- .window_minimize_all ⇒ Object
- .window_minimize_all_undo ⇒ Object
Class Method Details
.admin? ⇒ Boolean
32 33 34 |
# File 'lib/autoit-ffi.rb', line 32 def admin? self.AU3_IsAdmin == 1 end |
.auto_it_set_option(option, value) ⇒ Object
28 29 30 |
# File 'lib/autoit-ffi.rb', line 28 def auto_it_set_option(option, value) self.AU3_AutoItSetOption(to_utf16(option), value.to_i) end |
.block_input(flag) ⇒ Object
36 37 38 39 |
# File 'lib/autoit-ffi.rb', line 36 def block_input(flag) flag_int = flag ? 1 : 0 self.AU3_BlockInput(flag_int) end |
.cd_tray(drive, action) ⇒ Object
41 42 43 44 |
# File 'lib/autoit-ffi.rb', line 41 def cd_tray(drive, action) result = self.AU3_CDTray(to_utf16(drive), to_utf16(action)) result == 1 end |
.clip_get ⇒ Object
TODO: currently this method allocates a buffer that can hold 10000 utf16 characters to which the clipboard data is read to. A better approach would be to first query the size of the clipboard and allocate a buffer that fits that size. Note that the program will crash if there is more than 10000 characters in the clipboard.
52 53 54 55 56 57 |
# File 'lib/autoit-ffi.rb', line 52 def clip_get buffer = FFI::MemoryPointer.new(:uint16, 10000, true) # allocate 20000 bytes and zero out the memory. self.AU3_ClipGet(buffer, 10000) clipboard_data = buffer.read_string(buffer.size) clipboard_data.force_encoding("UTF-16LE").encode("UTF-8").rstrip end |
.control_click(title, text, control, button, num_clicks, x = AU3_INTDEFAULT, y = AU3_INTDEFAULT) ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/autoit-ffi.rb', line 59 def control_click(title, text, control, , num_clicks, x = AU3_INTDEFAULT, y = AU3_INTDEFAULT) self.AU3_ControlClick(to_utf16(title), to_utf16(text), to_utf16(control), to_utf16(), num_clicks.to_i, x.to_i, y.to_i) end |
.error ⇒ Object
24 25 26 |
# File 'lib/autoit-ffi.rb', line 24 def error self.AU3_error end |
.get_mouse_pos_x ⇒ Object
73 74 75 |
# File 'lib/autoit-ffi.rb', line 73 def get_mouse_pos_x self.AU3_MouseGetPosX end |
.get_mouse_pos_y ⇒ Object
77 78 79 |
# File 'lib/autoit-ffi.rb', line 77 def get_mouse_pos_y self.AU3_MouseGetPosY end |
.mouse_wheel(direction, clicks) ⇒ Object
89 90 91 |
# File 'lib/autoit-ffi.rb', line 89 def mouse_wheel(direction, clicks) self.AU3_MouseWheel(to_utf16(direction), clicks.to_i) end |
.move_mouse(x, y, speed = 10) ⇒ Object
69 70 71 |
# File 'lib/autoit-ffi.rb', line 69 def move_mouse(x, y, speed = 10) self.AU3_MouseMove(x.to_i, y.to_i, speed.to_i) end |
.send(text, mode = :special) ⇒ Object
93 94 95 96 |
# File 'lib/autoit-ffi.rb', line 93 def send(text, mode = :special) mode_int = mode.to_sym == :raw ? 1 : 0 self.AU3_Send(to_utf16(text), mode_int) end |
.shutdown(*args) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/autoit-ffi.rb', line 102 def shutdown(*args) if args.size == 1 && args.first.is_a?(Fixnum) self.AU3_Shutdown(args.first.to_i) else = {logoff: 0, shutdown: 1, reboot: 2, force: 4, power_down: 8} = .keys & args.map(&:to_sym) opt_num = .map { |option| [option] }.inject(:+) raise ArgumentError, "Illegal arguments #{args.inspect}" if opt_num.nil? self.AU3_Shutdown(opt_num.to_i) end end |
.sleep(milliseconds) ⇒ Object
98 99 100 |
# File 'lib/autoit-ffi.rb', line 98 def sleep(milliseconds) self.AU3_Sleep(milliseconds.to_i) end |
.tool_tip(tip, x = AU3_INTDEFAULT, y = AU3_INTDEFAULT) ⇒ Object
114 115 116 |
# File 'lib/autoit-ffi.rb', line 114 def tool_tip(tip, x = AU3_INTDEFAULT, y = AU3_INTDEFAULT) self.AU3_ToolTip(to_utf16(tip), x.to_i, y.to_i) end |
.win_close(title, text = "") ⇒ Object
118 119 120 121 |
# File 'lib/autoit-ffi.rb', line 118 def win_close(title, text = "") result = self.AU3_WinClose(to_utf16(title), to_utf16(text)) result == 1 end |
.win_exists?(title, text = "") ⇒ Boolean
123 124 125 126 |
# File 'lib/autoit-ffi.rb', line 123 def win_exists?(title, text = "") result = self.AU3_WinExists(to_utf16(title), to_utf16(text)) result == 1 end |
.win_kill(title, text = "") ⇒ Object
128 129 130 |
# File 'lib/autoit-ffi.rb', line 128 def win_kill(title, text = "") self.AU3_WinKill(to_utf16(title), to_utf16(text)) end |
.window_minimize_all ⇒ Object
81 82 83 |
# File 'lib/autoit-ffi.rb', line 81 def window_minimize_all self.AU3_WinMinimizeAll end |
.window_minimize_all_undo ⇒ Object
85 86 87 |
# File 'lib/autoit-ffi.rb', line 85 def window_minimize_all_undo self.AU3_WinMinimizeAllUndo end |