AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

iTunes Anywhere (keyboard shortcuts)
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
rockNme2349



Joined: 31 Aug 2007
Posts: 3

PostPosted: Fri Aug 31, 2007 9:41 pm    Post subject: Reply with quote

For anyone developing with iTunes in windows, i would definately look into iTunes COM Interface.

I used that to develop an itunes remote that allows me to remotely control itunes from any web broweser, even my phone, and gives me more controls such as typing in song names and playing them, and almost anything, even if there is no hotkey.
_________________
There are 10 types of people. Those that understand binary and those that don't.
Back to top
View user's profile Send private message
benbenben
Guest





PostPosted: Thu Nov 08, 2007 1:02 am    Post subject: mad props Reply with quote

thanks for the scripts here, i used the first one and just mapped them to the media keys, since those only worked when itunes was the active window....

SWEET!!!

I'm very pleased.
Back to top
ellipticaltable
Guest





PostPosted: Fri Dec 14, 2007 6:31 pm    Post subject: Reply with quote

If you want to be a bit fancier in talking to iTunes, you can do the following. It uses the iTunes SDK and ws4ahk (http://www.autohotkey.net/~easycom/). Basically, you get the full SDK functionality directly in your script.

This code doesn't do anything particularly useful at the moment. Instead, it shows how to do various things.

Code:

#Include ws4ahk.ahk

; Necessary initialization
WS_Initialize("JScript")
itunes := WS_CreateObject("iTunes.Application")
WS_AddObject(itunes, "itunesapp")
WS_ReleaseObject(itunes)

;Advance to the next track
WS_Exec("itunesapp.NextTrack ()")

;Display the current track and playlist
WS_Eval(trackname, "itunesapp.CurrentTrack.Name;")
WS_Eval(playlistname, "itunesapp.CurrentPlaylist.Name ;")
ToolTip, %trackname% in playlist %playlistname%
Sleep, 5000

; Required cleanup
WS_Uninitialize()



Hope this helps.
Back to top
darkpaladin79



Joined: 25 Nov 2007
Posts: 3

PostPosted: Tue Mar 11, 2008 12:09 am    Post subject: Reply with quote

Well, I've been using this script happily for almost a year now (I think, don't really know), but every now and then it stops working. I think it has something to do with things inside iTunes being selected, because it works after I bring it up and down again. But, I took the examples from ellipticaltable and rewrote the whole thing with the COM and ws4ahk. You need that ws4ahk.ahk file that he specifies, and right now I have the keys set to my mouse. So change those and you should be good to go! No more random desyncs for me.

Code:

#Include ws4ahk.ahk
#InstallMouseHook ;helps with mouse stuff being detected, you can leave it out if you want, seems to help me
OnExit, ExitSub

; Necessary initialization
WS_Initialize("JScript")
itunes := WS_CreateObject("iTunes.Application")
WS_AddObject(itunes, "itunesapp")
WS_ReleaseObject(itunes)

F18 & rbutton::
   WS_Exec("itunesapp.NextTrack ()")
return

F18 & lbutton::
   WS_Exec("itunesapp.PreviousTrack ()")
return

F18 & wheeldown::
   WS_Exec("itunesapp.SoundVolume = itunesapp.SoundVolume - 2")
return

F18 & wheelup::
   WS_Exec("itunesapp.SoundVolume = itunesapp.SoundVolume + 2")
return

F18::
   WS_Exec("itunesapp.PlayPause()")
return

ExitSub:
{
   ;MsgBox, Uninitializing
   WS_Uninitialize()
   ExitApp
}
Back to top
View user's profile Send private message
mashenden



Joined: 13 Mar 2008
Posts: 6

PostPosted: Tue Apr 01, 2008 1:33 am    Post subject: In need of help on similar effort Reply with quote

I need a AHK script using the iTunes COM. I have it in VBS and AutoIT, but am not real sure on how to convert either of them to AHK.

Here is what I have so far with your help:
Code:
WS_Initialize("JScript")
itunes := WS_CreateObject("iTunes.Application")
WS_AddObject(itunes, "itunesapp")
WS_ReleaseObject(itunes)
;?
;?
WS_Exec("itunesapp.PlayFirstTrack()")  ; Guessing on this one

ExitSub:
{
   ;MsgBox, Uninitializing
   WS_Uninitialize()
   ExitApp
}


This is the VBS code that works:
Code:
Set objApp = CreateObject("iTunes.Application")
Set colSources = objApp.Sources
Set objSource = colSources.ItemByName("Library")
Set colPlaylists = objSource.Playlists
Set objPlaylist = colPlaylists.ItemByName("Party Shuffle")
objPlaylist.PlayFirstTrack


This is the AutoIT code that works:
Code:
$objApp = ObjCreate("iTunes.Application")
$colSources = $objApp.Sources
$objSource = $colSources.ItemByName("Library")
$colPlaylists = $objSource.Playlists
$objPlaylist = $colPlaylists.ItemByName("Party Shuffle")
$objPlaylist.PlayFirstTrack()


Thank you in advance for any help.

Matt A
Back to top
View user's profile Send private message
erictheturtle



Joined: 27 Jun 2007
Posts: 90
Location: California

PostPosted: Fri Apr 11, 2008 5:08 pm    Post subject: Re: In need of help on similar effort Reply with quote

Hope this code isn't too late for you mashenden. It's untested, but this is basically how it could work.

Code:
; Setup a VBScript environment
WS_Initialize("VBScript")

; Get the iTunes app and library
vbcode_init =
(
   Set objApp = CreateObject("iTunes.Application")
   Set colSources = objApp.Sources
   Set objSource = colSources.ItemByName("Library")
   Set colPlaylists = objSource.Playlists
)
WS_Exec(vbcode_init)


; Handy function to get a playlist
GetPlaylist(playlist)
{
   WS_Exec("Set objPlaylist = colPlaylists.ItemByName(" ScriptStr(playlist) ")")
}
GetPlaylist("Party Shuffle")

; Start playing
WS_Exec("objPlaylist.PlayFirstTrack")




; Cleanup on exit
ExitSub:
{
   WS_Uninitialize()
   ExitApp
}

_________________
-m35
Back to top
View user's profile Send private message
jgerhat
Guest





PostPosted: Wed Jul 23, 2008 10:51 pm    Post subject: Reply with quote

would there be a way to make itunes skip to the last 3 seconds of a song, so that it still adds to the playcount of the song, as opposed to just skipping to the next song?
Back to top
zozue49
Guest





PostPosted: Mon Aug 11, 2008 4:53 am    Post subject: About the first script Reply with quote

I know its been 3 years since you posted this but I have to thank you so much.I come from a Winamp world in which I had Global Hotkeys but this is missing in iTunes. Moreover, I tried iTunesKeys and it very unreliable in Vista.

Again, hats off Wink
Back to top
oljomo
Guest





PostPosted: Fri Aug 15, 2008 5:36 pm    Post subject: Reply with quote

Hi

Been trying to figure out how to use the COM interface to activate/deactivate shuffle and cant figure out how...

Closest thing seems to be the property for a playlist to play shuffled or not, but that doesnt seem to work for the main library.

Any ideas as to how to do this?
Back to top
Peter Johnston
Guest





PostPosted: Thu Sep 11, 2008 2:23 pm    Post subject: Reply with quote

Hey, got the iTunes COM interface working with Dell Media buttons. This can rate your current track too, with #1, #2, etc. As far as I can tell, this works no matter what status iTunes is in - maximised/minimised/toolbar.

I'm assuming I'm doing things correctly with the WS - all that's required for this script is for ws4ahk.ahk to be included somewhere.

The only thing is that once AHK takes control of your volume buttons, they don't get passed through to your system (or to other programs). There's probably some code that could be added that sorts that though.

I still need to change the volume control to use COM, but that'll happen soon I expect.

Code:
#Include C:\Program Files\AutoHotKey\ws4ahk.ahk

; Necessary initialization
WS_Initialize("JScript")
itunes := WS_CreateObject("iTunes.Application")
WS_AddObject(itunes, "itunesapp")
WS_ReleaseObject(itunes)

; ############## iTunes ##############
;
; Media keys as normal.
;
; Rate current song:
; win+0 -> no stars
; win+1 -> *
; win+2 -> **
; win+3 -> ***
; win+4 -> ****
; win+5 -> *****

Media_Play_Pause::
WS_Exec("itunesapp.PlayPause()")
return

Media_Next::
WS_Exec("itunesapp.NextTrack()")
return

Media_Prev::
WS_Exec("itunesapp.PreviousTrack()")
return

Media_Stop::
WS_Exec("itunesapp.Stop()")
return

Volume_Mute::
;Toggles mute - I think this is really elegant. :)
WS_Exec("itunesapp.Mute ^= 1")
return

Volume_Down::
DetectHiddenWindows, On
ControlSend, ahk_parent, ^{down}, iTunes ahk_class iTunes
DetectHiddenWindows, Off
return

Volume_Up::
DetectHiddenWindows, On
ControlSend, ahk_parent, ^{up}, iTunes ahk_class iTunes
DetectHiddenWindows, Off
return

#0::
WS_Exec("currtrack=itunesapp.CurrentTrack")
WS_Exec("currtrack.Rating = 0")
WS_ReleaseObject(currtrack)
return

#1::
WS_Exec("currtrack=itunesapp.CurrentTrack")
WS_Exec("currtrack.Rating = 20")
WS_ReleaseObject(currtrack)
return

#2::
WS_Exec("currtrack=itunesapp.CurrentTrack")
WS_Exec("currtrack.Rating = 40")
WS_ReleaseObject(currtrack)
return

#3::
WS_Exec("currtrack=itunesapp.CurrentTrack")
WS_Exec("currtrack.Rating = 60")
WS_ReleaseObject(currtrack)
return

#4::
WS_Exec("currtrack=itunesapp.CurrentTrack")
WS_Exec("currtrack.Rating = 80")
WS_ReleaseObject(currtrack)
return

#5::
WS_Exec("currtrack=itunesapp.CurrentTrack")
WS_Exec("currtrack.Rating = 100")
WS_ReleaseObject(currtrack)
return

; Required cleanup
WS_Uninitialize()
Back to top
anon
Guest





PostPosted: Sun Oct 26, 2008 2:26 am    Post subject: Reply with quote

khimaira wrote:
I only recently started getting into AHK, but this is exactly what I've been trying to do. I wonder, is this possible with any app? VLC perhaps?

Thank you, so much.


Code:

#space::
DetectHiddenWindows, On
ControlSend, ahk_parent, {space}, ahk_class QWidget
DetectHiddenWindows, Off
return


just use ahk_class QWidget instead of iTunes ahk_class iTunes[/code]
Back to top
Mattimeo84
Guest





PostPosted: Fri Nov 28, 2008 5:56 pm    Post subject: Reply with quote

Hey there, i am very new to AHK.

in itunes 7, if you open itunes while holding the shift key, you can change libraries.

is there a way to have AHK do this when i hit F12?
Back to top
Mattimeo84
Guest





PostPosted: Sun Nov 30, 2008 2:45 am    Post subject: Reply with quote

Mattimeo84 wrote:
Hey there, i am very new to AHK.

in itunes 7, if you open itunes while holding the shift key, you can change libraries.

is there a way to have AHK do this when i hit F12?


had alot of help (thanks Krogdor & Frankie)

Code:
F12::
Run %A_ProgramFiles%\iTunes\itunes.exe
Send {Shift Down}
WinWait, iTunes ahk_class iTunesCustomModalDialog
Send {Shift Up}
Return
Back to top
theKid
Guest





PostPosted: Wed Jan 07, 2009 12:00 am    Post subject: Reply with quote

doarc's script is perfect, except it needs something to allow to you play the song w/ the keyboard once you've searched for it
Back to top
TylerJames
Guest





PostPosted: Mon Jan 12, 2009 6:24 am    Post subject: Reply with quote

theKid wrote:
doarc's script is perfect, except it needs something to allow to you play the song w/ the keyboard once you've searched for it


Indeed.


By the way, may i recommend using Cd art using Kaelri's Enigma theme. Creates an easy way to basically embed itunes info on your desktop intrusively.

http://www.cdartdisplay.com/index.php?categoryid=13
http://kaelri.deviantart.com/art/Enigma-103823591

use those to get something like this (which also has a seperate, unrelated backround and a bit of object dock):

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4  Next
Page 3 of 4

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group