Tag: Apple

Powershell iTunes v1

Powershell iTunesIn the last days I worked with Powershell and ComObjects. It turned out that iTunes is a really good exmaple for using ComObjects with Powershell, thats why I wrote this little Script.
Powershell iTunes is a Powershell script which lets you control iTunes over Powershell.

Howto:

  1. Download Powershellitunes.zip
  2. Extract the Files where ever you wanna save the powershell script
  3. Run the script
    Powershell iTunes
  4. Now you can run the Powershell Cmdlets

Powershell iTunes Commands:

  • Start-iTunes
  • Close-iTunes
  • Play-Track
  • Pause-Track
  • Resume-Track
  • Back-Track
  • Next-Track
  • Mute-Track
  • Unmute-Track
  • Show-iTunesVersion
  • Set-VolumeDown
  • Set-VolumeUp
  • Set-Volume

The Script:

#
#*****************************************************************
#
# Powershell iTunes v1 $Rev: 754 $
# (c) 2004-2010 Thomas Maurer. All rights reserved.
# created by Thomas Maurer
#
# https://www.thomasmaurer.ch
# https://www.thomasmaurer.ch/projects 
#
# last Update by $Author: tmaurer $ on $Date: 2010-11-24 07:50:06 +0100 (Mi, 24 Nov 2010) $
#
# Version 1.0.1
#
#*****************************************************************
#
 
# Welcome													
Write-Host "                                                                  " -BackgroundColor Black -ForegroundColor White
Write-Host "    ____                               __         ____            " -BackgroundColor Black -ForegroundColor White
Write-Host "   / __ \____ _      _____  __________/ /_  ___  / / /            " -BackgroundColor Black -ForegroundColor White
Write-Host "  / /_/ / __ \ | /| / / _ \/ ___/ ___/ __ \/ _ \/ / /             " -BackgroundColor Black -ForegroundColor White
Write-Host " / ____/ /_/ / |/ |/ /  __/ /  (__  ) / / /  __/ / /              " -BackgroundColor Black -ForegroundColor White
Write-Host "/_/    \____/|__/|__/\___/_/  /____/_/ /_/\___/_/_/               " -BackgroundColor Black -ForegroundColor White
Write-Host "                                                                  " -BackgroundColor Black -ForegroundColor White                    
Write-Host "    _ ______                                                      " -BackgroundColor Black -ForegroundColor White
Write-Host "   (_)_  __/_  ______  ___  _____                                 " -BackgroundColor Black -ForegroundColor White
Write-Host "  / / / / / / / / __ \/ _ \/ ___/                                 " -BackgroundColor Black -ForegroundColor White
Write-Host " / / / / / /_/ / / / /  __(__  )                                  " -BackgroundColor Black -ForegroundColor White
Write-Host "/_/ /_/  \__,_/_/ /_/\___/____/                                   " -BackgroundColor Black -ForegroundColor White                                 
Write-Host "                                                                  " -BackgroundColor Black -ForegroundColor White
Write-Host "******************************************************************" -BackgroundColor Black -ForegroundColor White
Write-Host "                                                                  " -BackgroundColor Black -ForegroundColor White
Write-Host " Welcome to the Powershell iTunes                                 " -BackgroundColor Black -ForegroundColor White
Write-Host "                                                                  " -BackgroundColor Black -ForegroundColor White
Write-Host " (c) 2010 Thomas Maurer www.thomasmaurer.ch/projects              " -BackgroundColor Black -ForegroundColor White
Write-Host "                                                                  " -BackgroundColor Black -ForegroundColor White
Write-Host "******************************************************************" -BackgroundColor Black -ForegroundColor White
Write-Host "                                                                  " -BackgroundColor Black -ForegroundColor White
Write-Host " for Help use the Get-PSiTunesHelp                                " -BackgroundColor Black -ForegroundColor White
Write-Host "                                                                  " -BackgroundColor Black -ForegroundColor White
 
# Add ComObjects to $iTunes
$iTunes = New-Object -ComObject iTunes.Application
 
 
# Function to start itunes
function Start-iTunes { 
    process {
 
		$iTunesRunning = Get-Process | Where-Object {$_.ProcessName -eq "iTunes"}
		if(!$iTunesRunning) {
			$script:iTunes = New-Object -ComObject iTunes.Application
			Write-Host "(PS iTunes): iTunes started" -BackgroundColor Black -ForegroundColor green
		} 
		else {
			Write-Host "(PS iTunes): iTunes allready running" -BackgroundColor Black -ForegroundColor red
		}
	}
}
 
# Function to close itunes
function Close-iTunes { 
    process {
 
		$iTunesRunning = Get-Process | Where-Object {$_.ProcessName -eq "iTunes"}
		if(!$iTunesRunning) {
			Write-Host "(PS iTunes): iTunes not running" -BackgroundColor Black -ForegroundColor red
		} 
		else {
			Stop-Process $iTunesRunning.Id
			Write-Host "(PS iTunes): iTunes closed" -BackgroundColor Black -ForegroundColor red
		}
	}
}
 
# Function to play a song
function Play-Track { 
    process {
		if ($iTunes.Playerstate -eq "0"){
			$iTunes.Play()
			Write-Host "(PS iTunes): Now playing:" $iTunes.CurrentTrack.Name "from" $iTunes.CurrentTrack.Artist -BackgroundColor Black -ForegroundColor green
		} 
		else {
			Write-Host "(PS iTunes): Already playing Track:" $iTunes.CurrentTrack.Name "from" $iTunes.CurrentTrack.Artist -BackgroundColor Black -ForegroundColor red
		}
	}
}
 
# Function to stop a song
function Pause-Track { 
    process {
        if ($iTunes.Playerstate -eq "1"){
			$iTunes.Pause()	
			Write-Host "(PS iTunes): iTunes paused" -BackgroundColor Black -ForegroundColor Red
		}
		else {
			Write-Host "(PS iTunes): Not playing any track" -BackgroundColor Black -ForegroundColor red
		}
	}
}
 
# Function to resume a song
function Resume-Track { 
    process {
    	if ($iTunes.Playerstate -eq "0"){ 
			$iTunes.Play()
			Write-Host "(PS iTunes): Now playing:" $iTunes.CurrentTrack.Name "from" $iTunes.CurrentTrack.Artist -BackgroundColor Black -ForegroundColor green
		}
		else {
			Write-Host "(PS iTunes): Already playing Track:" $iTunes.CurrentTrack.Name "from" $iTunes.CurrentTrack.Artist -BackgroundColor Black -ForegroundColor red
		}
	}
}
 
# Function to go a song back
function Back-Track { 
    process { 
	$iTunes.BackTrack()
	Write-Host "(PS iTunes): Now playing:" $iTunes.CurrentTrack.Name "from" $iTunes.CurrentTrack.Artist -BackgroundColor Black -ForegroundColor green	
	}
}
 
# Function to go to the next
function Next-Track { 
    process {   
	$iTunes.NextTrack()
	Write-Host "(PS iTunes): Now playing:" $iTunes.CurrentTrack.Name "from" $iTunes.CurrentTrack.Artist -BackgroundColor Black -ForegroundColor green	
	}
}
 
# Function to get infos about the current track
function Get-CurrentTrack { 
    process {    
	Write-Host "(PS iTunes): Currently playing:" $iTunes.CurrentTrack.Name "from" $iTunes.CurrentTrack.Artist -BackgroundColor Black -ForegroundColor White
	}
}
 
# Function to mute itunes
function Mute-iTunes { 
    process {
        if($itunes.Mute -eq $false) {
			$itunes.Mute = $true
			Write-Host "(PS iTunes): iTunes muted" -BackgroundColor Black -ForegroundColor Red
		}
		else {
			Write-Host "(PS iTunes): iTunes already muted" -BackgroundColor Black -ForegroundColor red
		}
	}
}
 
# Function to unmute itunes
function Unmute-iTunes { 
    process {
    	if($itunes.Mute -eq $true) {
			$itunes.Mute = $false
			Write-Host "(PS iTunes): iTunes unmuted" -BackgroundColor Black -ForegroundColor green
		}
		else {
			Write-Host "(PS iTunes): iTunes already unmuted" -BackgroundColor Black -ForegroundColor red
		}
	}
}
 
# Function to set iTunes volume up
function Set-VolumeUP { 
    process {
		if($iTunes.SoundVolume -lt 100) {
			$iTunes.SoundVolume = $iTunes.SoundVolume + 2
			Write-Host "(PS iTunes): iTunes Volume" $iTunes.SoundVolume -BackgroundColor Black -ForegroundColor green	
		}	
		else {
			Write-Host "(PS iTunes): iTunes Volume is already 100%" -BackgroundColor Black -ForegroundColor red
		}	
	}
}
 
# Function to set iTunes volume down
function Set-VolumeDown { 
    process {
		if($iTunes.SoundVolume -gt 0) {
			$iTunes.SoundVolume = $iTunes.SoundVolume - 2
			Write-Host "(PS iTunes): iTunes Volume" $iTunes.SoundVolume -BackgroundColor Black -ForegroundColor red	
		}	
		else {
			Write-Host "(PS iTunes): iTunes Volume is already 0%" -BackgroundColor Black -ForegroundColor red
		}
	}
}
 
# Function to set iTunes
function Set-Volume { 
	param (
		[int]$Volume 
	)
    process {
		if($Volume -ge 0 -and $Volume -le 100) {
			$iTunes.SoundVolume = $Volume
			Write-Host "(PS iTunes): iTunes Volume" $iTunes.SoundVolume -BackgroundColor Black -ForegroundColor green	
		}	
		else {
			Write-Host "(PS iTunes): Volume has to be 0-100" -BackgroundColor Black -ForegroundColor red
		}
	}
}
 
# Function to show the Version of iTunes
function Show-iTunesVersion { 
    process {
	Write-Host "(PS iTunes): iTunes Version" $iTunes.version -BackgroundColor Black -ForegroundColor White	
	}
}
 
# Function to show the Version of iTunes
function get-PSiTunesHelp { 
    process {
	Write-Host " "
	Write-Host " Powershell iTunes Help"
	Write-Host " "	
	Write-Host "********************************************************"	
	Write-Host " "
	Write-Host " Commands"
	Write-Host " "
	Write-Host " Start-iTunes			Starts iTunes"
	Write-Host " Close-iTunes			Closes iTunes"
	Write-Host " Play-Track			Plays a iTunes Track"
	Write-Host " Pause-Track			Pauses a iTunes Track"
	Write-Host " Resume-Track			Resumes a iTunes Track"
	Write-Host " Back-Track			Go to the last iTunes Track"
	Write-Host " Next-Track			Plays next iTunes Track"
	Write-Host " Mute-Track			Mutes iTunes"
	Write-Host " Unmute-Track			Unmutes iTunes"	
	Write-Host " Show-iTunesVersion		Shows iTunes Version"
	Write-Host " Set-VolumeDown			Set Volume Down"
	Write-Host " Set-VolumeUp			Set Volume Up"
	Write-Host " Set-Volume			Set iTunes Volume (0-100)"
	}
}

I released this here: https://www.thomasmaurer.ch/projects/powershell-itunes/



SVN Basic

subversionA colleague made a pretty cool blog post about svn basic on his blog. Subverion is a software versioning and a revision control system. At work all our program code and scripts, every little piece of code is going in your Subversion repository. This allows you to get back to earlier revisions of the code or simply share and work on code with other employees. Even your documentation is going into the Subversion repository.

On his blog post (German) he shows the basics of subversion, doing a checkout of e repository, adding files, changing files, removing files and more.

Here is a basic list of svn commands, if you need more information you should check the Subversion Homepage or try the Blog post from tspycher.com

svn checkout  http://svn.colab.company.com # SVN checkout
svn commit -m "My Message and Changes" # SVN committing changes and new files
svn add /files/*.* # Adding Files to the SVN Repository after this you have to commit that
svn update # Update your local copy

A lot of IDE’s (Integrated Development Environment) like Visual Studio or Xcode have SVN integrated.



Error when trying to install Windows 7 x64 on your Mac

I tried to install Windows 7 Enterprise Edition x64 on older iMac at work with Bootcamp. After booting from the Windows 7 DVD I got the following error:

“Select CD-Rom Boot Type:_”

Now with this steps you can solve this issue by creating an new Windows 7 ISO image (I found this solution on Fluxbox.co.uk) :

  1. Create this 3 folders: C:\Windows7exe, C:\Windows7iso and C:\Windows7dvd
  2. Download oscdimg.exe and save it into C:\Windows7exe
  3. Copy the Content of a Windows 7 DVD or ISO to C:\Windows7iso
  4. Open the DOS prompt and navigate to the C:\Windows7exe directory (the place where oscdimg.exe was saved)
  5. Run the oscdimg.exe with the following parameters:
    oscdimg -n -m -bc:\windows7iso\boot\etfsboot.com c:\windows7iso c:\windows7dvd\windows7dvd.iso
  6. Burn the new windows7dvd.iso to a DVD and boot this with the Bootcamp installer.

oscdimg.exe



Enable Tiger “Classic” Style Dock In Leopard and Snow Leopard

defaults write com.apple.dock no-glass -boolean NO; killall DockIf you like the old or classic Dock Style from Mac OS X 10.4 you can enable this in Mac OS X 10.5 (Leopard) and in Mac OS X 10.6 (Snow Leopard).

Mac OS X 10.4 (Tiger) Dock:

Mac OS X 10.4 Tiger DockMac OS X 10.6 (Leopard) Dock:

Mac OS X 10.6 Snow Leopard Dock

  1. Open Mac OS X Terminal in the Utilities folder
  2. Run the following command in the Terminal
    defaults write com.apple.dock no-glass -boolean YES; killall Dock
  3. Now you have the classic Dock activated

If you want to activate the new glass Dock again, you can use the following command:

defaults write com.apple.dock no-glass -boolean NO; killall Dock



How to use Adium on every Mac OS X Space

Since Mac OS X Leopard I use Spaces a lot. In the System Preferences, Expose & Spaces you can configure Spaces. You can also configure Applications to use everytime the same Space. So for example my iCal always opens on Space 3, Tweetie always on Space 1 and so on. This is nothing new but it is pretty usefull to arrange your workspace like that.

Mac OS X Spaces

I also use Adium a lot so, often I copy past something form Safari, Evernote, Mail or another program to the Adium Message Window. But with Spaces I always had to drag the Adium Message Window to the Space of the Application or the other way round. But there is a pretty cool setting in Spaces. You can set an Application be on “Every Space”. So I set Adium to “Every Space” and I don’t have to move the Adium Message Window or a Application.

Mac OS X Spaces

I know this is nothing new, but I just didn’t know about this function.



HP iPrint iOS App

HP iPrint 3.0

Yesterday Hewlett-Packard released iPrint version 3.0. And this is a perfect App for printing and scanning documents directly from your iPhone, iPod Touch or iPad. You can print to HP Network Printers or USB Printers. For example printers which are connected with the Apple Airport Extreme or Express USB port.

What’s New In Version 3.0

  • Print PDF and text documents
  • Native iPad resolution & user interface for enhanced iPad viewing and use
  • Document Support – View and wirelessly print attachments (text and PDF files) from mail clients and apps compatible with iOS “Document Support” feature (requires iPad and/or iPhone iOS 4)
  • WebDAV – Turns your device into a wireless flash drive. Copy documents directly from your PC or Mac to/from your device and take them with you
  • File Sharing support – When connected via USB cable, transfer documents to iPad & iPhone (iOS 4) from PC or Mac
  • Scan to device – Scan photos & documents wirelessly from HP e-All-in-One printers to iOS devices (iPhone, iPod Touch and iPad)
  • Available in English, French, Italian, German, Spanish

Here you can find a list of printers which are supported with HP iPrint 3.0:



Flipboard – An awesome iPad App

Flipboard is an awesome iPad App. Its like your own social media magazine.

More about Flipboard: