Created
January 24, 2026 01:02
-
-
Save Nunocky/83d4c0f768b4cf85473a940bb0fcebc7 to your computer and use it in GitHub Desktop.
スクリーンショットを撮影してクリップボードにコピーする関数
This file contains hidden or 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
| # スクリーンショットを撮影してクリップボードにコピーする関数 | |
| android-screenshot() { | |
| local temp_file="/tmp/android_screenshot_$(date +%s).png" | |
| echo "📱 スクリーンショットを撮影中..." | |
| # スクリーンショットを撮影してデバイスに保存 | |
| adb shell screencap -p /sdcard/screenshot.png | |
| if [ $? -ne 0 ]; then | |
| echo "❌ スクリーンショットの撮影に失敗しました" | |
| return 1 | |
| fi | |
| # デバイスからMacにファイルを転送 | |
| adb pull /sdcard/screenshot.png "$temp_file" | |
| if [ $? -ne 0 ]; then | |
| echo "❌ ファイルの転送に失敗しました" | |
| return 1 | |
| fi | |
| # デバイス上のスクリーンショットを削除 | |
| adb shell rm /sdcard/screenshot.png | |
| # クリップボードにコピー | |
| osascript -e "set the clipboard to (read (POSIX file \"$temp_file\") as PNG picture)" | |
| if [ $? -eq 0 ]; then | |
| echo "✅ スクリーンショットをクリップボードにコピーしました" | |
| # 一時ファイルを削除 | |
| rm "$temp_file" | |
| else | |
| echo "❌ クリップボードへのコピーに失敗しました" | |
| echo "ファイルは $temp_file に保存されています" | |
| return 1 | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment