Go Back   The macosxhints Forums > OS X Help Requests > Applications



Reply
 
Thread Tools Rate Thread Display Modes
Old 11-30-2012, 09:16 PM   #1
ppayne
Prospect
 
Join Date: Jan 2007
Posts: 25
Need help making iTunes auto update iOS apps

Managing all my iOS app updates has started to become a chore, and my goal is to make iTunes automatically update all apps that need updating so they're automatically pushed out to my iPhone and iPad at the next update. Sadly Apple has not given us any clear way to automatically update iOS apps either by Applescript nor by clear menus or keyboard shortcuts, so I appear to need to do it with UI scripting, the bane of poorly designed Mac software.

There are several options, including fiddling with Applescript, but Keyboard Maestro is what I'd like to use I think. The problem is, other than setting the screen to a set size and clicking the point where I know the "Update apps" button to be, I can't think of a way to reliably access that button.

Another option is Automator, which I tend to dislike using for some reason, maybe because it makes me feel like a noob. I can make an action that loads iTunes and clicks the appropriate "Update apps" button at the bottom of the screen, but the fact that this button's value can change (now it says "2 Updatable Apps" instead) seems to break Automator.

So my question, I guess, how can I script the clicking of the "Update now" button in the iTunes 11 apps tab as reliably as Automator can do it? If anyone has any suggestions on how to proceed it'd be great. Also if I'm missing any way to update apps directly using Applescript that's be awesome too, though I can't find any support for what I want to do in the dictionary.
ppayne is offline   Reply With Quote
Old 12-01-2012, 05:56 PM   #2
sojourner
Major Leaguer
 
Join Date: Apr 2010
Posts: 324
I don't have apps, and no "update apps" button, so I'm explaining this blind. Plus, I'm running Lion, so if your OS varies, so may your results. I hope that I'm giving enough info so that you can craft something that works. I'm also being more verbose in my explanation and the code, so that it's (I hope) more understandable for you and other users.

Running something like the following script in AppleScript Editor will return results which can supply clues as to how to refer to the UI element you want to act upon:

Code:
tell application "iTunes" to activate

tell application "System Events"
	tell application process "iTunes"
		tell window "iTunes"
			entire contents
		end tell
	end tell
end tell
This gives a long list of text in the results window. One item in the results is
Code:
static text "Apps" of row 8 of outline 1 of scroll area 1 of splitter group 1 of window "iTunes" of application process "iTunes" of application "System Events"
(Note that your results may be different, depending on what you've elected to show in iTunes > General Preferences.) Static text UI elements usually are exactly that: text which is non-interactive. But this static text is in row 8, and the item before that is
Code:
row 8 of outline 1 of scroll area 1 of splitter group 1 of window "iTunes" of application process "iTunes" of application "System Events"
Rows can be interactive, and we can find out more about this one using the following:

Code:
tell application "System Events"
	tell application process "iTunes"
		tell window "iTunes"
			tell row 8 of outline 1 of scroll area 1 of splitter group 1
				properties
			end tell
		end tell
	end tell
end tell
One result item shows that selected is true, and we can use that to make sure that iTunes selects this row before attempting to click the updatable apps button.

To find the updatable apps button (I hope there's only one), use something like:

Code:
tell application "iTunes" to activate

tell application "System Events"
	tell application process "iTunes"
		tell window "iTunes"
			-- select Apps section in Library
			tell row 8 of outline 1 of scroll area 1 of splitter group 1
				select it
			end tell
			
			-- click updatable apps button
			tell group 1 of splitter group 1
				set listButtonsUpdatableApps to (every button of it whose name contains "updatable apps")
				set buttonUpdatabaleApps to item 1 of listButtonsUpdatableApps
				click buttonUpdatabaleApps
			end tell
		end tell
	end tell
end tell
UI scripting can be such a pain. Explaining it even more cumbersome. The biggest reward is the time you save once you've gotten the script working.
__________________
see a problem; solve a problem.
sojourner is offline   Reply With Quote
Old 12-01-2012, 10:33 PM   #3
ppayne
Prospect
 
Join Date: Jan 2007
Posts: 25
Thanks for the reply, this is helpful. Unfortunately the script to get the "entire contents" of the UI times out after 2-3 minutes. Is there any other way to get this information dumped that you can think of?
ppayne is offline   Reply With Quote
Old 12-02-2012, 02:06 AM   #4
NaOH
Hall of Famer
 
Join Date: Dec 2007
Posts: 3,642
Two points which aren't exactly direct answers to the original question. For one, getting the apps in iTunes beforehand isn't necessary for syncing. Plus, if you're running iOS 6 on the iPhone and iPad you can update the apps on the devices in three taps per device: Tap the App Store icon, tap the Updates section, Tao the Update All button. When you do sync, iTunes will grab newer app versions from the devices. In a sense, apps on a Mac (or PC) are essentially backups of what you can freely re-download from the App Store if you need to, not to mention the apps are part of device back ups to either your Mac or iCloud (depending upon which backup system you've chosen).

But out of curiosity, I set up a solution to this using Keyboard Maestro. Yes, that's US $36 software, but it took me about two minutes to configure a macro to handle this, and sojourner is spot-on in noting that GUI scripting is difficult to configure.

Considering your interest in automating this activity, you may have other uses for Keyboard Maestro, and they border on the limitless because the software is so flexible in what it allows you to do. So I figured I'll point out this option.

Anyway, the picture shows the macro I created. A keyboard shortcut starts things, though this could be launched in a number of other ways. iTunes activates, then the macro switches iTunes to the Apps section (⌘-7), presses the Tab key once to select the button which shows available updates, then activates that button by pressing the Space Bar. From there, it's just a couple instructions which move the mouse to where the Download All Updates option is always shown and clicking in that spot.

If I were actually using this, I would make a couple adjustments beyond what's shown in the picture.
  1. I would add a delay after telling iTunes to activate in case it isn't already running. Without that, the actions of moving through the app-update process would be invoked before iTunes is ready to accept them. A one-minute pause would be ample.
  2. My iTunes setup is such that I must always enter my password when I download updates, so that would have to be addressed either with Keyboard Maestro typing (or pasting) it in or by changing that requirement within iTunes settings.
  3. Some updates elicit an age-restriction warning, but Maestro can easily be configured to handle that as well. The warning always appears within a few seconds, so Maestro could be told to wait just a pinch, then see if there's a dialog with an OK button to press and, if so, press it.
  4. I sync my iPhone with iTunes twice a year. Maybe. If I were doing it regularly and having Maestro update my apps, then I would consider having this macro run on a set schedule instead of a keyboard shortcut.

If you do decide to give Keyboard Maestro a try (there is a 30-day trial), just post if you have any questions about using it or setting up a macro for this.
Attached Thumbnails
Click image for larger version

Name:	Keyboard Maestro And App Updates.jpg
Views:	50
Size:	67.6 KB
ID:	4606  
NaOH is offline   Reply With Quote
Old 12-02-2012, 01:06 PM   #5
sojourner
Major Leaguer
 
Join Date: Apr 2010
Posts: 324
I've used with Keyboard Maestro. It's on my buy list, as it is an easy to use program that can do some fairly complex things. Not only does can it make UI scripting less of a pain, it has a number of other features that puts it on my buy list. I would definitely recommend taking it for a test drive if you have any doubts about buying it. The trial period is more than fair.

If you want to continue with the UI scripting, I am curious about your timeout issues. It's odd that it would take so long. Which OS are you using?
__________________
see a problem; solve a problem.
sojourner is offline   Reply With Quote
Old 12-02-2012, 06:16 PM   #6
acme.mail.order
League Commissioner
 
Join Date: Sep 2003
Location: Tokyo
Posts: 6,046
Quote:
Originally Posted by ppayne
Sadly Apple has not given us any clear way to automatically update iOS apps either by Applescript nor by clear menus or keyboard shortcuts

Yes, they have. There's a "Download all updates" button in both iTunes and the device's App Store. There's also an "Always check for available downloads" option in iTunes preferences.

You seem to want a "just do it in the background" option - such a feature wold be unreliable on anything except a desktop with a permanent internet connection, and you would complain about it if the system was downloading some giant update at the same time you are trying to watch streaming video.
acme.mail.order is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 09:06 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.