More XDo examples

require "xdo/mouse"
require "xdo/keyboard"
require "xdo/xwindow"

# minimise all windows
XDo::XWindow.toggle_minimize_all

# getting a handle of an existing window
xwin = XDo::XWindow.from_search("jeeves_mobile@jamesrobertson.eu")
xwin.position #=> [72, 208]


# launching a new window

spawn("pluma")
id = XDo::XWindow.wait_for_window("pluma")
xwin = XDo::XWindow.new(id)

xwin.move(xwin.position[0] + 20, xwin.position[1] + 10)

# Activate the window if another window has become active
xwin.activate

# get the active window
XDo::XWindow.from_active
#=> <XDo::XWindow: "james@jessie: ~" (48234500)>

# return the desktop number
XDo::XWindow.desktop # => 0

# return the number of desktops
XDo::XWindow.desktop_num #=> 2


# right mouse click at x=400, y=400
XDo::Mouse.click(400, 400, XDo::Mouse::RIGHT)

# left mouse click
XDo::Mouse.click

# scroll down using the mouse wheel
XDo::Mouse.wheel(XDo::Mouse::DOWN, 4)

# return the mouse position
XDo::Mouse.position

# Type some text
XDo::Keyboard.simulate("testing 1 2 3\n")

# drag something in the window to position X=400 y=200
XDo::Mouse.drag(nil, nil, 400, 200)


# press CTRL+s
XDo::Keyboard.ctrl_s

# other methods include: ctrl_a, alt_s, return, delete, 

# press the down arrow key 9 times
XDo::Keyboard.simulate("{DOWN}" * 9)

# other special keys include: END, TAB

# Using type is usually faster than simulate if the 
# text doesn't contain special characters or escape sequences
XDo::Keyboard.type("Percentage of smokers in different jobs in Germany".upcase)

# type an individual special character
XDo::Keyboard.char("Shift+Right")