G+_Travis Decker Posted December 22, 2013 Share Posted December 22, 2013 I want to write a windows based script for itunes, however I have never written a script or know how to run one. Can someone give me some pointers? Simple script: At X time, open itunes movie list, where kind = "Protected MPEG-4 video file" individually select the first file, choose "get info" then "Okay", then move to the next file and repeat. I have set custom genre's on my purchased video files and apple keeps overwriting them, so I thought a automated script would be a useful work around for those dealing with this issue. Any help is appreciated!! Link to comment Share on other sites More sharing options...
G+_Vincent Tompkins Posted December 23, 2013 Share Posted December 23, 2013 Do you have any preferences as to which script language to use? PERL, Python, Powershell, or JAVA? Link to comment Share on other sites More sharing options...
G+_Travis Decker Posted December 23, 2013 Author Share Posted December 23, 2013 No, I don't know much about any of them so I have no preference to express. :) Link to comment Share on other sites More sharing options...
G+_Nicholas Glenn Posted December 23, 2013 Share Posted December 23, 2013 I'm a fan of JavaScript for writing the script. As far as executing the script, you can use something like Microsoft SQL Server to create a repeating job that calls the link to the script that you write. Link to comment Share on other sites More sharing options...
G+_Travis Decker Posted December 24, 2013 Author Share Posted December 24, 2013 Any good tutorial sites you can point me to for the basics of Java script? Link to comment Share on other sites More sharing options...
G+_Nicholas Glenn Posted December 24, 2013 Share Posted December 24, 2013 I would recommend using http://www.w3schools.com. they have great beginner tutorials on how to code in JavaScript as well as some other popular languages and it is free. Link to comment Share on other sites More sharing options...
G+_Joe Philipps Posted December 24, 2013 Share Posted December 24, 2013 so wait...What do you mean by "open iTunes?" the site or the program? If you mean the site, yes, JS might be a good choice. If you mean the program, AutoIt would be a far better choice. (It's made for controlling other programs.) In fact, I'm not quite sure how Nicholas Glenn would use JavaScript or SQL Server to do ANY of that. (But that's mainly due to my lack of familiarity w/ SQL Server.) As for doing something regularly, or at a specified time, the Task Scheduler service is the facility on Windows which very typically does that.? Link to comment Share on other sites More sharing options...
G+_Nicholas Glenn Posted December 24, 2013 Share Posted December 24, 2013 SQL Server and JavaScript could both be used to open either the Web link or the actual program of iTunes Joe Philipps . I do this at work on a daily basis (just not for iTunes). SQL Server has a functionality built in much like Tasker for your phone which allows you to automate the process and run certain processes at a specified time on whichever days you would pick. JavaScript would be used to write the actual function that would check to see if the genre has been changed or not. In this case though, since Travis Decker is looking at a detail (property) of the files he has, you wouldn't actually need to open iTunes (even though you could if you wanted). You would want to look at the properties of the file in the directory they are being stored and use a simple if/else statement in JavaScript to see if the property has been changed or not. I'm sure there are multiple ways a person could do this, but this is just one example of how this could be done, and it is the most familiar to me as it is what I do everyday at work. I'm not sure that SQL Server is a free program though, so another program may be needed to automate the task if your looking to go the free route. Link to comment Share on other sites More sharing options...
G+_Robert Ilbrink Posted December 24, 2013 Share Posted December 24, 2013 You could have a look at AutoHotKey (http://l.autohotkey.net/), this can do simple things like simulating mouse/keyboard actions based on timing and coordinates and in a more advanced mode, check the status of windows, control windows objects (buttons, etc). For help check the Autohotkey forum at http://www.autohotkey.com/board/ Link to comment Share on other sites More sharing options...
G+_Vincent Tompkins Posted December 24, 2013 Share Posted December 24, 2013 Do you want this to be a stand alone script or browser based? JavaScript is usually run from a browser. Which if needed you can have it launch from an .html page. How much of a programming background do you have? Link to comment Share on other sites More sharing options...
G+_Joe Philipps Posted December 24, 2013 Share Posted December 24, 2013 SQL Server, to my knowledge, is not free. It starts out at about $300 for one version behind (2008), with a "developer's edition" for about $45. In fact, most pricing you will see (a Google search) start at around $1500 for the current product and go all the way up to ten or so thousand dollars for the current (2012) enterprise product. I just don't see the need to buy anything for that purpose when the ability to launch programs on a schedule is built into the Task Scheduler, which comes with Windows. I mean, if this gives the user some gain, some better functionality, I'm all eyes (instead of ears). I'm also with Vincent Tompkins ; JavaScript needs an interpreter (or at the very least a compiler), and the one most people encounter is part and parcel of a Web browser. In that sense, AFAIK, you would need a browser capable of injecting your code into the iTunes page, such as Opera, Chrome, or Firefox+Greasemonkey. I just can't foresee how JS will help you much. Maybe SQL Server provides that interpreter. Something like AutoIt (which has its own BASIC-like scripting language) or as Robert Ilbrink mentions, AutoHotKey, might be more suited to your task. AutoIt can control a program (such as iTunes) and simulate clicks and keystrokes. It even has a compiler which can produce an executable (which you then could in turn presumably launch from Task Scheduler). Just sayin', my advice is to start out with one of these click-n-keystroke-injector programs, like AutoHotKey or AutoIt, and if that won't do what you need it to do, maybe Nicholas Glenn can clue us all in on how to use JS to do it instead. I might add, I don't use iTunes, so I'm just writing theoretically. I must say, I didn't like the UI much. I've only bought one song through it, and basically haven't returned to it. Link to comment Share on other sites More sharing options...
G+_Travis Decker Posted December 24, 2013 Author Share Posted December 24, 2013 I ended up using http://www.jitbit.com/macro-recorder/ I was able to automate the manual workaround with medium success. Every once in awhile it plays the movie instead of updating its info but I will tune it and make it work. This allowed for scheduling as well which was a primary function. Link to comment Share on other sites More sharing options...
G+_Nicholas Glenn Posted December 25, 2013 Share Posted December 25, 2013 Glad to hear that you found a solution that works for you. I'm sure you'll work out the kinks for more than just medium success Link to comment Share on other sites More sharing options...
G+_Travis Decker Posted December 25, 2013 Author Share Posted December 25, 2013 Yeah the macro program is fun, but iTunes being iTunes named all of the popup menu windows and main window "iTunes" so the really nice feature of the macro program that can recognize when a window loads and disappears doesn't work, so the macro has to allow for inconsistent window load times and be all timing based. Link to comment Share on other sites More sharing options...
Recommended Posts