Is it possible to check whether client's filemaker is in background but still open?

For example, a client opened a layout in filemaker file, and then he started working on another software in his computer but left the filemaker layout open in background. Can we use some scripts to detect this behavior?

2 Likes

Not from inside FM because it requires a background process that has access to all app windows and their state.

What's your end-game? What problem are you trying to solve?

I have a dashboard layout that contains a lot of summary fields to track and summarize depending on records status. Every time the summary fields update, a dialogue showing "fields summarizing..." pops up even filemaker is in background. This can become annoying if the client is working on something else on his computer. I already added a button on that layout to easily hide or show all the summary fields with a single click, but I want to find a solution to make it fully automatic. I realized this morning that maybe "install timer script" would do the trick, that's why I'm posting this question. Any thoughts on how to make that summarizing update go background?

Frank, welcome to ‘the soup’.

Your problem is the summary fields rather than needing to check within the OS. I’ve started a thread ‘Summary Fields - Never Again’ recently.

I will create a demo file, hopefully in the next week (we are overwhelmed with work at the moment) that potentially may help, maybe with a bit of creative thinking and help.

Currently sitting outside a tent in a field in the sun to escape the ‘mouseface’, so this will be next week.

Kind regards

Andy

Hi Andy, I have checked your post actually, but to me, it seems too many steps to kill the annoying popup window. Anyway, I'm still looking forward to check out your demo file. Thanks!

If you have MBS FileMaker Plugin installed, you can query MBS( "Process.IsFrontMost" ) to learn whether FileMaker is in background or in foreground.

Use Process.SetFrontMost and then Window.Activate to move FileMaker and the window to the front.

1 Like

None of that will solve the issue I'm afraid. As @AndyHibbs mentions: get away from the summary field use and find a way to set its value statically, as part of the workflow. Your system will become a lot more performant in the process.

1 Like

Lots of ways to get process information.

In Java 9+, you can do this (with the new ProcessHandle Interface):

https://docs.oracle.com/javase/9/docs/api/java/lang/ProcessHandle.html

public static void main(String[] args) {
    ProcessHandle.allProcesses()
            .forEach(process -> System.out.println(processDetails(process)));
}

private static String processDetails(ProcessHandle process) {
    return String.format("%8d %8s %10s %26s %-40s",
            process.pid(),
            text(process.parent().map(ProcessHandle::pid)),
            text(process.info().user()),
            text(process.info().startInstant()),
            text(process.info().commandLine()));
}

private static String text(Optional<?> optional) {
    return optional.map(Object::toString).orElse("-");
}

In Java 8 (the version FMS is still stuck on), you can do this:

Linux/Mac:

try {
    String line;
    Process p = Runtime.getRuntime().exec("ps -e");
    BufferedReader input =
            new BufferedReader(new InputStreamReader(p.getInputStream()));
    while ((line = input.readLine()) != null) {
        System.out.println(line); //<-- Parse data here.
    }
    input.close();
} catch (Exception err) {
    err.printStackTrace();
}

Windows:

Change Process line to:

Process p = Runtime.getRuntime().exec
    (System.getenv("windir") +"\\system32\\"+"tasklist.exe");

Whip this code up in a little micro-service (free) and you have a cross-platform (non FileMaker ONLY -- ANY HTTP capable application can use your micro-service!) way to get process info! :slight_smile:

If FileMaker is running, it will have at least one "pid" entry in the list.

HTH

Happy Coding!

6 Likes