Skip to content

Instantly share code, notes, and snippets.

@codebutler
Created August 27, 2014 00:00
Show Gist options
  • Select an option

  • Save codebutler/58c2ef7fc0e51a9bcfda to your computer and use it in GitHub Desktop.

Select an option

Save codebutler/58c2ef7fc0e51a9bcfda to your computer and use it in GitHub Desktop.
set adb to "/usr/local/bin/adb"
set impbcopy to "/Users/ericbutler/.bin/impbcopy"
set {oldtid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
set rawDevices to do shell script adb & " devices | tail -n +2 | grep -v '^$' | awk -F\\ '{ print $1 }'"
set devices to every text item of rawDevices
set AppleScript's text item delimiters to oldtid
set device to item 1 of {choose from list devices with prompt "Select Device:"}
if device is not false then
do shell script adb & " -s '" & device & "' shell screencap -p | perl -pe 's/\\x0D\\x0A/\\x0A/g' | " & impbcopy & " -"
display dialog "Screenshot copied to clipboard!" buttons {"OK"}
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment