Alert when mouse is disconnected.

Is there a way to make a script that will alert that a mouse has been disconnected?

Thanks,
SWeeT

Model: iMac
AppleScript: 1.9
Browser: Safari 85.8.1
Operating System: Mac OS X (10.2.x)

I thought this was an interesting question. The solution seems to be in the ioreg command. On my machine, a G5 Dual 10.4.5, a slight change in the output of the ioreg command occurs when I unplug the mouse. With the mouse plugged in I see the line:

| | | | | | “HIDDefaultBehavior” = “Mouse”

When the mouse is unplugged this line is gone.

So:

set the_script to “ioreg -l | grep ‘"HIDDefaultBehavior" = "Mouse"’”
do shell script the_script
–do stuff you want when the mouse is plugged in
on error
–do stuff you want when the mouse is unplugged

IIRC ioreg outputs can differ on different machines, so your results may vary.

Andy

Browser: Safari 412
Operating System: Mac OS X (10.4)

On a dual-core G5/2.3 10.4.5, it works a treat, tugboat666

Thank you for the help =) I am not very good at using AppleScript (just the basics, really) and this is a great start for me =) Hopefully I can figure the rest out. I am really glad it is possible and thanks again for helping me =)

Connie

Would one of you be willing to help me some more?

Model: iMac
AppleScript: 1.9
Browser: Safari 85.8.1
Operating System: Mac OS X (10.2.x)

The whole board is willing to help, Connie. Post another question in another thread (this one is answered).

Okay, I will work on it today and then if I can’t figure it all out I will ask later. Thanks =)

I had a question about this script. I typed it in and receive an error on the word “error”

Syntax Error
Expected function name, command name or function name, but found “error”

Now, I used to be comfortable coding Applescript for OS9, but the transition to OSX left me a bit confused. Now I’m just rusty and trying to bone up on it all again. If I copied and pasted the script exactly as you typed it, why would I receive that error at “on error”?

I got that error too. I posted a new thread because this one has been answered. Here is the reply. I haven’t gotten to try it yet.

http://bbs.applescript.net/viewtopic.php?id=16223