Skip to content

Instantly share code, notes, and snippets.

@CannoHarito
Last active December 28, 2023 06:38
Show Gist options
  • Save CannoHarito/e64199abc59b18f01a61f6af6b522c28 to your computer and use it in GitHub Desktop.
Save CannoHarito/e64199abc59b18f01a61f6af6b522c28 to your computer and use it in GitHub Desktop.
Windows版iTunesで再生中の楽曲を#NowPlayingをつけてツイートするページを開く cmd版,WSH(JScript)版,Powershell版
powershell (New-Object -C 'iTunes.Application').CurrentTrack^|%%{start('https://twitter.com/intent/tweet?text='+[Uri]::EscapeDataString(\"#NowPlaying $($_.Name) - $($_.Artist) ($($_.Album))\"))}
var t=new ActiveXObject("iTunes.Application").CurrentTrack;
new ActiveXObject("WScript.Shell").Run("https://twitter.com/intent/tweet?text="+encodeURIComponent("#NowPlaying "+t.Name+" - "+t.Artist+" (Album: "+t.Album+")"));
# $t=(New-Object -Com "iTunes.Application").CurrentTrack;
# Add-Type -AssemblyName ($w="System.Web");
# $w="$w.HttpUtility" -as [type];
# start ("https://twitter.com/intent/tweet?text="+$w::UrlEncode("#NowPlaying $($t.Name) - $($t.Artist) (Album: $($t.Album))"))
# System.Uri の方で十分であった
# $t = (New-Object -Com "iTunes.Application").CurrentTrack;
# start ("https://twitter.com/intent/tweet?text=" + [System.Uri]::EscapeDataString("#NowPlaying $($t.Name) - $($t.Artist) (Album: $($t.Album))"))
# ついでに一行にする
(New-Object -Com "iTunes.Application").CurrentTrack | % { start ("https://twitter.com/intent/tweet?text=" + [System.Uri]::EscapeDataString("#NowPlaying $($_.Name) - $($_.Artist) (Album: $($_.Album))")) }
@CannoHarito
Copy link
Author

cmd版のコマンドをダブルクォーテーションで囲う必要はなかったですね
"が2つ減って、|^|になったので1文字短くなりました

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment