death pax Posted February 7, 2006 Share Posted February 7, 2006 Just a little scrap from a program I made for someone, thought I would share it, if anyone would like to improve on it, go for it ^.^ func GetCurrentItunesSong() $oItunes = ObjCreate("iTunes.Application") if @error then Msgbox (0,"Itunes","Error Getting an active Itunes Object. Error code: " & hex(@error,8)) exit endif $state=$oItunes.PlayerState if $State=1 Then $curtrack=$oItunes.CurrentTrack $Trackname=$curtrack.name $Artistname=$curtrack.Artist $Title=$ArtistName&" - "&$TrackName endif return $title endfunc Link to comment Share on other sites More sharing options...
death pax Posted February 9, 2006 Author Share Posted February 9, 2006 guess nobody likes it, or has no use for it.. ah well Link to comment Share on other sites More sharing options...
Wus Posted February 9, 2006 Share Posted February 9, 2006 nah, I used it, nice script some people just lurk and use instead of posting Link to comment Share on other sites More sharing options...
death pax Posted February 10, 2006 Author Share Posted February 10, 2006 yay Link to comment Share on other sites More sharing options...
Amen Posted February 26, 2006 Share Posted February 26, 2006 hey! i use Itunes,very nice script to have.. Tnx for Sharing Plugged ThoughtsQBsick? check my Old staff (New Launchers to Work with Windows.Thnx to Autoit!)Game Development ToolsPortes (A Backgammon game)Ball (An Arkanoid Style game)Au3? SecretProgz - Reveals Commands that can be used on your system CleanOut - Uninstall leftovers Enable windows XP Autologon. Stop Windows Auto Sharing your hard drives (C$,D$,etc) D-Link - Create a dynamic link.Useful for server shortcuts Fun - How would your name sounds in Japanese,Russian or Reventian? Fix_srt - Shift a subtitle (.srt) some secs +/- Link to comment Share on other sites More sharing options...
greenmachine Posted February 26, 2006 Share Posted February 26, 2006 It may be just a scrap, but it's a useful scrap. I expanded on it a little to show a ToolTip with the current song and another whenever the song changes. The GetCurrentItunesSongAfterCreation function does the same thing as the other one, I just didn't want it to go through the ObjCreate function every time it was called. expandcollapse popupGlobal $oItunes $CurrentSong = GetCurrentItunesSong() TrayTip ("Current Song", $CurrentSong, 1) Do Sleep (1000) $NewSong = GetCurrentItunesSongAfterCreation() If $NewSong <> $CurrentSong Then $CurrentSong = $NewSong TrayTip ("Song Changed", $CurrentSong, 1) EndIf Until Not ProcessExists ("iTunes.exe") Func GetCurrentItunesSongAfterCreation() Local $Title = "" $state=$oItunes.PlayerState If $State=1 Then $curtrack=$oItunes.CurrentTrack $Trackname=$curtrack.Name $Artistname=$curtrack.Artist $Title=$ArtistName & " - " & $TrackName EndIf Return $Title EndFunc Func GetCurrentItunesSong() Local $Title = "" $oItunes = ObjCreate("iTunes.Application") If @error Then Msgbox (0,"iTunes","Error Getting an active iTunes Object. Error code: " & Hex (@error, 8)) Exit EndIf $State=$oItunes.PlayerState If $State=1 Then $curtrack=$oItunes.CurrentTrack $Trackname=$curtrack.Name $Artistname=$curtrack.Artist $Title=$ArtistName & " - " & $TrackName EndIf Return $Title EndFunc Link to comment Share on other sites More sharing options...
death pax Posted February 27, 2006 Author Share Posted February 27, 2006 ^.^ thanks green Link to comment Share on other sites More sharing options...
death pax Posted February 27, 2006 Author Share Posted February 27, 2006 I actually made a program for getting the current song of winamp and putting it in a file to be read for a game(unreal). In unreal you can set keybind to read inputs from files, so i set a keybind to exec winamp.txt. in winamp.txt, when the song changed it would write "say Currently Listening to: <SongTitle>" so whenever i pressed the key it would show what song i was listening to. Needlessly to say, other people liked the idea but requested the functionality for itunes, thus this scrap was born. ^.^ Link to comment Share on other sites More sharing options...
greenmachine Posted February 27, 2006 Share Posted February 27, 2006 I tried something a while back dealing with iTunes, but I couldn't figure out all the object commands and such. But regardless, they're still fun little scripts to play with. Link to comment Share on other sites More sharing options...
death pax Posted February 27, 2006 Author Share Posted February 27, 2006 (edited) one thing i couldnt get working is for the program to close the open object when itunes closes, so you dont get the annoying message from itunes and the error popping up for the script i dont think autoit can handle the type of events that itunes throws >.> otherwise instead of constantly checking to see if titles are different, you could just wait for an event to happen(itunes throws an event when song changes), and also right before itunes exits it throws another event to allow com objects to be closed gracefully Edited February 27, 2006 by death pax Link to comment Share on other sites More sharing options...
greenmachine Posted February 27, 2006 Share Posted February 27, 2006 I also couldn't get iTunes to be embedded - it really doesn't want to get in the damn GUI. Link to comment Share on other sites More sharing options...
rakudave Posted March 3, 2006 Share Posted March 3, 2006 i liked it! ... and i played with it... ^^expandcollapse popup#include <GUIConstants.au3> Fileinstall("...somewhere...\itunes.jpg", @tempdir & "\itunes.jpg") Global $oItunes $width = 400 $height = 55 $xa = @DesktopWidth - $width - 5 $ya = @DesktopHeight - $height - 30 $CurrentSong = GetCurrentItunesSong() show() Hotkeyset("+!s","show") Do Sleep (1000) $NewSong = GetCurrentItunesSongAfterCreation() If $NewSong <> $CurrentSong Then $CurrentSong = $NewSong show() EndIf Until Not ProcessExists ("iTunes.exe") Func GetCurrentItunesSongAfterCreation() Local $Title = "" $state=$oItunes.PlayerState If $State=1 Then $curtrack=$oItunes.CurrentTrack $Trackname=$curtrack.Name $Artistname=$curtrack.Artist $Title=$ArtistName & " - " & $TrackName EndIf Return $Title EndFunc Func GetCurrentItunesSong() Local $Title = "" $oItunes = ObjCreate("iTunes.Application") If @error Then Msgbox (0,"iTunes","Error Getting an active iTunes Object. Error code: " & Hex (@error, 8)) Exit EndIf $State=$oItunes.PlayerState If $State=1 Then $curtrack=$oItunes.CurrentTrack $Trackname=$curtrack.Name $Artistname=$curtrack.Artist $Title=$ArtistName & " - " & $TrackName EndIf Return $Title EndFunc Func show() $hwnd = GUICreate("Alert", $width, $height, $xa, $ya, $WS_POPUPWINDOW, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) GUICtrlCreatePic(@tempdir & "\itunes.jpg",0,0,55,55) $disp = Stringreplace($CurrentSong," - ",@crlf) GUICtrlCreateLabel($disp, 55, 15) GUISetBkcolor(0xFFFFFF) DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 400, "long", 0x00040008) GUISetState() sleep(4000) DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 400, "long", 0x00050004) GUIDelete($hwnd) endfuncdownload with pics and stuff: http://www.gymmuenchenstein.ch/rakudave/iTunes_Alert.zip Pangaea Ruler new, UDF: _GUICtrlCreateContainer(), Pangaea Desktops, Pangaea Notepad, SuDoku, UDF: Table Link to comment Share on other sites More sharing options...
death pax Posted March 3, 2006 Author Share Posted March 3, 2006 yeah i made something like that for my version for winamp ^.^ Link to comment Share on other sites More sharing options...
rakudave Posted March 3, 2006 Share Posted March 3, 2006 yeah! show me... Pangaea Ruler new, UDF: _GUICtrlCreateContainer(), Pangaea Desktops, Pangaea Notepad, SuDoku, UDF: Table Link to comment Share on other sites More sharing options...
death pax Posted March 3, 2006 Author Share Posted March 3, 2006 I havent been able to find out how to use the windows sendmessage dll call correctly yet... maybe its not possible for autoit, so instead i just read the title of the window. here is the source&skinWinampToaster.zip Link to comment Share on other sites More sharing options...
rakudave Posted March 3, 2006 Share Posted March 3, 2006 lovely! Pangaea Ruler new, UDF: _GUICtrlCreateContainer(), Pangaea Desktops, Pangaea Notepad, SuDoku, UDF: Table Link to comment Share on other sites More sharing options...
greenmachine Posted March 25, 2006 Share Posted March 25, 2006 I just thought I'd bring this thread back up because I've been editing my script, and I added some features to it. It still shows the traytip when the song changes, but now you can do ctrl+ up, down, left, right, or space to change the volume (up and down), the song (left and right), or pause (space). If you press ctrl+shift+space, you can get more details, including current time and total length of the song, and current volume. After using this hotkey, you don't need to press ctrl before the modifier keys (although you still can). The traytip also updates itself during the 10 seconds it shows. expandcollapse popupHotKeySet ("+{ESC}", "quitme") HotKeySet ("^+{SPACE}", "ShowAndDoHotkeys") Func quitme() Exit EndFunc $oMyError = ObjEvent ("AutoIt.Error", "myerrfunc") Func MyErrFunc() $HexNumber=hex($oMyError.number,8) ; for displaying purposes Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline ) SetError(1) ; to check for after this function returns Endfunc Global $oItunes, $CurTip $CurrentSong = GetCurrentItunesSong() TrayTip ("Current Song", $CurrentSong, 10) $CurTip = 1 $Timer = TimerInit () Do Sleep (1000) If TimerDiff ($Timer) < 10000 Then If $CurTip = 3 Then TrayTip ("Current Song", GetCurrentItunesSongAfterCreation(1), 10) EndIf HotKeySet ("^{RIGHT}", "SendEventToITunes") HotKeySet ("^{LEFT}", "SendEventToITunes") HotKeySet ("^{UP}", "SendEventToITunes") HotKeySet ("^{DOWN}", "SendEventToITunes") HotKeySet ("^{SPACE}", "SendEventToITunes") ElseIf TimerDiff ($Timer) >= 10000 Then TrayTip ("", "", 1) HotKeySet ("^{RIGHT}") HotKeySet ("^{LEFT}") HotKeySet ("^{UP}") HotKeySet ("^{DOWN}") HotKeySet ("^{SPACE}") HotKeySet ("{RIGHT}") HotKeySet ("{LEFT}") HotKeySet ("{UP}") HotKeySet ("{DOWN}") HotKeySet ("{SPACE}") EndIf $NewSong = GetCurrentItunesSongAfterCreation() If $NewSong <> $CurrentSong Then $CurTip = 2 $CurrentSong = $NewSong TrayTip ("Song Changed", $CurrentSong, 10) $Timer = TimerInit () EndIf Until Not ProcessExists ("iTunes.exe") Func GetCurrentItunesSongAfterCreation($ShowOtherOptions = 0) Local $Title = "" $state=$oItunes.PlayerState If $State=1 Then $curtrack=$oItunes.CurrentTrack $Trackname=$curtrack.Name $Artistname=$curtrack.Artist $Title=$ArtistName & " - " & $TrackName If $ShowOtherOptions Then $Time = $curtrack.Time $CurPos = $oITunes.PlayerPosition $CurPos = Int ($CurPos/60) & ":" & StringRight ("00" & Mod ($CurPos, 60), 2) $Title &= @CRLF & "Time: " & $CurPos & " of " & $Time & @CRLF & @CRLF & _ "Volume: " & $oITunes.SoundVolume EndIf Else $Title = "Press Ctrl+Space to Play" EndIf Return $Title EndFunc Func GetCurrentItunesSong() Local $Title = "" $oItunes = ObjCreate("iTunes.Application") If @error Then Msgbox (0,"iTunes","Error Getting an active iTunes Object. Error code: " & Hex (@error, 8)) Exit EndIf $State=$oItunes.PlayerState If $State=1 Then $curtrack=$oItunes.CurrentTrack $Trackname=$curtrack.Name $Artistname=$curtrack.Artist $Title=$ArtistName & " - " & $TrackName Else $Title = "Press Ctrl+Space to Play" EndIf Return $Title EndFunc Func SendEventToITunes() ControlSend ("iTunes", "", $oItunes, @HotKeyPressed) EndFunc Func VolumeUp() $oITunes.SoundVolume = $oITunes.SoundVolume + 5 EndFunc Func VolumeDown() $oITunes.SoundVolume = $oITunes.SoundVolume - 5 EndFunc Func ShowAndDoHotkeys() TrayTip ("Current Song", GetCurrentItunesSongAfterCreation(1), 10) $CurTip = 3 $Timer = TimerInit () HotKeySet ("{LEFT}", "SendEventToITunes") HotKeySet ("{RIGHT}", "SendEventToITunes") HotKeySet ("{UP}", "VolumeUp") HotKeySet ("{DOWN}", "VolumeDown") HotKeySet ("{SPACE}", "SendEventToITunes") EndFunc Func OnAutoItExit() $oITunes = 0 HotKeySet ("^{RIGHT}") HotKeySet ("^{LEFT}") HotKeySet ("^{UP}") HotKeySet ("^{DOWN}") HotKeySet ("^{SPACE}") HotKeySet ("{RIGHT}") HotKeySet ("{LEFT}") HotKeySet ("{UP}") HotKeySet ("{DOWN}") HotKeySet ("{SPACE}") EndFunc PS - I figured it'd be a good 800th post. Link to comment Share on other sites More sharing options...
death pax Posted March 25, 2006 Author Share Posted March 25, 2006 awesome! I never really needed to add control over itunes to my script, and since i dont use itunes myself, i probly never would have, but i am glad to see that my original post has inspired a few people ^.^ Link to comment Share on other sites More sharing options...
greenmachine Posted March 25, 2006 Share Posted March 25, 2006 Yeah I use it, and I wanted to do this before, and so now that I have their helpfile I can do it. Link to comment Share on other sites More sharing options...
lev Posted April 13, 2007 Share Posted April 13, 2007 just want to thank for your first script to get the trackname and artist Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now