2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Elixirでキーボード信号を送信する

Last updated at Posted at 2024-07-27

前提環境

OS Ubuntu 22.04
xdotoolがインストールできる環境

xdotoolをインストール

$ sudo apt install xdotool

キーボード信号を送信するコマンドとして使います

ソース

10回「a」を1秒間隔で送信します

efmodule Keyout do
  @moduledoc """
  Documentation for `Keyout`.
  """

  def key() do
    1..10
    |> Enum.each(fn _ -> send_key() end)
  end

  def send_key() do
    System.cmd("xdotool", ["type", "a"])
    Process.sleep(1000)
  end
end

key関数

  • 10回send_key関数を実行

send_key関数

  • xdotoolコマンドで「a」を送信
  • 1秒待つ
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?