Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@cnromaine
Last active December 21, 2015 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cnromaine/6268337 to your computer and use it in GitHub Desktop.
Save cnromaine/6268337 to your computer and use it in GitHub Desktop.
From http://www.drdobbs.com/windows/building-gui-applications-in-powershell/240049898?pgno=2The Search-Twitter function returns an array of PowerShell objects with properties from the Twitter query. From that data, we extract the text of the tweet and the URL pointing to the Twitter user's profile image. If you look closely at the PowerShell cod…
Import-Module .\ShowUI
function Search-Twitter ($q) {
$wc = New-Object Net.Webclient
$url = http://search.twitter.com/search.rss?q=$q
    ([xml]$wc.downloadstring($url)).rss.channel.item | select *
}
 
$ws = @{
    WindowStartupLocation = "CenterScreen"
    Width = 500
    Height = 500
}
New-Window @ws -Show {
    ListBox -Background Black -ItemTemplate {
        Grid -Columns 55, 300 {
        Image -Column 0 -Name Image -Margin 5
        TextBlock -Column 1 -Name Title `
            -Margin 5 `
            -Foreground White `
            -TextWrapping Wrap
    } | ConvertTo-DataTemplate -Binding @{
            "Image.Source" = "image_link"
            "Title.Text" = "title"
    }
  } -ItemsSource (Search-Twitter PowerShell)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment