Jump to content
Server Maintenance This Week. ×

Restoring open windows possible?


This topic is 1820 days old. Please don't post here. Open a new topic instead.

Recommended Posts

i’d bet  you could script this. However, there are a lot of tricky parts. Was the window on a record that’s been deleted? Then what should happen? https://fmhelp.filemaker.com/help/17/fmp/en/index.html#page/FMP_Help%2Fwindownames.html%23

will probably come in handy. Also, you’d need to store the list per user. 

Link to comment
Share on other sites

To be clear, I am not talking about the main window, but about 4 smaller windows that contain other information about the openend record.

I have it now so far as that it's being remembered in a variable when a window is open or closed. When a specific window is being openend, the variable is set to 1 in the open window script. That variable is set to 0 with the script trigger OnLayoutExit of that specific window. The value of this variable is saved in a Preferences table and set to a field when opening or closing the window and this variable is being set again when the program is started, read from the preference field/variable. If it turns out to be 1, then it runs the script to open the window. I used this same methode for other things, like remembering windows positions and open tabs and it works great.

However... the problem here is that if the window is open and I close the database completely, that specific window will also be closed and therefor, the variable will be set to 0 and not being openend when I start the database. Any suggestion at what point I should run the script that puts the variable to 0?

Edited by AndreasvanHaren
Link to comment
Share on other sites

You will need to have a way to store the window locations that persists across FileMaker restarts.

 

An Account table is good for this…either by itself or with a more relational structure:

Account-<Account_Window>-Window

 

When a user quits the system, use the OnLastWindowClose Script Trigger and store each window position as table data using Get (Functions)

http://www.twdesigns.com/filemaker-15-functions-list/

 

When the user logs back in, use onFirstWindowOpen to trigger a script that uses Get (AccountName) to located the saved window settings for that AccountName.

Then use the Windowing scripts steps: New Window, Move/Resize Window, etc. to restore the windows.

 

Link to comment
Share on other sites

9 hours ago, bcooney said:

Instead of storing indicators, why not have an on layout enter trigger that opens  the supporting windows, if they aren’t yet opened? 

The main window has 5 layouts and the supporting windows and the supporting windows could be open at any point. Wouldn't this mean I have to run the same script from every layout? Still, the man problem is: how does the solution remember if a window was closed or open after closing the program? 

4 hours ago, tonywhitelive said:

You will need to have a way to store the window locations that persists across FileMaker restarts.

 

An Account table is good for this…either by itself or with a more relational structure:

Account-<Account_Window>-Window

 

When a user quits the system, use the OnLastWindowClose Script Trigger and store each window position as table data using Get (Functions)

http://www.twdesigns.com/filemaker-15-functions-list/

 

When the user logs back in, use onFirstWindowOpen to trigger a script that uses Get (AccountName) to located the saved window settings for that AccountName.

Then use the Windowing scripts steps: New Window, Move/Resize Window, etc. to restore the windows.

 

The solution is only to be used by a single user, would using account tables still be needed to do this? I never worked with the user account option in fm, not sure how to use this part of the program yet.

Link to comment
Share on other sites

Make a script named “Save Window Sizes and Positions” and tell the user to run that script before closing

The “Save Window Sizes and Positions” script

  • Uses the WindowNames design function to get the names of open windows
  • Loops through the list or window names looking for windows that you want to restore (using the Select Window script step)
  • Use Get functions and and set field to save window settings to a table

Use a script named “Restore Window Sizes and Positions” to restore the windows

  • Use onFirstWindowOpen to trigger a script that runs on open (or run the script from a button)
  • Read the data stored about the saved windows
  • Loop through the window data and use the New Window script step to open windows (from the correct context) with the correct name and position.
Edited by tonywhitelive
Link to comment
Share on other sites

Thanks for the help. I was able to put this script together, it only seems to remember the last window in the variable though. Not sure if I am on the right track for what I am trying to do.

1772085481_Screenshot2019-04-29at19_54_22.thumb.png.0d54f377e64939cc72c525059a383f3d.png

 

 

 

Link to comment
Share on other sites

Things work better already. Running the script with an extra window open is being reopened when restarting the solution. However, it seems that only the window that is focused on at the moment I run the Save script, is being set correctly in the variable. How can all the windows that are open at the moment of running the save script, being remembered?

 

Here is my current script:

1936064283_Screenshot2019-04-30at07_02_07.thumb.png.6623bd6bf0def06d90e59d4615aa0eaa.png

 

Link to comment
Share on other sites

33 minutes ago, bcooney said:

Yes, I am able to get the list with open windows, but I don't see how this can be used to restore them again after a restart.

33 minutes ago, bcooney said:

 

 

Link to comment
Share on other sites

14 minutes ago, AndreasvanHaren said:

I don't see how this can be used to restore them again

If you have a script that opens a window named "Calculator", then your restore script should have something like:

If [ not IsEmpty ( FilterValues ( "Calculator" ; $listOfWindows ) ) ]
  Perform Script [ "Open Calculator Window" ]
End If

 

Edited by comment
Link to comment
Share on other sites

1 hour ago, comment said:

If you have a script that opens a window named "Calculator", then your restore script should have something like:


If [ not IsEmpty ( FilterValues ( "Calculator" ; $listOfWindows ) ) ]
  Perform Script [ "Open Calculator Window" ]
End If

 

Thanks! This appears to be much easier than I thought. It looks like a loop script isn't needed either, right? Just the script step Windownames. Only weird thing is that this only seems to remember 4 windows in total. A 5th open window will not open with restart. But I cannot image that a user will ever have 5 windows open at the time.

Link to comment
Share on other sites

52 minutes ago, AndreasvanHaren said:

It looks like a loop script isn't needed either, right?

It depends:

If you want to restore all existing windows and what's in them, no matter how they were created, then you will need a looping script to store the data of each open window (including name, current layout, and any other detail you will want to restore), and another looping script to reopen all these windows and restore all their remembered details.

But if - as it seems - you have 4 predefined windows, with a script to open each one, then you only need to remember the names of the currently opened ones and run the corresponding scripts on restore - none of which requires looping.

 

1 hour ago, AndreasvanHaren said:

this only seems to remember 4 windows in total

I am afraid I don't follow you here. The WindowNames function returns the names of all open windows.

Link to comment
Share on other sites

11 hours ago, comment said:

It depends:

If you want to restore all existing windows and what's in them, no matter how they were created, then you will need a looping script to store the data of each open window (including name, current layout, and any other detail you will want to restore), and another looping script to reopen all these windows and restore all their remembered details.

But if - as it seems - you have 4 predefined windows, with a script to open each one, then you only need to remember the names of the currently opened ones and run the corresponding scripts on restore - none of which requires looping.

What I miss now is actually that their positions are not being saves, so I probalby do need a looping for this to make that work. 

11 hours ago, comment said:

 

I am afraid I don't follow you here. The WindowNames function returns the names of all open windows.

It seems also random on which windows are being saved AND openend even if the names are saved in a variable. According to the custom dialoge window that runs after restarting, only 4 out of 5 (main window and 4 extra) windows are being remembered, and it seems to be depending on in which order I had the windows openend. This is the save script:

1963137126_Screenshot2019-05-01at07_50_12.png.6a20260281e16d9359db1682027f4070.png

And this is the script that runs when restarting the solution:841044984_Screenshot2019-05-01at07_54_50.thumb.png.e8ede09be4272dda5ea8bdcb3b493377.png

Link to comment
Share on other sites

4 minutes ago, AndreasvanHaren said:

It seems also random on which windows are being saved AND openend even if the names are saved in a variable.

You can see which windows were saved by looking at the contents of the Preferences::OpenWindows field. As for reopening, find out which one is not being reopened and examine your script for errors in that section (most likely, the names do not match exactly). Nothing a computer does is random.

Link to comment
Share on other sites

1 minute ago, comment said:

You can see which windows were saved by looking at the contents of the Preferences::OpenWindows field. As for reopening, find out which one is not being reopened and examine your script for errors in that section (most likely, the names do not match exactly). Nothing a computer does is random.

Yes, I did that by using a custom dialogue window which is being run after a restart and immediately after the preferences are being read. Even with all windows open saved, the result is always different. Also, when only having a single windows open up till 3 extra windows, everything works correctly. It goes wrong the moment I add that 4th extra window. This can be any kind of window, it doesn't depend on which window.

Link to comment
Share on other sites

I found out why not all windows were listed. They were listed but I didn't see them, because... the custom dialogue window was not resized long enough to show them to me! 🤫

 

 

Link to comment
Share on other sites

All the windows are now being restored after restarting the solution, this is great! Thanks so much for the help.

Only one thing to do is restoring the zoom level from these windows. I know how to set the current window zoom in a variable, but how do I restore it? I cannot find a zoom script step that can be defined by a variable.

 

Link to comment
Share on other sites

After a zoom setting I add an Adjust window step so the layout of that window will be shown correctly without scroll bars, however this also places a window in a way that it always stays inside the visible area of the screen, even though it was half off screen when saving the windows settings before closing the solution. 

Is there are way to avoid this from happening?

Link to comment
Share on other sites

3 hours ago, comment said:

I am not sure why you need to adjust the window after you have restored its original size. 

You have a valid point there, something must be wrong. I will check this. 

Link to comment
Share on other sites

This topic is 1820 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.