autohotkey ruby Remote Control Smart Home

Remote Control Windows from Smartphone with Sinatra and AutoHotkey

A memo of when I implemented remote control of a Windows PC from a smartphone using sinatra and autohotkey. For example, accessing a URL in a browser like Chrome on your smartphone controls your Windows PC (specific example: press the space key once). ruby, gems, sinatra installation...

Shou Arisaka
1 min read
Nov 1, 2025

A memo of when I implemented remote control of a Windows PC from a smartphone using sinatra and autohotkey.

What you can do: Accessing a URL in a browser like Chrome on your smartphone controls your Windows PC (specific example: press the space key once)

What to do: Set up a web server with sinatra. (Probably works with node.js too, but I like sinatra.) Write an autohotkey script. (If you can write, Java, C, or VBS are fine too.)

Implementation

Iโ€™ll skip the installation of ruby, gems, and sinatra.

app.rb

require 'sinatra'
require "open3"

get '/' do
  'hello'
end

# http://192.168.3.19:4567/youtube
get "/youtube" do
  Open3.popen3(%(cmd /c start "" "C:/pg/sinatra/_tmp/enterSpace.ahk")) do |i, o, e, w| ; end
  "/youtube"
end

C:/pg/sinatra/_tmp/enterSpace.ahk

send, {space}

When done, start the server.

PS C:\pg\sinatra> ruby app.rb -o 0.0.0.0

Check the local IP with ipconfig, and access a URL like 192.168.3.19:4567/youtube from your smartphone.

Was the space key pressed on Windows?

If you apply this, you might be able to put a keyboard on your smartphone and make any operation basically possible.

Share this article

Shou Arisaka Nov 1, 2025

๐Ÿ”— Copy Links