Created
September 6, 2022 11:28
-
-
Save labocho/7ecf1d239750e09e9de54cbc8f5d5268 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# PS5 版 FF14 にマクロをコピペするための支援スクリプトです。 | |
# 1. PS リモートプレイで操作しマクロ入力欄でキャレットが点滅する状態にする | |
# 2. マクロをクリップボードにコピー | |
# 3. pbpaste | paste-to-ps5 実行 | |
# 4. 通知音がなるたびに△ボタンを押す | |
require "open3" | |
def osascript(script, *args) | |
out, err, status = Open3.capture3("osascript", "-l", "JavaScript", "-e", script, *args) | |
unless status.success? | |
raise err | |
end | |
[out, err, status] | |
end | |
def sh(*args, **kwargs) | |
o, e, s = Open3.capture3(*args, **kwargs) | |
unless s.success? | |
$stderr.puts e | |
exit s.to_i | |
end | |
o | |
end | |
def beep | |
sh "afplay", "/System/Library/Sounds/Tink.aiff" | |
end | |
s = ARGF.read | |
warn "Press △ button when sounds beep" | |
warn "----------------------------------" | |
s.each_line do |line| | |
line.strip! | |
warn line | |
sh("pbcopy", stdin_data: line) | |
beep | |
sleep 3 | |
osascript <<~JS | |
function run(argv) { | |
var app = Application("PS Remote Play"); | |
app.activate(); | |
var se = Application("System Events"); | |
se.keystroke("v", {using:"command down"}); | |
delay(1.0) | |
se.keyCode(36); // or 76 | |
delay(2.0) | |
se.keyCode(36); // or 76 | |
delay(0.5) | |
} | |
JS | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment