stop loop on user interaction

Hi,

I am quite new to Applescript and would like to do something which seems basic but according to my search on this site not very easy.

I have a loop in a script and would like to exit the loop on user interaction. It could be a keystroke or a mouseclick or whatever. How can this be achieved?

The background is that the script is supposed to read data received from a serial port, process it and write it to a file. The user must be able to stop the recording of this data, write a comment in a dialog that would be inserted into the file and upon another action of the user the script would continue to read the data. Everybody told me that the big issue would be to read the serial port but now it seems that I am stumbling over something so basic.

I searched the web to be able to do this, but it seems not easy with Applescript. I would like to stick with AppleScript because of the Extension SerialPortX.

Any help would be really appreciated.

Dimitri

This is generally really hard/impossible in AppleScript depending on exactly what you want, but too easily done in AppleScript Studio or ASOC.

If this is really the only way…

Since I know neither of them, it will be new for me anyway; so what would you suggest, ASOC or Apple Script Studio? I’ve heard of some trouble with Apple Script Studio after upgrading to Snow Leopard.

Thanks in advance.

Dimitri

That was a wobbly if, I’ve never heard of a remote mouse or keyboard event being received in AS though. An AS dialog being there will prevent a script running. I don’t know about remote events in cocoa, but it’s easiest to do this with a custom dialog in ASOC/Studio. If you have 10.6 your best option is ASOC, 10.5 and below use Studio. ASOC is not runnable on pre 10.6, Studio is runnable throughout, but projects can only be edited (but not built for 10.4) on 10.6, not created, and that’s with a terminal preference change. If you want it to run on OSes below 10.6 use Studio, otherwise ASOC, it is much better.

It should be fairly easy with Xcode anyway.