How to close window outside of app on Mac?

Im downloading an update file as a zip from a website. When I get the zip file, I launch it to open it. When it opens, it opens a window in the foreground with the decompressed file. Any way to avoid opening this window, or send a command to close it so the user doesn’t get confused by it? Thanks.

Nowadays you don’t control other apps.

However in your situation you’re in luck as you can use the Xojo shell class and the terminal command unzip to unzip a file. No extra gui added :slight_smile:

Thats what Im currently doing. However because I am doing that to unzip the file, apple puts finder on the window displaying it being unzipped. When it is done unzipping, it leaves that window on the screen. I am trying to see if there is a command to send in to prevent that window from opening, or there is something I can send to terminal to shut that window down. Otherwise the user will see it in the foreground and no longer see the update process. The user may think the update process is completed when it is not. I need the finder window to not pop up.

You could use MBS Plugins and expand zip via our archive classes.

It sounds to me that you’re doing this wrong. Please give more details:

  1. Is this a native Mac app or a Web app?

  2. Show us the code that you use to unzip the file.

Also, please move this from the General topic to a more specific one, e.g. Targets/macOS

Jeffery, is it still part of your update mechanism you touched about in another thread ?

In my own update mechanism, instead of the system zip, I use UnZipMBS() to extract my Apple Installer, so it does not show anything.

http://www.monkeybreadsoftware.net/classes.shtml

[quote=388194:@Thomas Tempelmann]It sounds to me that you’re doing this wrong. Please give more details:

  1. Is this a native Mac app or a Web app?

  2. Show us the code that you use to unzip the file.

Also, please move this from the General topic to a more specific one, e.g. Targets/macOS[/quote]
Its a cross platform app for Windows and Mac, here is the portion of the code used for the Mac to unzip the file. Just using the built in system unzip.

[code]Dim f As FolderItem
Dim sError As String = “”
Dim sFilename As String

sFilename = “BudgetPlannerInstallerApple.zip”
f = GetFolderItem(App.FLUpdatePath).Child(sFilename)

If f <> Nil Then
If f.exists Then
f.Launch
If f.LastErrorCode <> 0 Then sError = “1)Unable to unzip BudgetPlannerInstallerApple.zip”
End If
Else
sError = " f = Nil"
End If
[/code]

[quote=388201:@Michel Bujardet]Jeffery, is it still part of your update mechanism you touched about in another thread ?

In my own update mechanism, instead of the system zip, I use UnZipMBS() to extract my Apple Installer, so it does not show anything.

http://www.monkeybreadsoftware.net/classes.shtml[/quote]
Yes. Im trying to develop the Mac version of an existing installer used with our software. Im trying to duplicate what it does on Windows, but Mac does things a little differently than windows so I have to download the file as a zip file from the our website, then unzip it. Im trying to not use any more plugins than I need to. I love the MBS plugins but I don’t want to have to use them any more than I have to. Just looking for a simple solution to close down the window after unzipping, or prevent the window from coming up in the first place.

When Sam suggested to use the Shell to invoke the unzip command, you replied you do that - but you don’t. If you did, you’d solve your issue. Something like this (not tested):

dim sh as new Shell sh.Execute "/usr/bin/unzip "+f.ShellPath

[quote=388254:@Jeffery Lemons]here is the portion of the code used for the Mac to unzip the file. Just using the built in system unzip. …

f.Launch [/quote]

That does not necessarily launch any specific program. It will launch what that user has configured as the default for a *.zip file. Which could well be different on different user machines, depending on what applications they have installed which support zip files.

That’s why you want to explicitly unzip using a specific method so you know how it will behave. The MBS method is great if you have a license. The shell method works too and unlike .Launch you know exactly what will happen.

[quote=388259:@Thomas Tempelmann]When Sam suggested to use the Shell to invoke the unzip command, you replied you do that - but you don’t. If you did, you’d solve your issue. Something like this (not tested):

dim sh as new Shell sh.Execute "/usr/bin/unzip "+f.ShellPath[/quote]

You are right. Very sorry about that. Not sure what I was thinking. This solved my problem. Was able to use this to unzip without displaying the window. Thank you very much.

sh.Execute "open -n " + f.ShellPath

[quote=388266:@Jeffery Lemons]You are right. Very sorry about that. Not sure what I was thinking. This solved my problem. Was able to use this to unzip without displaying the window. Thank you very much.

sh.Execute "open -n " + f.ShellPath

Be aware that using “open” will try to open the file with the user’s default program registered to open zip files. You still don’t have explicit control over that, even if it appears to work on your own machine (due to your default program). I strongly suggest that if you want it to act the same for every user, you explicitly use a specific method instead of using “open”.