I’m new to applescript but have lots of experience with other programming and scripting languages. I’m a Logic user, and would very much like a script that starts Logic when the USB “xskey” device is connected to a USB port of my Powerbook.
Is there a hardware device event monitoring application I can run to spot what happens when the xskey is connected, and trigger the application launch from that event, or is there a simpler way?
A good application, but the logic xskey doesn’t have any storage on it, so it doesn’t get mounted as a volume when connected. How else can I detect when it has been connected?
I was thinking that there might be a unix way to get the usb status. If there is none, then you can use the Apple System Profiler. It takes a while to get all the data. Once you get the data, you can just get the offset of whatever the device is called. If it finds the name of the device in the text, then the device is connected. Otherwise it will return 0 and the device is not connected.
set device_name to “Studio Mouse Wireless”
tell application “Apple System Profiler”
activate
with timeout of 1000 seconds
set sys_profile to (system profile)
end timeout
quit
end tell
set dstatus to (offset of device_name in sys_profile)
if dstatus is 0 then
– device not connected
beep 2
else
– device connected
beep 3
end if
You need to check out the name of the usb device first and make sure it doesn’t occur elsewhere in the text.
The application “peripheral vision” appears to monitor most i/o ports, perhaps it can handle what you’re doing. It says it can trigger apps, applescripts, or unix scripts when a usb device is connected.
OK, I just set it up and configured it to run an “application bundle” script when I plugged in my mp3 player (which does not show up on the desktop when I plug it in). I tried it with a plain script and got an error, so I saved as an app bundle… but perhaps that was just a glitch. It runs as a preference pane in the system preferences, and is pretty configurable (if you register). Seems pretty cool, and may be worth the few bucks to register if you really need this feature.