Hi there. I’m still kind of new to scripting with Ruby. I have
written a small Ruby/Fox app that displays a message in a window at
regular intervals. The ‘regular intervals’ part is done using the
Windows Task Scheduler.
I’d like only one message window to appear at a time though. What I
am seeing is that if I step away from my computer for a few hours,
there can sometimes be several of these popup windows on the desktop.
I’d like the app to check (when it first starts up) to see if there
are any other instances of this popup window on the desktop, and if
so, just exit… or maybe kill the other window’s process (I haven’t
decided which yet).
May be it’s better to try another way:
- Check that some file is being open or exists
- Using Win32 API you can register unique objects that another instance
of your application is running (as far as I can remember they called
“atoms” in MSDN) - … and so on.
Finding a window isn’t the only and the best way to check if you are
already running some process (it’s platform dependent and there can be
another window with title ‘foo’).