Method: AutoItX3::Window#send_message

Defined in:
lib/AutoItX3/window/send_message.rb

#send_message(msg, info1 = 0, info2 = 0) ⇒ Object

Sends a window message to self and waits for the window to process it.

Parameters

msg

The message to send. Either a constant from the Window::Messages module, or a symbol formed off a such name. For example, for WM_DESTROY you’d pass :destroy.

info1

(0) Additional message-specific information (wParam value).

info2

(0) Additional message-specific information (lParam value).

Return value

The return value of the SendMessage() function.

Raises

Au3Error

Window not found.

Errno::EACCES

Windows’s security policy blocked the function call.

Example

win.send_message(:destroy) #Immediately destroys a window. No chance to save.

You can find the additional paramters needed for each message at the Windows API docs at MSDN. I recommand you to query the search function with something like “WM_PAINT” if you want to know more about WM_PAINT.



234
235
236
237
238
239
240
241
242
# File 'lib/AutoItX3/window/send_message.rb', line 234

def send_message(msg, info1 = 0, info2 = 0)
  Window.functions[__method__] ||= Win32::API.new("SendMessage", 'LILL', 'L', "user32")
  
  raise_unfound unless exists?
  msg = Messages.const_get(:"WM_#{msg.to_s.upcase}") if msg.kind_of? Symbol
  ret = Window.functions[__method__].call(self.to_i, msg, info1, info2)
  Kernel.raise(Errno::EACCES, "The Windows UIPI blocked your function call.") if Window.functions[:get_last_error].call == 5
  ret
end