Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Clive At Five

macrumors 65816
Original poster
May 26, 2004
1,439
-1
St. Paul, MN
I'm building a keyboard & mouse-less HTPC. I need to make "DarwiinRemote" search for a Wiimote recursively on startup or I won't be able to control the damn thing at all...

Goals:

1) Detect whether Bluetooth device "Nintendo RVL-CNT-01" is connected.
2) If not, activate DarwiinRemote and click "Find Wiimote". Pause for a few seconds, loop to #1.
3) If connected, hide DarwiinRemote and end loop...

Have I have:

tell application "System Preferences"
activate
set current pane to pane "com.apple.preferences.Bluetooth"
end tell
tell application "System Events"
if UI elements enabled then
try
tell application process "System Preferences"
tell group 1 of window "Bluetooth"
set selected of row 2 of table 1 of scroll area 2 to true --NOT the prefered way to select this but I can't seem to search for a table item by name.
delay 5
if menu item "Connect" of menu 1 of menu button "Perform tasks with the selected device" of group 1 of window "Bluetooth" exists then -- Not working: Jumps to "else".
--device is not connected
tell application "DarwiinRemote"
activate
--(click button "Find Wiimote" of window "WiiRemote Event Log") <-- this fails for some reason
end tell
else
--Device is connected
display dialog "Connected"
tell application "System Preferences" to quit
end if
end tell
end tell

tell me to activate
on error
tell me to activate
display dialog "An error has occurred... moron." buttons {"Whoops!"} default button 1
end try
else --GUI scripting is disabled
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.universalaccess"
end tell
display dialog "Please check the box called \"Enable access for assistive devices.\"" buttons {"Okay"} with icon 1 default button 1
end if
end tell

Any help is appreciated!

Thanks,

-Clive
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.