AutoHotkey Community

It is currently May 26th, 2012, 9:29 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 38 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject:
PostPosted: August 4th, 2009, 9:35 pm 
Offline

Joined: June 11th, 2005, 9:34 am
Posts: 264
Location: England ish
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
::


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 29th, 2009, 9:41 pm 
Offline

Joined: March 19th, 2007, 5:12 pm
Posts: 29
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 30th, 2009, 9:11 pm 
Offline

Joined: March 19th, 2007, 5:12 pm
Posts: 29
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.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: September 2nd, 2009, 1:25 pm 
Offline

Joined: June 17th, 2008, 9:03 pm
Posts: 19
Location: Kiel, Germany
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)
  }


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 2nd, 2009, 1:46 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: COM_Release
PostPosted: September 2nd, 2009, 3:25 pm 
Offline

Joined: June 17th, 2008, 9:03 pm
Posts: 19
Location: Kiel, Germany
Wow! How quickly the clarification! Thank you, Sean!


Report this post
Top
 Profile  
Reply with quote  
 Post subject: COM_Release
PostPosted: September 2nd, 2009, 3:57 pm 
Offline

Joined: June 17th, 2008, 9:03 pm
Posts: 19
Location: Kiel, Germany
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)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 3rd, 2009, 3:27 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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")


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Version 2.1
PostPosted: September 3rd, 2009, 8:47 pm 
Offline

Joined: June 17th, 2008, 9:03 pm
Posts: 19
Location: Kiel, Germany
Thank you for proofreading. I've made the corrections and uploaded the new version (with some new features).


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Broken in iTunes 9?
PostPosted: September 10th, 2009, 4:40 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject: broken in iTunes 9
PostPosted: September 25th, 2009, 3:06 pm 
Offline

Joined: June 17th, 2008, 9:03 pm
Posts: 19
Location: Kiel, Germany
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 25th, 2009, 10:29 pm 
Offline

Joined: March 19th, 2007, 5:12 pm
Posts: 29
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2009, 7:31 am 
Offline

Joined: June 17th, 2008, 9:03 pm
Posts: 19
Location: Kiel, Germany
Dear wrecklass,
many thanks for the feedback and suggestions. I updated the script. See my first post.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Changing the hotkeys?
PostPosted: October 19th, 2009, 10:41 am 
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?


Report this post
Top
  
Reply with quote  
 Post subject: media keys
PostPosted: October 19th, 2009, 11:28 am 
Offline

Joined: June 17th, 2008, 9:03 pm
Posts: 19
Location: Kiel, Germany
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 October 21st, 2009, 4:27 am, edited 1 time in total.

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

All times are UTC [ DST ]


Who is online

Users browsing this forum: MSN [Bot] and 15 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