How to press a button in a Finder window
How to press a button in a Finder window
- Subject: How to press a button in a Finder window
- From: Doug McNutt <email@hidden>
- Date: Sat, 31 Jan 2004 15:15:21 -0700
I could sure use a bit of sample code that pokes a button in a Finder window.
I am opening a Finder window on a mounted server and I want it to appear in the classic mode. Finder doesn't remember my settings for the remote window and I'm trying to script it.
This script works. It's waits around around as a startup APPL until a shell script mounts several volumes on the server using mount_afp calls when I login.
*********
property thebounds : {184, -444, 568, -11} -- the window is above the startup monitor.
tell application "Finder"
try -- Pick up new bounds property if not starting up
set thebounds to bounds of window "Transfer"
close window "Transfer"
end try
set jill to 20
repeat while jill > 0
set worked to true
try
open ":Mimas:Transfer" -- This is on my SE/30 server
on error
do shell script "sleep 5"
set worked to false
set jill to jill - 1
end try
if worked then
set bounds of window 1 to thebounds
exit repeat
end if
end repeat
end tell
*********
The problem is that the window uses up most of the space with stuff at the left and top that I don't want. I can click the little button at the top right but that shrinks the window and I have to move it manually. I want to click the button within the script and then locate the window where I want it.
*********
From the UI Inspector
Cursor is over the button at the right top of the window.
It's the one that hides all of the OSX stuff.
<AXApplication: "Finder">
<AXWindow: "Transfer">
<AXButton>
Attributes:
AXRole: "AXButton"
AXRoleDescription: "button"
AXSubrole: "AXToolbarButton"
AXChildren: "<array of size 0>"
AXParent: "<AXWindow: "Transfer">"
AXWindow: "<AXWindow: "Transfer">"
AXPosition: "x=548 y=-472"
AXSize: "w=20 h=13"
AXEnabled: "1"
Actions:
AXPress - press
*******
Last iteration of the kind of thing I would like to add
Probably has too many tells this way.
I think I have tried everything except asking with a "pretty please"
tell application "Finder"
activate
end tell
tell application "System Events"
tell process "Finder"
tell window "Transfer"
tell "AXTOOLbarButton"
tell "AXButton"
press -- fails here, "variable press is not defined."
end tell
end tell
end tell
end tell
end tell
*******
--
--> There are 10 kinds of people: those who understand binary, and those who don't <--
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.