Image Capture and sharing

Hi, totally new to Apple Script and it is not as easy to do some things as I hoped, but this site is proving to be a good learning environment.
I want to be able to load Image Capture on a machine and automatically share the scanner that is attached.
I have got a script to load Image Capture and by using the Keystrokes command, load the preference pane.
In the example I looked at, it then pressed the Alt + Number to change the tabs, but this does not do anything in Image Capture and searching for tabs doesn’t really return any options.
anyone tell me how I can take the preference screen off from “General” and onto “Sharing”.

I guess I’ll be back with more afterwards, but that may help me start off.

Thanks in Advance

Jules

Hi. I think I’m going to feel new to AppleScript for quite a while.

You can work this into your script:


tell application "System Events"
	tell process "Image Capture"
		tell window 1
			tell radio button "Sharing" of tab group 1
				click
			end tell
		end tell
	end tell
end tell

which can be shortened to:


tell application "System Events" to tell process "Image Capture" to click radio button "Sharing" of tab group 1 of window 1

j

Cool. That works and using keystrokes I can now tell it to enable sharing, name the unit, but I am unable to select the scanner.

How do you determine what tab group, or element you need to select ?
I feel if I can fathom that I can modify your reply to do everything I need.

If you don’t already have it, you can download UI Element Inspector here - http://www.apple.com/applescript/uiscripting/02.html

If you lock on an element, a second window opens with additional information.

If there are few UI elements, and especially if only one, I use numbers because there’s less typing. If I’m unsure of a number, I use the name.

Unfortunately, sometimes names and numbers aren’t what they appear to be so guessing or repeating through the elements (see Jacques example here - http://bbs.applescript.net/viewtopic.php?id=17460) becomes necessary.

The inspector’s main window gives this information on the first device’s checkbox:

[i]<AXApplication: “Image Capture”>
<AXWindow: “Image Capture Preferences”>




<AXCheckBox: “”>

Attributes:
AXRole: “AXCheckBox”
AXRoleDescription: “check box”
AXHelp: “(null)”
AXValue: “0”
AXEnabled: “1”
AXFocused (W): “0”
AXParent: “”
AXWindow: “<AXWindow: “Image Capture Preferences”>”
AXTopLevelUIElement: “<AXWindow: “Image Capture Preferences”>”
AXPosition: “x=956 y=359”
AXSize: “w=25 h=32”
AXTitle: “”

Actions:
AXPress - press
[/i]

So to script it:


tell application "System Events" to tell process "Image Capture" to tell checkbox 1 of row 1 of table 1 of scroll area 1 of tab group 1 of window 1 to perform action "AXPress"

Running it a second time will uncheck the box.

j

Many thanks for you help and pointers with this. With the uiinspector and a few other selected searches I got the script to do what I want. Only selects the first device, but hey, that will do. I may modify it to disable other features at some stage.



set DEPT to "<some department / description>"

tell application "Image Capture"
	activate
	tell application "System Events"
		set foremost to true
		keystroke "," using command down
		tell application "System Events"
			tell process "Image Capture"
				if value of checkbox "Share my devices" of tab group 1 of window 1 = 0 then
					tell checkbox "Share my devices" of tab group 1 of window 1 to perform action "AXPress"
				end if
				set value of text field 1 of tab group 1 of window 1 to DEPT
				if value of checkbox 1 of row 1 of table 1 of scroll area 1 of tab group 1 of window 1 = 0 then
					
					tell checkbox 1 of row 1 of table 1 of scroll area 1 of tab group 1 of window 1 to perform action "AXPress"
				end if
				tell button "OK" of window 1 to perform action "AXPress"
				
			end tell
		end tell
	end tell
	
end tell

tell application "System Events" to if "Image Capture" is in name of processes then tell application "Image Capture" to quit