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 and AutoHotkey
Goto page Previous  1, 2, 3  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
TheLeO



Joined: 11 Jun 2005
Posts: 264
Location: England ish

PostPosted: Tue Aug 04, 2009 8:35 pm    Post subject: Reply with quote

Hey,

Great script.

I'm trying to use bits of it for an script I'm working on, iTunes auto Lyric finder. I.e fill in the lyrics from all of your tracks in your libary by using wikilyrics.

I need to be able to retrieve the song name and artist from the selected song (as oppose to the current playing song),, do you know how I can do that?

I got this far:
The below would retrieve the current song:

Code:


;- First we need to initilize com+ and add iTunes as the object.
COM_Init()
iTunesApp := COM_CreateObject("iTunes.Application")  ;Create the object
If (iTunesApp = 0)
  {
   MsgBox, 262160, dude `, please open up iTunes. Cheers.
   GoSub, PleaseExitApp
  }
iTunesConn := COM_ConnectObject(iTunesApp, "iTunes_")


  getTrackName   := COM_Invoke(COM_Invoke(iTunesApp, "Track"), "Name")
  getTrackArtist   := COM_Invoke(COM_Invoke(iTunesApp, "Track"), "Artist")
 
MsgBox, %getTrackName%  %getTrackArtist%

;+ sean's com+ library: http://www.autohotkey.com/forum/topic22923.html



now,,, how do I get the selected field...


Also, would you happen to know if it's possible to fill in the Lyrics field without making the script do clicks?
thank you very much.

Leo.
_________________
::
I Have Spoken
::
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
wrecklass



Joined: 19 Mar 2007
Posts: 29

PostPosted: Sat Aug 29, 2009 8:41 pm    Post subject: Reply with quote

I suspect this is no longer supported since I see the author no longer posts here. Still I wonder if anyone has fixed the crash bug where this script crashes AutoHotkeys whenever a podcast is selected from within iTunes.

I tried the pre-compiled version on the other site that was pointed to here, and it has the same bug.

Unfortunately the app crashes without giving any information about where in the script it is a the time of the crash. It makes this great script unusable for me as I listen to a lot of podcasts.
Back to top
View user's profile Send private message
wrecklass



Joined: 19 Mar 2007
Posts: 29

PostPosted: Sun Aug 30, 2009 8:11 pm    Post subject: Reply with quote

If anyone else is curious, after some debugging of my own I found the issue. My simple fix was to comment out lines 963 & 964:

; COM_Release(Duration)
; COM_Release(Position)

My guess is that these objects are being used when the release is performed so they lead to an App Crash. With these commented out I have had no further crashes of the script. It's entirely possible that not releasing these will cause a slow memory leak, but I can live with that while listening to iTunes.
Back to top
View user's profile Send private message
ophthalmos



Joined: 17 Jun 2008
Posts: 19
Location: Kiel, Germany

PostPosted: Wed Sep 02, 2009 12:25 pm    Post subject: crashes when a podcast is chosen Reply with quote

Another solution is to enlarge the variable's holding capacity of the COM_Release function as followed:

Code:
COM_Release(ppv)
  {
  VarSetCapacity(ppv, 64)  ; added by Ophthalmos
  Return   DllCall(NumGet(NumGet(1*ppv)+8), "Uint", ppv)
  }
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Wed Sep 02, 2009 12:46 pm    Post subject: Reply with quote

Duration and Position are not COM objects, but are simply numbers. So, must not apply COM_Release to them.
And, VarSetCapacity(ppv, 64) will set ppv to Null, so no real COM objects will be released, i.e., will leak memory, so don't do it.
Back to top
View user's profile Send private message
ophthalmos



Joined: 17 Jun 2008
Posts: 19
Location: Kiel, Germany

PostPosted: Wed Sep 02, 2009 2:25 pm    Post subject: COM_Release Reply with quote

Wow! How quickly the clarification! Thank you, Sean!
Back to top
View user's profile Send private message
ophthalmos



Joined: 17 Jun 2008
Posts: 19
Location: Kiel, Germany

PostPosted: Wed Sep 02, 2009 2:57 pm    Post subject: COM_Release Reply with quote

I think the same applies to the following variables, which represent only numbers.

    Rating => COM_Release(getRating)
    SoundVolume => COM_Release(PlayerVol)
    Size => COM_Release(getSize)
    SampleRate => COM_Release(getSampleRate)
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Thu Sep 03, 2009 2:27 am    Post subject: Reply with quote

Yes, I saw COM_Release was mis-used in many places, while being not used at all when necessary. For example, the following will create IITBrowserWindow object intermediarilly but it was never released.
Code:
COM_Invoke(COM_Invoke(iTunesApp, "BrowserWindow"), "Maximized", "True")

which can be replaced safely with
Code:
COM_Invoke(iTunesApp, "BrowserWindow.Maximized", "True")
Back to top
View user's profile Send private message
ophthalmos



Joined: 17 Jun 2008
Posts: 19
Location: Kiel, Germany

PostPosted: Thu Sep 03, 2009 7:47 pm    Post subject: Version 2.1 Reply with quote

Thank you for proofreading. I've made the corrections and uploaded the new version (with some new features).
Back to top
View user's profile Send private message
myrison
Guest





PostPosted: Thu Sep 10, 2009 3:40 pm    Post subject: Broken in iTunes 9? Reply with quote

This script appears to be broken by iTunes 9. Does anyone know what needs to be edited to make it function with the new release?

The error invoked is from this line of code:

Code:
    lng_NoiTunes = Could not locate iTunes!`nApplications exits.

And appears to be triggered here:

Code:
COM_Init()
iTunesApp := COM_CreateObject("iTunes.Application")  ;Create the object
If (iTunesApp = 0)
  {
   MsgBox, 262160, %ScriptName% %ScriptVersion% %lng_4iTunes%, %lng_NoiTunes%
   GoSub, ExitSub
  }


I'm sure this is an easy fix, but I don't know enough about the code to resolve myself. Hopefully someone can help!

Thanks,

Jason
Back to top
ophthalmos



Joined: 17 Jun 2008
Posts: 19
Location: Kiel, Germany

PostPosted: Fri Sep 25, 2009 2:06 pm    Post subject: broken in iTunes 9 Reply with quote

I have no problems with the latest version of iTunes under Win XP (32bit) and Vista (64bit).
The script terminates only the first time, when the disclaimer is shown or the database converter is active.
Back to top
View user's profile Send private message
wrecklass



Joined: 19 Mar 2007
Posts: 29

PostPosted: Fri Sep 25, 2009 9:29 pm    Post subject: Reply with quote

The new script is nice, but has a number of problems:

1) The new option to not start playing when iTunes is launched causes the Album info to never be loaded. In fact even if you start a track playing, it will show the Artwork as missing. Fixed this be changing the code that checks this option to start and pause playback when starting up:

Code:
If iTPlay
    COM_Invoke(iTunesApp, "Play")
Else
{
    NoPlayStart = 1
    COM_Invoke(iTunesApp, "Play")
    COM_Invoke(iTunesApp, "PlayPause")
}

Also, just because I want iTunes to have the browser open when I launch it, does NOT mean I want iTunes to be maximized. So I changed this to false in the file. Some people may like that behavior, but I find it annoying.
Back to top
View user's profile Send private message
ophthalmos



Joined: 17 Jun 2008
Posts: 19
Location: Kiel, Germany

PostPosted: Sat Sep 26, 2009 6:31 am    Post subject: Reply with quote

Dear wrecklass,
many thanks for the feedback and suggestions. I updated the script. See my first post.
Back to top
View user's profile Send private message
ramel
Guest





PostPosted: Mon Oct 19, 2009 9:41 am    Post subject: Changing the hotkeys? Reply with quote

I have a multimedia keyboard and I want to use the play/pause buttons on it to control iTunes. How can I change the script to do so?
Back to top
ophthalmos



Joined: 17 Jun 2008
Posts: 19
Location: Kiel, Germany

PostPosted: Mon Oct 19, 2009 10:28 am    Post subject: media keys Reply with quote

The script is already using media keys. However, only together with the modifier keys.
You can search for "Media_" to find (and to modify) the corresponding lines.


Last edited by ophthalmos on Wed Oct 21, 2009 3:27 am; edited 1 time in total
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
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