Detecting whether FM Pro is "front" application

Notes on our latest calendar for FileMaker 13,: DayBack
Posts: 66
Joined: Wed Nov 27, 2013 5:51 am
PostPosted: Sat Jun 02, 2018 6:23 am
I have a setup with both "schedulers" and "clinicians." The former schedule patients in one location for clinicians who are in many locations. My modified version of Dayback is hosted by Datatrium.

I've set things up such that when a scheduler makes a change to a clinician's schedule for the current week, it sets a flag. Instances of the Calendar run by clinicians periodically check the flag with a timer script. If a schedule change is flagged, that clinician's instance of Dayback refreshes itself (and resets the flag). That way, changes made by schedulers automatically appear on clinicians' calendars.

However, I suppress the refresh if the DayBack Calendar window is not front-most FM Pro Window, so the refresh doesn't push the DayBack solution window to the front and interrupt the clinician, who may be viewing an event window, a contact list, etc.

My problem: If I switch to another application entirely (say, Word) and a refresh is called for, FM Pro pushes itself to the front and interrupts use of the second application. This happens both on Mac and Windows.

Ideally, I'd like Dayback to refresh itself while remaining in the background. Alternatively, I'd like to determine whether FM Pro is the foreground application and suppress the refresh if it is not. I haven't found a way to do either.

Thoughts?
SeedCode Staff
SeedCode Staff
Posts: 357
Joined: Tue Nov 08, 2016 1:54 pm
PostPosted: Mon Jun 04, 2018 10:56 am
Hi wsmiii,

That's a very interesting question. As far as refreshing the calendar in the background, this really isn't possible since we need to re-load the WebViewer and it needs to be in focus in order to do that. You could, however, save the active window as a global variable so that, once the "Query Events From FileMaker" script is completed, you can set the focus back to that original window.

Since what you're referring to with the system windows is really outside of the context of FileMaker, it sounds like you'd need to make some custom scripts to run (in the system context, so not FileMaker scripts), depending on which version of the operating system that is running. You could call these scripts to see if the "focused" window is FileMaker before then checking if the Calendar interface window is on top.

You can call system scripts from within a FileMaker script by using the "Send Event" method: http://www.filemaker.com/help/14/fmp/en ... 5.170.html

If you do decide to dive into this, here are some forum posts that might help you on your quest to write these scripts:
https://stackoverflow.com/questions/160 ... he-mac-osx
https://gallery.technet.microsoft.com/s ... r-352fa957

Hope that helps!

Regards,

KC

Return to DayBack Calendar for FileMaker

Who is online

Users browsing this forum: No registered users and 5 guests

(855) SEEDCODE
[email protected]
Follow us: