1 Reply Latest reply on Jun 20, 2016 8:22 PM by user19752

    Closing All Windows for a Specific File




      I've a developer who works in several different systems a day for different customers, and created a launcher file that uses fmp protocol to open various files on various servers without using an external file reference to them.


      I'm trying to write  a script that will also close all windows for a given file. 


      My first thought was to loop through the windows and use Get ( filename ) to close all windows where Get ( filename ) = $FileName ( and I've already set $FileName to the name of the the file I want to close ). 


      However, Get ( filename ) will get the name of the file running the script, not the name of the file of the window selected.


      Does anyone know a way to get the filename of a window when the window is from a different file than the one running the script ?


      Also, oddly enough, get WindowNames will give me the names of all the windows that are open, but using WindowNames ( "filename" ) with the name of the file I'm trying to close will NOT give me the names of the windows association with that file.  That only works if "filename" is the name of the file you are currently in/ running the script from.

        • 1. Re: Closing All Windows for a Specific File

          What version / platform do you use? I got correct result with WindowNames ( "filename" ) on Win7 / FM15.


          If you failed to "close", you might missed "current file only" check box in Close Windows script step. If you failed to "get names", it can be bug.


          This worked for me if the file is "standalone". I think if the file is referenced from other file, you need to close rerereing file first, so there may be no way to full automate. I close application.



            Exit Loop If [ Let ( $windows = WindowNames ( "filename" ) ; $windows = "" ) ]

            Close Window [ Name: GetValue ( $windows ; 1 ) ]

          End Loop