AutoHotkey Community

It is currently May 26th, 2012, 10:33 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 81 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Author Message
 Post subject:
PostPosted: August 31st, 2007, 9:41 pm 
Offline

Joined: August 31st, 2007, 9:08 pm
Posts: 3
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: mad props
PostPosted: November 8th, 2007, 1:02 am 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 14th, 2007, 6:31 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2008, 12:09 am 
Offline

Joined: November 25th, 2007, 7:33 pm
Posts: 3
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
}


Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 1st, 2008, 1:33 am 
Offline

Joined: March 13th, 2008, 2:48 pm
Posts: 6
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


Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 11th, 2008, 5:08 pm 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 23rd, 2008, 10:51 pm 
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?


Report this post
Top
  
Reply with quote  
 Post subject: About the first script
PostPosted: August 11th, 2008, 4:53 am 
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 ;)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 15th, 2008, 5:36 pm 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 11th, 2008, 2:23 pm 
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()


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 26th, 2008, 2:26 am 
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]


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 28th, 2008, 5:56 pm 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 30th, 2008, 2:45 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 7th, 2009, 12:00 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 12th, 2009, 6:24 am 
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):

Image


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 81 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Exabot [Bot], Stigg and 7 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group