Support
All support resources for our products. Here you can find answers to frequently asked questions, discuss with other users, recover a lost license code or file a support request.
Forum closed
This forum was closed and turned into an archive effective April 21, 2018. It is no longer possible to create new topics or reply to existing topics.

Thanks everyone for all the great questions and contributions over the years.

Please use the Contact form to get in touch.

Remote Buddy Forum

Overview 

AuthorThread
User

30.08.2006 23:33:30
Interactive Behavior/Action using UI scripting

This posting is older than 6 months and can contain outdated information.
Felix,

I would propose you to reconsider the current, tedious way of entering actions step-by-step in Behaviour Factory. With UI scripting, RemoteBuddy could "read" a front application's available menu's and GUI elements, present those onscreen in its own format, and thus control apps exactly as the Mac UI does. 
As known, UI scripting is not ALWAYS without problems but in these cases step-by-step action editing can come in.

Please find enclosed the following script that illustrates how to interactively "read" UI elements and emulate selections - as RB could do. 
I would suggest to introduce such an option into RB's initial Behaviour dialog. 
This will certainly facilitate interfacing with always new and updated applications on our disks !

Regards, 
Eelco Houwink

_________

tell application "System Events" 
set fApp to name of some application process whose frontmost is true and background only is false 
set Appz to name of application processes 
tell application fApp 
activate 
set appn to choose from list Appz with prompt "Select app" OK button name "OK" 
end tell 
if appn is false then return 
set targName to item 1 of appn 
set theApp to targName 
set mainTarget to application process targName

repeat 
set fApp to name of some application process whose frontmost is true 
tell process fApp to activate 
set UIlist to (get mainTarget's UI elements) 
set UInames to {} 
repeat with h from 1 to number of items in UIlist 
try 
set name1 to (get name of item h of UIlist) 
if name1 = "" then set name1 to ("itempje " & h) as string 
on error 
set name1 to (class of item h of UIlist & " " & h) as string 
end try 
set UInames to UInames & {name1} 
end repeat 
if UInames = {} then exit repeat 
if number of items of UInames = 1 then 
set selname to item 1 of UInames 
else 
set selname to (choose from list UInames with prompt "UI elements of \"" & targName & "\": " default items 1 OK button name "Browse") as string 
if selname is "false" then exit repeat 
end if 
set itemNo to my getIndex(selname, UInames) 
set mainTarget to item itemNo of UIlist 
try 
set targName to name of mainTarget 
if name of mainTarget = "" then set targName to fApp 
on error 
set targName to fApp 
end try 
end repeat 
end tell 
repeat until fApp = theApp 
tell application theApp to activate 
tell me to do shell script "sleep 1" 
tell application "System Events" to set fApp to name of some application process whose frontmost is true 
end repeat 
tell application "System Events" to click mainTarget

on getIndex(i, l) 
repeat with n from 1 to count l 
if l's item n is i then return n 
end repeat 

end getIndex

Last edited: 31.08.2006 00:16:12 

These entries from the FAQ may be relevant to this topic:

Behaviours
Hardware - Apple® Remote
Thread-display::